Closed Bug 1845407 Opened 1 year ago Closed 11 months ago

Firefox does not initially provide accessible API on launch.

Categories

(Core :: Widget: Cocoa, defect, P3)

defect

Tracking

()

RESOLVED FIXED
121 Branch
Tracking Status
firefox121 --- fixed

People

(Reporter: eeejay, Assigned: eeejay)

References

(Regressed 1 open bug)

Details

Attachments

(1 file)

If we set up an external listener to wait for Firefox to launch and then query its accessibility API, we fail. Accessibility services such as Voice Control do this and cannot access Firefox for this reason. Below is a python script that illustrates the issue. It should ideally retrieve the role and name of the top-level application accessibility object.

from Foundation import NSObject
from AppKit import NSWorkspaceDidLaunchApplicationNotification, NSWorkspace
from ApplicationServices import AXUIElementCreateApplication, AXUIElementCopyAttributeValue
from Quartz import CFRunLoopRun

class Observer(NSObject):
  def run_(self, notification):
    info = notification.userInfo()
    print("LAUNCH %s (%s)" %
          (info["NSApplicationName"], info["NSApplicationBundleIdentifier"]))
    pid = notification.userInfo()['NSApplicationProcessIdentifier'];
    acc = AXUIElementCreateApplication(pid)
    err, name = AXUIElementCopyAttributeValue(acc, "AXTitle", None)
    assert err == 0, "Error getting accessible's AXTitle"
    err, role= AXUIElementCopyAttributeValue(acc, "AXRole", None)
    assert err == 0, "Error getting accessible's AXRole"
    print("name=%s role=%s" % (name, role))
    exit(0)


observer = Observer.new()
NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector_name_object_(
  observer, "run:", NSWorkspaceDidLaunchApplicationNotification, None)
CFRunLoopRun()

When we call nextEventMatchingMask we send a "did launch app" notification to the OS workspace. If we do that before we call [NSApp run] accessibility isn't hooked up yet internally in AppKit and we fail to respond to a11y API queries.

Pumping Apple events is currently used for getting url requests in order to launch Firefox with the URLs loading correctly in a browser window. We can achieve the same result by using application:openURLs: in the delegate and calling run on the NSApp earlier and then stopping the loop in order to build the command line and finish initializing Firefox.

Also pumping the apple event queue should be deferred in ProcessNextNativeEvent until [NSApp run] is called.

The severity field is not set for this bug.
:spohl, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(spohl.mozilla.bugs)
Severity: -- → S3
Flags: needinfo?(spohl.mozilla.bugs)
Priority: -- → P3
Attachment #9345675 - Attachment description: Bug 1845407 - Don't pump apple events before application starts. r?spohl! → Bug 1845407 - Don't pump apple events before application starts. r?nika!
Pushed by eisaacson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c869f080aad6 Don't pump apple events before application starts. r=nika

Backed out for causing multiple failures

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-ERROR | netwerk/test/marionette/test_purge_http_cache_at_shutdown.py PurgeHTTPCacheAtShutdownTestCase.test_asetup | OSError: Process has been unexpectedly closed (Exit code: 0) (Reason: Process still running 70.0s after quit request)
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | toolkit/components/backgroundtasks/tests/browser/browser_backgroundtask_specific_pref.js | Test timed out -
  • Failure Log
  • Failure line: TEST-UNEXPECTED-TIMEOUT | browser/base/content/test/sanitize/browser_sanitizeDialog.js (finished) | application timed out after 370 seconds with no output
Flags: needinfo?(eitan)
Backout by ctuns@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/d85342952298 Backed out changeset c869f080aad6 for causing marionette failures in test_purge_http_cache_at_shutdown.py CLOSED TREE
Pushed by eisaacson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c4bfe39c76f0 Don't pump apple events before application starts. r=nika

These unit test failures seem arbitrary and I don't think are related. I tested those unit tests locally and they passed. Same with try.

Flags: needinfo?(eitan)
Pushed by eisaacson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/04750ca05094 Don't pump apple events before application starts. r=nika
Regressions: 1857387

Backed out for causing failures on mozapps/update/

[task 2023-10-06T03:37:13.795Z] 03:37:13     INFO -  TEST-START | toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js
[task 2023-10-06T03:42:14.015Z] 03:42:14  WARNING -  TEST-UNEXPECTED-TIMEOUT | toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js | Test timed out
[task 2023-10-06T03:42:14.016Z] 03:42:14     INFO -  TEST-INFO took 300219ms
[task 2023-10-06T03:42:14.016Z] 03:42:14     INFO -  >>>>>>>
[task 2023-10-06T03:42:14.016Z] 03:42:14     INFO -  (xpcshell/head.js) | test MAIN run_test pending (1)
[task 2023-10-06T03:42:14.016Z] 03:42:14     INFO -  "03:37:13:927 | TEST-INFO | xpcshellUtilsAUS.js | [setupTestCommon : 836] start - general test setup"
[task 2023-10-06T03:42:14.016Z] 03:42:14     INFO -  TEST-PASS | toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js | setupTestCommon - [setupTestCommon : 838] gTestID should be 'undefined' (setupTestCommon should only be called once) - "undefined" === "undefined"
[task 2023-10-06T03:42:14.017Z] 03:42:14     INFO -  (xpcshell/head.js) | test pending (2)
Flags: needinfo?(eitan)

These test failures are looking very scary, as they involve updates (and possibly the failure to relaunch after updates, or worse). We may want to get QA to confirm that this all still works properly. n-i=bytesized for awareness and opinion.

Flags: needinfo?(bytesized)

This is puzzling because the failing tests are supposed to be skipped in mac.

https://searchfox.org/mozilla-central/source/toolkit/mozapps/update/tests/unit_base_updater/xpcshell.ini#54

Flags: needinfo?(eitan)

oh. i misread the ini file. the options don't fall through in that way.

At first glance, these test failures are confusing. They time out after seeming to have done everything successfully and having printed "calling doTestFinish" and "test finished". I'm not entirely clear on what's going on here. I'm going to keep the needinfo on me because I want to take another look at this in a bit.

(In reply to Stephen A Pohl [:spohl] from comment #11)

and possibly the failure to relaunch after updates, or worse

Are you suggesting this because of the nature of the patch, or for some other reason? I'm having a bit of a hard time understanding the patch, so I can't tell if it is likely to cause this sort of problem.

Flags: needinfo?(bytesized) → needinfo?(spohl.mozilla.bugs)

whoops, meant to leave that.

Flags: needinfo?(bytesized)

(In reply to Robin Steuber (they/them) [:bytesized] from comment #14)

Are you suggesting this because of the nature of the patch, or for some other reason? I'm having a bit of a hard time understanding the patch, so I can't tell if it is likely to cause this sort of problem.

Because this patch touches app launch there is a possibility that this affects relaunch after update, which is what might be failing as you suggest?

I am having trouble running these xpc tests locally, I get a system error dialog "dir" is damaged and can't be opened. You should move it to the Trash. Any pointers on how to run this locally are welcome!

I'm afraid that I wasn't able to make any progress figuring out why this test is failing, but I was able to figure out the issue that I believe you are having running the test locally. I believe that you need to add ac_add_options --enable-unverified-updates to your mozconfig and rebuild.

Flags: needinfo?(bytesized)
Pushed by eisaacson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/374f05be6d50 Don't pump apple events before application starts. r=nika
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch

Backed out for causing bc failures on browser/components/* , browser/base/content/*

Backout link

Push with failures

Failure log

Status: RESOLVED → REOPENED
Flags: needinfo?(eitan)
Resolution: FIXED → ---
Target Milestone: 121 Branch → ---
Regressions: 1860975
Regressions: 1860858
Pushed by eisaacson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/275d06a26aff Don't pump apple events before application starts. r=nika
Status: REOPENED → RESOLVED
Closed: 1 year ago11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Regressions: 1862716
Flags: needinfo?(spohl.mozilla.bugs)
Regressions: 1856096

Hello!
Is manual testing required here? If yes, can you provide us some steps to reproduce?

Regressions: 1866098
Regressions: 1872516
Regressions: 1873945
See Also: → 1818194
Regressions: 1881536
See Also: → 1893817
Flags: needinfo?(eitan)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: