Closed Bug 2004469 Opened 11 months ago Closed 10 months ago

opening 4 html files from the command line causes a noticable main process hang in mach_msg2_trap

Categories

(Toolkit :: Startup and Profile System, defect)

Unspecified
macOS
defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: mgaudet, Assigned: mossop)

References

Details

Attachments

(1 external file)

Note: I'm basically unable to reproduce this outside my main install at the moment. More details in a moment.

STR: Have a folder

macOS 15: Have a folder with ~20 HTML docs. do open *.html in a terminal

Expected: 20 tabs open almost instantly

Actual: Hang for ~2 min, only 5 tabs actually open.

Some profiles:

I'm opening in this component because the highest function in the call stack I can name is sendCommandLine

The actual time is spent in an OS frame much further down, mach_msg2_trap


Debugging notes:

  1. If I create a new profile with the profile manager, this reproduces
  2. I can reproduce in Troubleshooting Mode
  3. Version is 147.0a1 (2025-12-05) (aarch64)
  4. I cannot reproduce if I
  • Launch with mozregression
  • put a copy of firefox in ~/tmp, and launch with open -a "$HOME/tmp/Firefox Nightly.app" *.html
  • Even if I create a new profile in the profile manager
  1. I can't reproduce on release, though like mozregression I basicallly just installed Release today.
  2. for i in seq 0 20; do touch test_$i.html; done; is sufficient to test
  3. It's interesting to me that I only ever get ~5 tabs.

Oh, also I tried rebooting the machine -- this fixed an oddity I had been seeing with Safari, where a few tabs weren't loading correctly, but didn't fix firefox.

Ah, interesting. Even opening 3 files is enough for a weird hang.

Summary: opening a moderate (~20) html files from the command line causes a 2 minute main process hang in mach_msg2_trap → opening 4 html files from the command line causes a noticable main process hang in mach_msg2_trap

Ahh -- I tried opening 9 HTML files from Finder using "cmd-down"... same hang, and only 5 tabs opened.

BUT! Dragging all 9 into the window worked fine!

Sounds like an OS issue...

Based on the stack this would only reproduce if you've used the new profiles UI to create a profile.

Is Firefox already open when you trigger opening the files? If so how many profiles are running at once and in which one do the files open?

Flags: needinfo?(mgaudet)
  1. Firefox is already open
  2. I originally only tried reproducing with one (main) profile open. When I tried with the second profile open, the first time it was fast, and the files opened in the second (testing) profile. Now they open in the main profile and are slow again.
  3. The profile UI has only 3 profiles available.
Flags: needinfo?(mgaudet)

So this is probably an issue with the mitigation we added in bug 1945207 to open URLs passed to us by the OS in the most recently used profile. The problem is that the instance that receives the OS notification may not be the one we want to load the URLs into. So we do some async disk I/O to determine the correct instance and then use the remoting system to send a message over the CFMessagePort to have it handle the command line arguments.

But in the case where there is only one profile running we're actually sending a message to ourselves. In my testing this appeared to work fine but my guess is that it is working fine for a single message but when you start sending a bunch we are hitting some kind of lock contention. I do notice from the profiles that we spend almost an exact multiple of 10 seconds in mach_msg2_trap and the timeout we set on sending the message is 10 seconds.

We can probably fix this by skipping sending the message when the target profile is the current profile and just handle the command line arguments directly. I didn't do this originally because re-creating the command line and running it through all command line handlers isn't easy to do from JavaScript. However since the command line in question is quite simple we can probably get away with just parsing it ourselves and opening the URLs directly.

Ok, glad to know there might be an actual issue here rather than my diagnosis which was "this profile is haunted" :)

(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #9)

Ok, glad to know there might be an actual issue here rather than my diagnosis which was "this profile is haunted" :)

To be clear I can't reproduce myself so I'm somewhat guessing. But those 10s timings is suspicious and it is kinda silly that we use the remoting system to talk to the same process anyway so fixing that isn't a bad thing.

Yeah, unfortunately it's hard for me to reproduce outside of my 'main' setup too, so 'might' was carrying a lot of weight in that comment.

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

For more information, please visit BugBot documentation.

Flags: needinfo?(dtownsend)
Assignee: nobody → dtownsend
Status: NEW → ASSIGNED
Pushed by dtownsend@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/18ae2eefe6fd https://hg.mozilla.org/integration/autoland/rev/e31f120f93f1 Avoid using the remoting service when opening external links in the currently running profile. r=profiles-reviewers,jhirsch
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch

I'd be interested to hear if this fixes the issue for you

Flags: needinfo?(dtownsend) → needinfo?(mgaudet)

Works perfectly. Every tab opened under a second even opening 95 html files. https://share.firefox.dev/4qeTGVd is a trimmed profile if you care.

Flags: needinfo?(mgaudet)
Regressions: 2010535
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: