Closed Bug 2036237 Opened 3 months ago Closed 2 months ago

URL from Apple Event / command line is lost when old profile manager dialog relaunches Firefox

Categories

(Toolkit :: Startup and Profile System, defect)

ARM
macOS
defect

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox150 --- wontfix
firefox151 --- wontfix
firefox152 --- wontfix
firefox153 --- fixed

People

(Reporter: Logan, Assigned: Logan)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

When Firefox is launched via open https://example.com (or Python's webbrowser.open()) on macOS and the old profile manager dialog appears (due to StartWithLastProfile=0 in profiles.ini), the URL is not loaded after selecting a profile.

Steps to reproduce

  1. Ensure StartWithLastProfile=0 is set in profiles.ini (or have the old profile manager configured to show on startup)
  2. Ensure Firefox is not already running
  3. Run: open https://example.com (or open -a "Firefox Nightly" https://example.com)
  4. The old profile manager dialog appears
  5. Select a profile and click "Start Firefox"

Expected

Firefox opens and navigates to https://example.com

Actual

Firefox opens to a blank new tab. The URL is lost.

This was encountered in practice when ./mach try auto opens a Lando auth URL via webbrowser.open() and the profile manager intercepts the launch.

Affected versions

Reproduced on both Firefox Release and Firefox Nightly on macOS.

Keywords: regression
Regressed by: 1866098

Set release status flags based on info from the regressing bug 1866098

:eeejay, since you are the author of the regressor, bug 1866098, could you take a look?

For more information, please visit BugBot documentation.

mozregression bisection complete. This is NOT a regression from bug 1866098.

Regression range:
Last good: e9458609191d (2025-09-29)
First bad: e7010b54fe0e (2025-09-30)
Pushlog: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=e9458609191d42bae5f4883d9226e2ecc21a361a&tochange=e7010b54fe0ee4432bda8f36e9f7df623319ff9c

The regressing commit is Bug 1988774 - "Update macOS SDK for tahoe" (cc06e453846c). This only changes the macOS SDK version from 15.5 to a newer one. The SDK change appears to have altered how NSWorkspace's openApplicationAtURL:configuration:completionHandler: handles command-line arguments passed via [config setArguments:]. With the older SDK, -url arguments survived the LaunchChild -> updater -> NSWorkspace relay. With the newer SDK, they do not.

This means the bug is in how the macOS Tahoe SDK handles app relaunch arguments through NSWorkspace, and the fix likely needs to find an alternative way to pass the URL through the profile manager relaunch.

Regressed by: 1988774
No longer regressed by: 1866098

Changing need-info to assignee of Bug 1988774

I'm not familiar with app launch shenanigans on macOS... Stephen, do you know how might the right fix look like here? It's a bit surprising (but plausible) that an SDK update changed behavior here... I don't see anything documented at least from the release notes...

Dave, ni?ing you since you're familiar with launch and the profile manager, in case there might be something obvious going on...

Flags: needinfo?(spohl.mozilla.bugs)
Flags: needinfo?(emilio)
Flags: needinfo?(dtownsend)

On macOS 15 (Sequoia), NSWorkspaceOpenConfiguration's setArguments: is
deprecated and no longer forwards command-line arguments to child
processes. This caused URLs from Apple Events (e.g. open https://...)
to be lost when Firefox relaunches itself through the profile manager.

Two issues needed fixing:

  1. The updater binary (used as a relaunch helper) passes -url arguments
    to Firefox.app via NSWorkspace's setArguments:, which no longer works.
    Fix this by extracting -url arguments and delivering them via
    openURLs:withApplicationAtURL:configuration:completionHandler:
    instead, which sends them as Apple Events to the child process's
    application:openURLs: delegate.

  2. The child process's openURLs: handler only buffered URLs during the
    brief InitializeMacApp() run loop (LaunchStatus::CollectingURLs).
    URLs arriving later (e.g. via Apple Events from the updater) were
    dispatched immediately via nsICommandLineRunner, which fails during
    early startup. Fix this by adding a new LaunchStatus::Running state
    and buffering URLs for all pre-Running states. The transition to
    Running happens after SetupMacCommandLine has consumed startup URLs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Assignee: nobody → loganrosen
Attachment #9576098 - Attachment description: WIP: Bug 2036237 - Fix URL loss during profile manager relaunch on macOS 15+ → Bug 2036237 - Fix URL loss from Apple Events on macOS 15+ r=#mac-reviewers,#application-update-reviewers
Status: NEW → ASSIGNED
Attachment #9576098 - Attachment description: Bug 2036237 - Fix URL loss from Apple Events on macOS 15+ r=#mac-reviewers,#application-update-reviewers → Bug 2036237 - Fix URL loss from Apple Events on macOS r=#mac-reviewers

So the diagnostic in comment 0 changed from what's in phab. The patch is now tweaking the code from bug 1866098. Does it mean that bug is the regressor after all?

Flags: needinfo?(loganrosen)

(or is it something else like the sdk changing some timing or behavior during startup?)

To answer the question from comment 7/8:

Bug 1988774 (SDK update) is the regressor, not Bug 1866098. Here's what happened:

Bug 1866098 introduced the InitializeMacApp() pattern: call [NSApp run] briefly to collect URLs from Apple Events, then applicationDidFinishLaunching: calls [NSApp stop:] to exit the run loop. The code assumes application:openURLs: fires before applicationDidFinishLaunching: (the comment at MacApplicationDelegate.mm:267-269 states this explicitly).

The macOS 26 SDK changed NSApplication.finishLaunching() from dispatching pending Apple Events (kAEOpenDocuments) synchronously inline -- which allowed application:openURLs: to fire before applicationDidFinishLaunching: -- to posting them to the event queue. Since [NSApp stop:] exits the run loop before those queued events are processed, the URLs are never collected.

This appears to be an undocumented SDK-linked behavioral change (Apple's release notes for macOS 26.0-26.4 don't mention it). Bug 2009594 reported the same symptom in January 2026 ("Open URLs from external applications no longer open on MacOS Firefox Nightly 148.0a1") but was closed INCOMPLETE.

Our fix adds a LaunchStatus::Running state so that openURLs: buffers URLs for all pre-Running states, not just CollectingURLs. This means URLs arriving after [NSApp run] exits but before the browser is fully started are still captured by TakeStartupURLs() in SetupMacCommandLine().

See Also: → 2009594
Duplicate of this bug: 2009594
Flags: needinfo?(loganrosen)
See Also: → 2036642
Flags: needinfo?(dtownsend)
Flags: needinfo?(spohl.mozilla.bugs)
Pushed by nfay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/40873380a531 https://hg.mozilla.org/integration/autoland/rev/29edf41ae210 Revert "Bug 2036237 - Fix URL loss from Apple Events on macOS r=mac-reviewers,bradwerth" for causing mochitest failure @ test_apple_event_url.py TestAppleEventURL.test_apple_event_url_survives_profile_manager

Backed out for causing mochitest failure @ test_apple_event_url.py TestAppleEventURL.test_apple_event_url_survives_profile_manager

Backout link

Push with failures

Failure log

Flags: needinfo?(loganrosen)

Apologies – I re-requested review on Phabricator without the flaky test. It unfortunately seems that this is too difficult/flaky to test via Marionette.

Flags: needinfo?(loganrosen)

Set release status flags based on info from the regressing bug 1988774

Duplicate of this bug: 2041162
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch

The patch landed in nightly and beta is affected.
:Logan, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(loganrosen)
Duplicate of this bug: 2041601
Flags: needinfo?(loganrosen)
QA Whiteboard: [qa-triage-done-c154/b153]
Duplicate of this bug: 2055233
No longer duplicate of this bug: 2055233
See Also: → 2055233
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: