Closed Bug 1812567 Opened 4 months ago Closed 4 months ago

plugin-container.app has potentially incorrect ActivationPolicy

Categories

(Core :: Widget: Cocoa, defect)

Firefox 109
defect

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: miika9764, Assigned: spohl)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/109.0

Steps to reproduce:

Use AltTab for macOS and Firefox at the same time

Actual results:

/var/log/com.apple.xpc.launchd/launchd.log got filled with notices and warnings where AltTab tried to subscribe accessibility events:
<Warning>: failed lookup: name = com.apple.axserver, handle = 16259, flags = 0x3, requestor = AltTab[13905], error = 3: No such process

Expected results:

AltTab should have been able to determine from ActivationPolicy that org.mozilla.plugincontainer does not spawn windows where accessiblity events can be observed. The NSApplication.ActivationPolicy enum has 3 possible values:
case regular = 0
case accessory = 1
case prohibited = 2

plugin-container.app reports activationPolicy=accessory, implying that it can spawn windows that can be activated although it doesn't have a menu bar. Perhaps it should be "prohibited" instead?

Disclosure: I have no past experience in macOS programming, so I could be missing something.

https://github.com/lwouis/alt-tab-macos/issues/2225
https://developer.apple.com/documentation/appkit/nsapplication/activationpolicy/accessory

Test using this Swift program:
// ------------------------------------------
// compile:
// swiftc filename.swift
import Cocoa

func axObserverCallback(observer: AXObserver, element: AXUIElement, notificationName: CFString, _: UnsafeMutableRawPointer?) -> Void {
/* print(observer, element, notificationName) */
}

let apps = NSWorkspace.shared.runningApplications
for app in apps {
let pid = app.processIdentifier
let axUiElement = AXUIElementCreateApplication(pid)
var axObserver: AXObserver? = nil
AXObserverCreate(pid, axObserverCallback, &axObserver)
AXObserverAddNotification(axObserver!, axUiElement, kAXFocusedWindowChangedNotification as CFString, nil)
print(app.activationPolicy.rawValue, app, axUiElement)
}
// ------------------------------------------

The Bugbug bot thinks this bug should belong to the 'Core::Layout' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout
Product: Firefox → Core
Component: Layout → Widget: Cocoa

Changing this may have unintended consequences, but it's worth giving it a try.

Assignee: nobody → spohl.mozilla.bugs
Status: UNCONFIRMED → ASSIGNED
Depends on: 557225
Ever confirmed: true

Reporter, could you try this build and let us know if this fixes the issue for you? You may have to launch it manually from System Settings by clicking "Open Anyway" under Security settings.

Flags: needinfo?(miika9764)

Thank you Stephen, it seems to fix the issue for me! I was running AltTab version 6.52.1 from brew. I also created a patch for AltTab that manually ignores all apps with the bundle id org.mozilla.plugincontainer, but that will be obsoleted if this goes to stable.

I believe it's this part of the code that bails out now that LSBackgroundOnly is set to '1':
https://github.com/lwouis/alt-tab-macos/blob/b57a39d8e897435818c754882b5e9ac67c8bea38/src/logic/Application.swift#L53-L60

I did not notice any unintended consequences, but I didn't test the build very thoroughly.

BTW, I grepped my /Applications/, and found that some have both LSBackgroundOnly and LSUIElement in their Info.plist. I don't know how these map to the accessibility property and why plugincontainer originally had LSUIElement. Either way my test program now shows that Nightly plugincontainer is NSApplication.ActivationPolicy.prohibited and not accessory.

Flags: needinfo?(miika9764)
Pushed by spohl@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/97a75b42cf6d
Change the activation policy for plugin-container to NSApplicationActivationPolicyProhibited to make it clear that it cannot itself be activated and should continue to not appear in the Dock. r=mstange
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
See Also: → 1827486
See Also: 1827486
You need to log in before you can comment on or make changes to this bug.