Closed Bug 2069375 Opened 2 months ago Closed 2 months ago

[Wayland] Web content ticks at 60 fps on a 165/240 Hz display while browser chrome ticks at the real refresh rate (multi-monitor GNOME, mixed refresh rates)

Categories

(Core :: Widget: Gtk, defect)

Firefox 155
x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
157 Branch
Tracking Status
firefox-esr140 --- unaffected
firefox-esr153 --- wontfix
firefox155 --- wontfix
firefox156 --- wontfix
firefox157 --- fixed

People

(Reporter: firefox, Assigned: emilio)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 external file)

Web content in the content process runs its refresh driver at a fixed 60 Hz
while the parent (chrome) refresh driver in the very same window runs at the
display refresh rate. Scrolling and page animation are visibly choppier than
the browser UI around them. Reproduced with clean profiles on Firefox 154 and
155. Bug 1645528 was meant to give content processes the widget-local vsync
source; on this setup content appears to be on the 60 Hz software timer.

Environment

  • Fedora 44, GNOME 50.4 / mutter 50.4, Wayland session, GTK 3.24.52
  • Firefox 155.0 (Fedora RPM, firefox-155.0-1.fc44); same result with 154.0-2.fc44
  • Mesa 26.1.8, kernel 7.1.13
  • Hybrid AMD laptop: built-in 1920x1080@240 panel (eDP-1, integrated Vega,
    GNOME primary monitor) plus external 1920x1080@165 monitor (DP-1, discrete
    Navi 22). Mutter primary GPU is the integrated one.
  • No user prefs involved: measured on freshly created profiles.

Measurements (window on the built-in 240 Hz panel unless noted)

  • requestAnimationFrame in a content page: 60 fps, exactly, sustained.
  • requestAnimationFrame in chrome context (Marionette, same window): 236 fps.
  • A GTK4 window's frame clock on the external 165 Hz output: 165 fps, so the
    compositor delivers frame callbacks at the output rate.
  • MOZ_LOG=WidgetWayland:5 on the parent: ~150 frame callbacks/s reach
    WaylandSurface::VSyncCallbackHandler ("set 1 emulated 0"), so the window
    vsync source is healthy.
  • Same page under XWayland (GDK_BACKEND=x11 MOZ_ENABLE_WAYLAND=0): 240 fps.
  • layout.frame_rate=165: content rAF goes to 165 fps. So the content refresh
    driver is following the software vsync rate, not the window vsync.
  • No effect: gfx.display.max-frame-rate, gfx.display.frame-rate-divisor,
    layout.expose_high_rate_mode_from_refreshdriver,
    gfx.webrender.layer-compositor=false.

Steps to reproduce

  1. GNOME Wayland session, two monitors with different refresh rates
    (240 Hz built-in + 165 Hz external), built-in set as primary.
  2. Fresh profile, open a page with a requestAnimationFrame counter, e.g.
    https://www.vsynctester.com or a 10-line page that counts rAF per second.
  3. Compare with the same counter run in the chrome context via the Browser
    Console or Marionette.

Expected: content rAF matches the refresh rate of the output the window is on.
Actual: content rAF is 60; chrome rAF is the output rate.

Notes

  • Not bug 1744896 (Firefox 95 locked to 120 fps, fixed 2022-01) nor its duplicate
    1740255: here the chrome refresh driver is correct and only content is wrong.
  • Bug 1634903 (WORKSFORME, 2020) reported vsynctester.com rates dropping under the
    Wayland vsync source on GNOME; this looks like the same symptom seen from the
    content side.
  • I can run further MOZ_LOG captures or try patches/try builds on request.

I took a poke, I think this is a regression from bug 2000639.

Keywords: regression
Regressed by: 2000639

This only happens if the page has never been idle (which is the case for vsynctester), but if it gets throttled and restarted (i.e., you switch to a different tab, then back) then it starts working properly.

Assignee: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

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

Can you confirm that if you go to vsynctester.com or so, switch to a different tab, then go back, vsync catches up? That is what I'm observing but just want to confirm that it matches your observation as well.

Flags: needinfo?(firefox)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

Can you confirm that if you go to vsynctester.com or so, switch to a
different tab, then go back, vsync catches up?

Confirmed, it catches up. Firefox 155.0 (buildID 20260831190421, Fedora RPM),
fresh profile, GNOME 50.4 Wayland; the window landed on the 165 Hz external
output this time. Driven over Marionette: a local page that moves a
transform every rAF (never idle), and 3-second rAF counts via
WebDriver:ExecuteAsyncScript, each repeated once.

  1. Page loaded in the startup tab 60.3 / 60.1 fps
  2. Open a new tab (focused), wait 2 s, switch back 165.1 / 162.4 fps
  3. Navigate the same tab to the page again (new document) 60.2 / 60.1 fps
  4. Same page loaded in the second tab (opened later) 60.1 fps
  5. Switch away from that tab and back 164.8 fps

So it matches comment 2, and it is per document rather than per tab or per
startup: every new document starts on the global software source (60 Hz on
Wayland, or whatever layout.frame_rate says) and only moves to the widget
source once throttling stops and restarts the timer. Under X11 both sources
tick at the display rate, which is why this is only visible on Wayland with
a >60 Hz display.

The patch reads right to me for this path: NotifyWidgetAttached() only
forces a re-ChooseTimer() when the driver is already ticking without
mOwnTimer, and CreateVsyncRefreshTimer() then finds the widget through
GetRootWidget() -> GetOwnWidget() -> the listener's mWindow, which
AttachToTopLevelWidget() has just set. It is the same restart that
SetActivity() does on the tab switch, just without the throttle detour.

Happy to run the same script against a try build if that helps.

Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d9fdde099e20 https://hg.mozilla.org/integration/autoland/rev/2a8268743e23 Make sure to potentially create a widget-specific vsync timer when attached. r=smaug
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
QA Whiteboard: [qa-triage-done-c158/b157]

Is this something we should uplift to ESR153?

Flags: needinfo?(firefox) → needinfo?(emilio)

Probably not, it's rather subtle and we're doing larger changes here...

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

Attachment

General

Created:
Updated:
Size: