Closed Bug 1985140 Opened 1 year ago Closed 11 months ago

Browser appears hung and vsync not occurring after wake from sleep after disconnecting external monitor on macOS

Categories

(Core :: Graphics, defect)

Firefox 140
Desktop
macOS
defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 148+ fixed
firefox143 --- wontfix
firefox144 --- wontfix
firefox145 --- wontfix
firefox146 --- wontfix
firefox147 --- verified
firefox148 --- verified

People

(Reporter: haik, Assigned: bradwerth)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files, 6 external files, 3 obsolete files)

667.07 KB, text/plain
Details
897.89 KB, text/plain
Details
749.40 KB, application/octet-stream
Details

After resume from sleep of an M3 MacBook Pro (November 2023) running macOS Tahoe 26.0 Beta (25A5346a), occasionally Nightly appears hung. For all windows, the tab bar is displayed as if the window is not the foreground window. Clicking on a different tab appears to have no effect, but after switching to another app and then back to Nightly, the new tab content is displayed. Using Activity Monitor to sample the parent process in the hung state show no instances of VsyncRefreshDriverTimer or nsRefreshDriver caught in the 1.9s sample.

After the hang was occurring, connecting an external monitor resulted in the browser being responsive to clicks again and work as normal without a restart of the browser.

Before the sleep, the laptop was connected to an external monitor and set to mirror mode. At some point, the monitor was disconnected and about 30 minutes later, the laptop was opened. I'm not sure if the computer was put to sleep while the monitor was still attached or after detaching.

See Also: → 1944078

Any ideas how to investigate this further, Brad?

Severity: -- → S3
Flags: needinfo?(bwerth)

(In reply to Jamie Nicol [:jnicol] from comment #1)

Any ideas how to investigate this further, Brad?

The problem will be somewhere in OSXVsyncSource. Here's some guesses as to what's going on:

  1. We aren't checking the return value of CGDisplayRegisterReconfigurationCallback. That would put us in a situation where we get an initial vsync refresh, but then it stops working when displays are reconfigured. Is waking from sleep a reconfiguration event? Comments in the code imply that it is. So perhaps this is our problem. If this is the problem, then we need to figure out what to do in this situation, beyond emitting a warning that it is occurring.
  2. Maybe we're hitting some of the NS_WARNING and that's not being reported adequately. We could try gfxWarning() instead and see if that makes failure messages more visible.

I'll put a patch together that does these things and we'll discuss in review.

Assignee: nobody → bwerth
Flags: needinfo?(bwerth)

This also changes NS_WARNING to gfxWarning(), in the hope of making serious vysnc failures more
visible.

I'll land this, but I'm not convinced it's a fix. Marking leave-open and I'll ask Haik for confirmation in the future.

Keywords: leave-open
Pushed by bwerth@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/10eb1266b91a https://hg.mozilla.org/integration/autoland/rev/d65788f167a1 Prevent OSXVsyncSource from creating a display link after it fails to register a reconfiguration callback. r=mstange

Thanks for looking into this, Brad. I hit the problem again today with a 2025-08-31 build which does have this change.

Built from https://hg.mozilla.org/mozilla-central/rev/f78c1c1a43a459e0918a3dc4b82a2f52be35120c

(In reply to Haik Aftandilian [:haik] from comment #7)

Thanks for looking into this, Brad. I hit the problem again today with a 2025-08-31 build which does have this change.

Built from https://hg.mozilla.org/mozilla-central/rev/f78c1c1a43a459e0918a3dc4b82a2f52be35120c

Okay, thanks for confirming that. What we need to get now is the graphics log, which might have something to say about what the vsync is doing. I'm actually not completely sure of the best way to get that log from you. Two ideas:

  1. Navigate to "about:logging", turn on Graphics logging, and log to a file. Reproduce the problem then upload the tail of the file to this Bug.
  2. After the problem has occurred, crash the parent process by navigating to "about:parentcrash", then link the crash report to this Bug. I think the gfxWarning stuff should appear in the crash log.
See Also: → 1988432

I don't see it mentioned in this bug yet, but have we considered if this might be a regression from bug 1960109?

Keywords: regression
Regressed by: 1960109

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

Duplicate of this bug: 1989442
Duplicate of this bug: 1988432

Haik, if you can reproduce consisently, would you please set the pref "gfx.logging.level" to 2, launch from Terminal and see what warnings are generated? Still trying to figure out what case we are hitting where vsync is lost.

Flags: needinfo?(haftandilian)

I'm not an expert but to add more context I'm using a two monitor setup on a macbook air m4 with the synaptics hardware and drivers. firefox is the only app that has this issue after resuming from sleep.

I was able to hit this problem with logging turned on (gfx.logging.level=2 + Graphics preset), and captured the terminal output, MOZ_LOG output, and took screenshots of the logs when while Nightly was still in the error state. I didn't think to add timestamps to the logs so I'll retry with that enabled. The logs are huge and just the last sections are likely to be useful, but I've included them all at this link. 40M compressed, 1GB decompressed.

In the MOZ_LOG output, the line [Parent 75647: Main Thread]: D/nsRefreshDriver [1345d6200] Completed transaction id 5853 towards the end of the log might be a good reference point. When I resumed the machine and noticed the problem after clicking around in Nightly, that was one of the last lines printed when I checked the log. The log entries after that are from more clicking around, collecting a profile, and then plugging in a monitor which unstuck Nightly.

Files:
MOZ_LOG-output-screenshot.png:
Screenshot of the MOZ_LOG window tailing the log file while the issue was happening after resume from sleep

vsync-debug-log.txt-main.75647.moz_log:
MOZ_LOG output file

Terminal-Output-Screenshot.png:
Screenshot of the terminal output of Firefox

terminal-output-log.txt:
Terminal output

profile_0_75647.json:
A profile collected via signals while in the error state

The screenshots might be useful to understand which log messages occurred after resume from sleep. A few minutes after resuming from sleep, I plugged in an external monitor and then Nightly became responsive as usual.

I had two instances of Nightly running and both were in the hung state after this resume from sleep.

vim in the macOS Terminal couldn't handle the 800M log file, but VScode worked!

Flags: needinfo?(haftandilian)
See Also: → 1994517
QA Whiteboard: [qa-investig-needed-c146/b145]

Hi! Weโ€™ve tried to reproduce this issue without success on macOS 26 mini M1 - Firefox 144.0, 145.0b2, and 146.0a1 (2025-10-16 - Using the Sleep option from the macOS menu:

  1. Connected two monitors, then put macOS to sleep. While in sleep mode, disconnected one monitor and woke the system - all Firefox instances were working properly.
  2. With one monitor connected, put macOS to sleep, then connected another monitor. After waking macOS, all Firefox instances were working.
  3. With two monitors connected, I pressed the Sleep button, then disconnected one monitor. After waking up macOS, all Firefox instances were still working.

Also, the issue could not be reproduced by two other colleagues using different machines: Apple M1 โ€“ macOS 15.0 and MacBook Pro Apple M2 โ€“ macOS 26.1 Beta (25B5057f).

Let us know if you need any help!

QA Whiteboard: [qa-investig-needed-c146/b145] → [qa-investig-done-c146/b145]

Yes this seems to have mostly gone away. However it happened one time this week but that's out of a dozen or so wakeups without issues.

QA Contact: cgeorgiu

I hit this problem again and found the first entries in the MOZ_LOG after resuming from sleep are about not being able to create a display link.

2025-10-17 17:08:13.593579 UTC - [Parent 46158: Main Thread]: W/gfx2d [GFX2-]: Could not create a display link with all active displays. Retrying
2025-10-17 17:08:13.593644 UTC - [Parent 46158: Main Thread]: W/gfx2d [GFX2-]: No display link available when starting vsync

As far as reproduction steps. This time I closed the lid on my MacBook configured in mirror mode with an external monitor. That doesn't put the machine to sleep. Then I pulled out the single USB-C connection providing power, display, peripherals, and ethernet. When I woke up the machine later at 10:08, my two instances of Nightly exhibited the problem. The instance with logging turned on corrected itself after switching virtual workspaces. More logging output below.

From the Graphics about:logging preset (with timestamp added):

2025-10-17 16:51:21.850960 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 4000.000000 ms [index 0/4]
2025-10-17 16:51:25.851189 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 4000.000000 ms [index 1/4]
2025-10-17 16:51:29.900599 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 4000.000000 ms [index 2/4]
2025-10-17 16:51:33.934175 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 4000.000000 ms [index 3/4]
2025-10-17 16:51:37.941647 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 8000.000000 ms [index 0/4]
2025-10-17 16:51:37.941839 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] RemoveRefreshDriver 1411dac00
2025-10-17 16:51:45.956781 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 8000.000000 ms [index 1/3]
2025-10-17 16:51:45.956965 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] RemoveRefreshDriver 137b76c00
Sleep...
Wake
2025-10-17 17:00:42.992708 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 16000.000000 ms [index 0/2]
2025-10-17 17:00:42.992852 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] RemoveRefreshDriver 155de9e00
Sleep...
Wake
2025-10-17 17:08:13.593579 UTC - [Parent 46158: Main Thread]: W/gfx2d [GFX2-]: Could not create a display link with all active displays. Retrying
2025-10-17 17:08:13.593644 UTC - [Parent 46158: Main Thread]: W/gfx2d [GFX2-]: No display link available when starting vsync
2025-10-17 17:08:18.572434 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 32000.000000 ms [index 0/1]
2025-10-17 17:08:50.562441 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] inactive timer next tick in 64000.000000 ms [index 0/1]
2025-10-17 17:08:50.562545 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [139311210] RemoveRefreshDriver 13b553000
2025-10-17 17:08:51.692732 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [137a23940] AddRefreshDriver 13b553000
2025-10-17 17:08:51.693347 UTC - [Parent 46158: Main Thread]: D/nsRefreshDriver [13b553000] Doing catch up tick
2025-10-17 17:08:51.693504 UTC - [Parent 46158: Main Thread]: I/dl.parent PaintFrame: 13dc86020 (), DisplayRoot: 13dc86020 (), Builder: 14035c000, URI: chrome://browser/content/browser.xhtml
2025-10-17 17:08:51.693598 UTC - [Parent 46158: Main Thread]: I/dl.parent (14035c000) RDL - AttemptPartialUpdate, root frame: 13dc86020
2025-10-17 17:08:51.693683 UTC - [Parent 46158: Main Thread]: I/dl.parent (14035c000) RDL - Clearing retained display list builder data

From Firefox's terminal output at time of waking from sleep:

Wake
2025-10-17 17:08:13.800437 UTC - [GPU 46163: Compositor]: D/WebRenderBridgeParent WebRenderBridgeParent::CompositeToTarget() PipelineId 10000000e Id 1 root 1
2025-10-17 17:08:13.910926 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] AddRefreshDriver 105bf5e00
2025-10-17 17:08:13.911856 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] inactive timer got new refresh driver 105bf5e00, resetting rate
2025-10-17 17:08:13.911897 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [105bf5e00] Doing catch up tick
2025-10-17 17:08:14.913457 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] inactive timer next tick in 1000.000000 ms [index 0/1]
2025-10-17 17:08:14.913498 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] RemoveRefreshDriver 105bf5e00
2025-10-17 17:08:30.116195 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] AddRefreshDriver 105bf5e00
2025-10-17 17:08:30.116240 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [1205b6b00] inactive timer got new refresh driver 105bf5e00, resetting rate
2025-10-17 17:08:30.116830 UTC - [Child 46172: Main Thread]: D/nsRefreshDriver [105bf5e00] Doing catch up tick

Very good. I'll pick through the logs and develop a theory of the case shortly.

I think what is happening is this call pattern:

  1. Monitor is disconnected, OnDisplayReconfiguration executes.
  2. This calls CreateDisplayLink, which fails, nulls out the display link, emits a warning, and reschedules itself 100ms later using RetryCreateDisplayLink. It immediately returns.
  3. OnDisplayReconfiguration then calls EnableVsync, which fails because the display link has been nulled out. It reschedules itself 100ms later using RetryEnableVsync.
  4. This is all I can confirm from the logs in comment 18, so the rest is speculation...
  5. The two previously scheduled calls arrive in the opposite order, and EnableVsync fails again because the display link is still null. The display link is never started.

If this is what's happening, then one way to fix it will be to create a new timed callback method CreateDisplayLinkAndEnableVsync which combines both methods -- same as they appear in OnDisplayReconfiguration. I'm going to try this out, as well as add a bit more gfxWarning logging.

(In reply to Brad Werth [:bradwerth] from comment #20)

I think what is happening is this call pattern:

  1. Monitor is disconnected, OnDisplayReconfiguration executes.
  2. This calls CreateDisplayLink, which fails, nulls out the display link, emits a warning, and reschedules itself 100ms later using RetryCreateDisplayLink. It immediately returns.
  3. OnDisplayReconfiguration then calls EnableVsync, which fails because the display link has been nulled out. It reschedules itself 100ms later using RetryEnableVsync.
  4. This is all I can confirm from the logs in comment 18, so the rest is speculation...
  5. The two previously scheduled calls arrive in the opposite order, and EnableVsync fails again because the display link is still null. The display link is never started.

If this is what's happening, then one way to fix it will be to create a new timed callback method CreateDisplayLinkAndEnableVsync which combines both methods -- same as they appear in OnDisplayReconfiguration. I'm going to try this out, as well as add a bit more gfxWarning logging.

If you want to add some logging, but not commit it, I can test with a patch.

This changes a few things:

  1. CreateDisplayLink loses its ability to reschedule itself. This is
    because the rescheduling is only useful within the display
    reconfiguration callback, and in such a case should be followed by a
    call to EnableVsync.
  2. A new retry callback CreateDisplayLinkAndEnableVsync is created to
    handle the one-time retry within the display reconfiguration callback.
  3. The OSXVsyncSource constructor no longer attempts to recreate the
    display link if CreateDisplayLink fails. The only callsite for the
    constructor will fallback to software vsync in such a case, and the
    rescheduled attempt wasn't preventing that from happening anyway.
  4. There are more gfxWarning messages, with more clarity on exactly
    which call has failed.

(In reply to Brad Werth [:bradwerth] from comment #20)
5) The two previously scheduled calls arrive in the opposite order, and EnableVsync fails again because the display link is still null. The display link is never started.

Rather, the second callback overwrites the first, and the callback RetryCreateDisplayLink never fires. Later when RetryEnableVsync fires, it fails.

Regardless the proposed patch will also fix this behavior.

Attachment #9520860 - Attachment description: WIP: Bug 1985140 Part 2: Make OSXVsyncSource safely retry vsync within display reconfiguration callback. → Bug 1985140 Part 2: Make OSXVsyncSource safely retry vsync within display reconfiguration callback.
Pushed by bwerth@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/3db184668e0f https://hg.mozilla.org/integration/autoland/rev/66e538e4dd1f Part 2: Make OSXVsyncSource safely retry vsync within display reconfiguration callback. r=mac-reviewers,mstange

Marking as RESOLVED until and unless.

Status: NEW → RESOLVED
Closed: 1 year ago
Keywords: leave-open
Resolution: --- → FIXED

Is that a fix we should consider uplifting in our last betas or can it ride the 146 train? Thanks

Flags: needinfo?(bwerth)

(In reply to Pascal Chevrel:pascalc from comment #27)

Is that a fix we should consider uplifting in our last betas or can it ride the 146 train? Thanks

I want Haik to confirm it in Nightly and then I'll request uplift.

Flags: needinfo?(bwerth) → needinfo?(haftandilian)

I haven't encountered the problem with the fix, but haven't tested it as much as I would like. I'll continue testing with the official Nightly builds this week and update the bug.

I have both Release and Nightly running and I hit the problem on Release, but Nightly was not affected. Normally, I would hit it with all browsers running. I didn't have logging enabled unfortunately.

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

For more information, please visit BugBot documentation.

Flags: needinfo?(bwerth)

(In reply to Haik Aftandilian [:haik] from comment #30)

I have both Release and Nightly running and I hit the problem on Release, but Nightly was not affected. Normally, I would hit it with all browsers running. I didn't have logging enabled unfortunately.

Sounds fixed. Logging is really only going to tell us how it's failing, so I'm not sure it's important to confirm the fix. As you continue to verify that it's working, I'll mark the Bug as RESOLVED and request uplift at the end of the week.

Flags: needinfo?(bwerth)

(In reply to Brad Werth [:bradwerth] from comment #32)

(In reply to Haik Aftandilian [:haik] from comment #30)

I have both Release and Nightly running and I hit the problem on Release, but Nightly was not affected. Normally, I would hit it with all browsers running. I didn't have logging enabled unfortunately.

Sounds fixed. Logging is really only going to tell us how it's failing, so I'm not sure it's important to confirm the fix. As you continue to verify that it's working, I'll mark the Bug as RESOLVED and request uplift at the end of the week.

Could you request uplift before Friday? We build our last beta on Friday 1PM UTC. Thanks

Flags: needinfo?(bwerth)

Comment on attachment 9520860 [details]
Bug 1985140 Part 2: Make OSXVsyncSource safely retry vsync within display reconfiguration callback.

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: macOS users who connect or disconnect an external monitor during device sleep may find Firefox unresponsive until it is relaunched.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is a relatively small code change that is objectively more correct than current behavior.
  • String changes made/needed:
  • Is Android affected?: No
Flags: needinfo?(bwerth)
Attachment #9520860 - Flags: approval-mozilla-beta?
Attachment #9520860 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Still looks good.

I've hit the problem 2 more times where it occurred on Release (without the fix) but did not occur on Nightly (with this fix).

My steps to reproduce are below.

MacBook Pro, 14-inch, Nov 2023, M3
Computer connected to a USBC hub with a single cable for power, display, keyboard, mouse, ethernet.
Laptop open with screen mirroring enabled.

  1. close the lid
  2. computer continues to work via external keyboard, mouse, monitor
  3. unplug USBC from laptop
  4. wait 5 seconds
  5. open lid on laptop

Firefox is visually unresponsive and only refreshes after switching apps and coming back to Firefox.

Flags: needinfo?(haftandilian)

Should we uplift this to ESR140? It'll need a bit of rebasing to do so if yes.

Flags: needinfo?(bwerth)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #37)

Should we uplift this to ESR140? It'll need a bit of rebasing to do so if yes.

My opinion is that it can ride the trains, but if there's anybody in Cocoa:Widget who wants to see it uplifted, I'll rebase and put it together.

Flags: needinfo?(bwerth)

(In reply to Brad Werth [:bradwerth] from comment #38)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #37)

Should we uplift this to ESR140? It'll need a bit of rebasing to do so if yes.

My opinion is that it can ride the trains, but if there's anybody in Cocoa:Widget who wants to see it uplifted, I'll rebase and put it together.

I'm being unclear. I don't know that this needs to go to ESR. I think it's an avoidable edge case. But... I guess I'm talking myself around. Since ESR is in use for so long, it would be rough for those users who encounter this issue during their usage. I'll put the rebased patch together.

I just hit the bug again so let's hold off. Brad, I'll try and reproduce with graphics logging. Should I file a new bug or add more here?

Flags: needinfo?(bwerth)

(In reply to Haik Aftandilian [:haik] from comment #40)

I just hit the bug again so let's hold off. Brad, I'll try and reproduce with graphics logging. Should I file a new bug or add more here?

Let's keep it here. If you have logging from the failure, that should tell us what part of the vsync restore process is breaking down.

For this log file, my steps were as follows. It took several tries before hitting the problem.

  1. Close the laptop lid so that the laptop continued running with the external monitor only
  2. Start logging
  3. Disconnect the single plug handling display, networking, USB, etc
  4. Wait ~2 minutes
  5. Open laptop lid (macOS logs show the wake up happened at 20:07:22).
  6. Observe that Nightly is not responsive, after each click switch to another app and back again for the screen to update
  7. Stop logging
  8. Restarting Nightly is required to get it back to a normal state

(In reply to Haik Aftandilian [:haik] from comment #42)

Created attachment 9527526 [details]
Log file with the graphics preset enabled

This log file has no text from the gfxWarning logs that mentions "display link". I think you'll need to set the pref "gfx.logging.level" to 2 and try again. I'm sorry!

Same steps as before but with gfx.logging.level=2 (and I forgot to add "timestamp,sync" to the log mode this time.)

  1. Close the laptop lid so that the laptop continued running with the external monitor only
  2. Start logging
  3. Disconnect the single plug handling display, networking, USB, etc
  4. Wait ~8 minutes
  5. Open laptop lid
  6. Observe that Nightly is not responsive, after each click switch to another app and back again for the screen to update
  7. Stop logging
  8. Restarting Nightly is required to get it back to a normal state

Thanks. Okay, the log shows that this is failing in OSXVsyncSource::DisplayReconfigurationCallback, and then failing again in the retry. But that doesn't make us fallback to software vsync, which is the part that's missing. I think we need a new part that when we fail in the callback, instead of retrying:

  1. Call OSXVsyncSource::Shutdown.
  2. Clear out the gfxPlatform::mGlobalHardwareVsyncSource. No method currently exists to do this.
  3. Either immediately or after some delay, call gfxPlatform::ReInitFrameRate, which will attempt to setup hardware vsync again (sort of like doing our existing retry) and will fallback to software upon failure.

I'll build a new Part that does this.

Flags: needinfo?(bwerth)

This adds a method gfxPlatform::ResetHardwareVsyncSource to allow a
hardware vsync source to remove itself when needed. The OSXVsyncSource
now calls this method when display reconfiguration fails. This allows a
software vsync method to be used as a fallback, ensuring that some
vsync source is active.

Haik, I'd appreciate you applying the Part 3 patch locally and seeing if that build exhibits the problem.

Flags: needinfo?(haftandilian)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Duplicate of this bug: 1994517

(In reply to Brad Werth [:bradwerth] from comment #47)

Haik, I'd appreciate you applying the Part 3 patch locally and seeing if that build exhibits the problem.

I haven't been able to reproduce the problem with the patch. I've gone through several cycles and just once saw the following in the log without any hanging in the browser. Before testing the patch, I wanted to make sure I could still reproduce it the bug. I was able to, but it took more iterations today.

18953 2025-11-19 19:23:08.630975 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: Could not create a display link with all active displays.
18954 2025-11-19 19:23:08.630980 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: No display link available when starting vsync.
18955 2025-11-19 19:23:08.630982 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: Display reconfiguration vsync has failed; giving up.
18956 2025-11-19 19:23:08.630988 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: Could not create a display link with all active displays.
18957 2025-11-19 19:23:08.630989 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: Could not create a display link during construction. This is unrecoverable. We'll fallback to software vsync.
18958 2025-11-19 19:23:08.630991 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: No display link available when starting vsync.
18959 2025-11-19 19:23:08.630992 UTC - [Parent 69452: Main Thread]: W/gfx2d [GFX2-]: OS X Vsync source not enabled. Falling back to software vsync.
Flags: needinfo?(haftandilian)

(In reply to Haik Aftandilian [:haik] from comment #49)

I haven't been able to reproduce the problem with the patch.

Cool. The log you posted is showing the expected behavior when display link creation fails. And if you are subsequently getting vsync notifications (and therefore continued rendering), then that's a strong indicator that the software fallback is working in these conditions. The only other thing I can imagine testing is repeating the Steps to Reproduce a second time, after the first potential failure. It would be interesting to know if we can subsequently get hardware vsync again, or again successfully fallback to software vsync.

(In reply to Brad Werth [:bradwerth] from comment #50)

(In reply to Haik Aftandilian [:haik] from comment #49)

I haven't been able to reproduce the problem with the patch.

Cool. The log you posted is showing the expected behavior when display link creation fails. And if you are subsequently getting vsync notifications (and therefore continued rendering), then that's a strong indicator that the software fallback is working in these conditions. The only other thing I can imagine testing is repeating the Steps to Reproduce a second time, after the first potential failure. It would be interesting to know if we can subsequently get hardware vsync again, or again successfully fallback to software vsync.

I did retry the steps with the same instance of Firefox and after those log entries, there aren't any more gfx2d entries for the subsequent attempts at reproducing the bug. I'll attach the full log file.

Attached file Patch 3 testing log .gz file โ€”

(In reply to Haik Aftandilian [:haik] from comment #51)

I did retry the steps with the same instance of Firefox and after those log entries, there aren't any more gfx2d entries for the subsequent attempts at reproducing the bug. I'll attach the full log file.

Log file isn't text and I can't figure out the encoding. Regardless, based on your experience testing, I think we're good.

Attachment #9527927 - Attachment mime type: text/plain → application/octet-stream
Attachment #9527927 - Attachment description: Patch 3 testing log → Patch 3 testing log .gz file

(In reply to Brad Werth [:bradwerth] from comment #53)

Log file isn't text and I can't figure out the encoding. Regardless, based on your experience testing, I think we're good.
Fixed.

Status: REOPENED → RESOLVED
Closed: 1 year ago → 11 months ago
Resolution: --- → FIXED

Whoops. Still need to review and land Part 3.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 146 Branch → ---
Attachment #9527588 - Attachment description: WIP: Bug 1985140 Part 3: Make OSXVsyncSource give up when display reconfiguration fails. → Bug 1985140 Part 3: Make OSXVsyncSource give up when display reconfiguration fails.
Duplicate of this bug: 1996447
Duplicate of this bug: 2005364

Haik, if you're willing, please try reproducing with the updated Part 3 https://phabricator.services.mozilla.com/D273131 applied.

Flags: needinfo?(haftandilian)
Duplicate of this bug: 2005260
Duplicate of this bug: 2005896
No longer duplicate of this bug: 2005260
Pushed by bwerth@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a17d30fdccc1 https://hg.mozilla.org/integration/autoland/rev/71975febf382 Part 3: Make OSXVsyncSource give up when display reconfiguration fails. r=mstange
Status: REOPENED → RESOLVED
Closed: 11 months ago → 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Flags: needinfo?(haftandilian)

I cannot reproduce the issue with the steps described by Haik on slack running latest Nightly 148.0a1 under macOS 26.1 ARM. Previously, I was able to reproduce it using an affected Nightly build.

STR:

  1. One external monitor connected via USBC/thunderbolt
  2. Have MacBookPro open and the laptop screen configured so laptop screen is a mirror of external monitor
  3. Close lid (laptop continues running on external monitor)
  4. Wait 10 seconds
  5. Pull out USBC plug for external monitor
  6. Wait 10 seconds
  7. Open laptop, observe if Firefox is responsive

Comment on attachment 9527588 [details]
Bug 1985140 Part 3: Make OSXVsyncSource give up when display reconfiguration fails.

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Under some conditions, wake from sleep will cause FF to stop rendering until it is relaunched.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: QA has been able to verify so far, and should continue to use that method. My summary:
  1. attach external monitor to laptop
  2. close laptop lid
  3. wait for laptop sleep mode to engage (10 seconds?)
  4. detach external monitor
  5. open laptop lid
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Activates a working fallback in an existing error case, rather than silently failing.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9527588 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Comment on attachment 9527588 [details]
Bug 1985140 Part 3: Make OSXVsyncSource give up when display reconfiguration fails.

Approved for 147.0b6.

Attachment #9527588 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-investig-done-c146/b145] → [qa-investig-done-c146/b145][uplift][qa-ver-needed-c148/b147]

This is also verified as fixed on latest Beta 147.0b6 (build downloaded from treeherder) on macOS 26.1.

QA Whiteboard: [qa-investig-done-c146/b145][uplift][qa-ver-needed-c148/b147] → [qa-investig-done-c146/b145][uplift][qa-ver-done-c148/b147]
Flags: qe-verify+
Duplicate of this bug: 2006703
Duplicate of this bug: 2007232

Bumping to S2. We have many dupes of this bug (7 at this time) and it requires the user to restart Firefox to continue working.

Severity: S3 → S2
Duplicate of this bug: 2007122
See Also: 1988432, 1994517 →

Given the number of dupes, I think we'll still want this on ESR140 also, but I also think we can let it bake a cycle first. The 3 patches mostly cherry-pick cleanly with Part 2 needing just a minor bit of rebasing.

Comment on attachment 9509883 [details]
Bug 1985140: Prevent OSXVsyncSource from creating a display link after it fails to register a reconfiguration callback.

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Seems to affect many users.
  • User impact if declined: If user connects or disconnects external monitor when device is asleep, Firefox will be unresponsive until it is restarted.
  • Fix Landed on Version: 147
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): In the problem case, shifts over to an existing fallback that historically has worked well.
Attachment #9509883 - Flags: approval-mozilla-esr140?

(In reply to Brad Werth [:bradwerth] from comment #73)

Comment on attachment 9509883 [details]
Bug 1985140: Prevent OSXVsyncSource from creating a display link after it fails to register a reconfiguration callback.

All parts (1 2 and 3) are needed for uplift to ESR140. Bugzilla interface makes this difficult to express.

Attachment #9509883 - Flags: approval-mozilla-esr140?

This also changes NS_WARNING to gfxWarning(), in the hope of making serious vysnc failures more
visible.

Original Revision: https://phabricator.services.mozilla.com/D262819

Attachment #9535722 - Flags: approval-mozilla-esr140?

This changes a few things:

  1. CreateDisplayLink loses its ability to reschedule itself. This is
    because the rescheduling is only useful within the display
    reconfiguration callback, and in such a case should be followed by a
    call to EnableVsync.
  2. A new retry callback CreateDisplayLinkAndEnableVsync is created to
    handle the one-time retry within the display reconfiguration callback.
  3. The OSXVsyncSource constructor no longer attempts to recreate the
    display link if CreateDisplayLink fails. The only callsite for the
    constructor will fallback to software vsync in such a case, and the
    rescheduled attempt wasn't preventing that from happening anyway.
  4. There are more gfxWarning messages, with more clarity on exactly
    which call has failed.

Original Revision: https://phabricator.services.mozilla.com/D269119

Attachment #9535723 - Flags: approval-mozilla-esr140?

This adds a method gfxPlatform::ResetHardwareVsyncSource to allow a
hardware vsync source to remove itself when needed. The OSXVsyncSource
now calls this method when display reconfiguration fails, and the
time-delayed retry also fails. This allows a software vsync method to
be used as a fallback, ensuring that some vsync source is active.

Original Revision: https://phabricator.services.mozilla.com/D273131

Attachment #9535724 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined: Seems to affect many users. If user connects or disconnects external monitor when device is asleep, Firefox will be unresponsive until it is restarted.
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: yes
  • Steps to reproduce for manual QE testing: QA has been able to verify so far, and should continue to use that method. My summary:
    attach external monitor to laptop
    close laptop lid
    wait for laptop sleep mode to engage (10 seconds?)
    detach external monitor
    open laptop lid
  • Risk associated with taking this patch: low
  • Explanation of risk level: Activates a working fallback in an existing error case, rather than silently failing.
  • String changes made/needed: None
  • Is Android affected?: no
Flags: qe-verify+
Duplicate of this bug: 2008778
Duplicate of this bug: 2009569
Attachment #9535722 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9535723 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9535724 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+

:bradwerth, this was backed out from esr140 for causing build failures
Run
Example Log

Flags: needinfo?(bwerth)
Attachment #9535722 - Flags: approval-mozilla-esr140+ → approval-mozilla-esr140?
Attachment #9535723 - Flags: approval-mozilla-esr140+ → approval-mozilla-esr140?
Attachment #9535724 - Flags: approval-mozilla-esr140+ → approval-mozilla-esr140?

(In reply to Donal Meehan [:dmeehan] from comment #83)

:bradwerth, this was backed out from esr140 for causing build failures

I apologize for that. I've fixed the build failures in my local patches, and I'll re-request the updated patches as an esr uplift request.

Flags: needinfo?(bwerth)

This also changes NS_WARNING to gfxWarning(), in the hope of making serious vysnc failures more
visible.

Original Revision: https://phabricator.services.mozilla.com/D262819

Attachment #9538007 - Flags: approval-mozilla-esr140?

This changes a few things:

  1. CreateDisplayLink loses its ability to reschedule itself. This is
    because the rescheduling is only useful within the display
    reconfiguration callback, and in such a case should be followed by a
    call to EnableVsync.
  2. A new retry callback CreateDisplayLinkAndEnableVsync is created to
    handle the one-time retry within the display reconfiguration callback.
  3. The OSXVsyncSource constructor no longer attempts to recreate the
    display link if CreateDisplayLink fails. The only callsite for the
    constructor will fallback to software vsync in such a case, and the
    rescheduled attempt wasn't preventing that from happening anyway.
  4. There are more gfxWarning messages, with more clarity on exactly
    which call has failed.

Original Revision: https://phabricator.services.mozilla.com/D269119

Attachment #9538008 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined: Seems to affect many users. If user connects or disconnects external monitor when device is asleep, Firefox will be unresponsive until it is restarted.
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: yes
  • Steps to reproduce for manual QE testing: QA has been able to verify so far, and should continue to use that method. My summary:
    attach external monitor to laptop
    close laptop lid
    wait for laptop sleep mode to engage (10 seconds?)
    detach external monitor
    open laptop lid
  • Risk associated with taking this patch: low
  • Explanation of risk level: Activates a working fallback in an existing error case, rather than silently failing.
  • String changes made/needed: None
  • Is Android affected?: no
Attachment #9538009 - Flags: approval-mozilla-esr140?

This adds a method gfxPlatform::ResetHardwareVsyncSource to allow a
hardware vsync source to remove itself when needed. The OSXVsyncSource
now calls this method when display reconfiguration fails, and the
time-delayed retry also fails. This allows a software vsync method to
be used as a fallback, ensuring that some vsync source is active.

Original Revision: https://phabricator.services.mozilla.com/D273131

Attachment #9535722 - Attachment is obsolete: true
Attachment #9535722 - Flags: approval-mozilla-esr140?
Attachment #9535723 - Attachment is obsolete: true
Attachment #9535723 - Flags: approval-mozilla-esr140?
Attachment #9535724 - Attachment is obsolete: true
Attachment #9535724 - Flags: approval-mozilla-esr140?
Attachment #9538009 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9538008 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9538007 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Summary: Browser appears hung and vsync not occurring after wake from sleep after disconnecting external monitor → Browser appears hung and vsync not occurring after wake from sleep after disconnecting external monitor on macOS
Version: unspecified → Firefox 140
Duplicate of this bug: 2011751
No longer duplicate of this bug: 2011751
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: