Low frame rate while smooth scrolling when picture-in-picture video is active
Categories
(Core :: Graphics, defect)
Tracking
()
People
(Reporter: andysem, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(5 files)
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
Steps to reproduce:
- Have smooth scrolling enabled in Firefox settings.
- Open any Youtube (or any other site) video and start playback.
- Click on the icon to enable picture-in-picture mode.
- Switch to another tab, open a web page and try scrolling through it with the mouse wheel.
Actual results:
The scrolling is noticeably less smooth than when picture-in-picture is not active, as if the frame rate is cut in half. A few observations:
- The picture-in-picture video is played back normally, the video frame rate seems normal.
- CPU is not fully loaded when the video is being played, nor when I scroll the page. This does not seem like a CPU shortage.
- The scrolling becomes smooth again when the video in picture-in-picture mode is paused or returned to the normal, in-page mode and that page tab is in the background (i.e. when I switch away from the tab with the playing video).
This is on Firefox 87.0 (but was reproducible on previous releases, since the introduction of picture-in-picture mode, AFAIR). Kubuntu 20.10, Nvidia driver 465.19.01 (also, not specific to Kubuntu or Nvidia driver version). WebRender is enabled, but reproduces without it as well.
Expected results:
Picture-in-picture video should not affect the scrolling smoothness as long as there is enough CPU/GPU resources.
Comment 1•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Toolkit::Video/Audio Controls' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Updated•4 years ago
|
Comment 2•4 years ago
|
||
I think this is happening because the background tab is getting deprioritized though I thought we had some special code to keep the video frames playing at normal frame rate when in PiP.
Please note that video playback in PiP is at normal frame rate. It's the non-video tab that is on the foreground which I'm scrolling that has low frame rate.
Comment 4•4 years ago
|
||
Ah okay thanks for that clarification.
Comment 5•4 years ago
|
||
Can you upload a profile using https://profiler.firefox.com/ and the Firefox Graphics preset of a short span where the problem is happening?
Here is a profile that was collected while playing a video in PiP mode and scrolling this bug page.
Comment 7•4 years ago
|
||
Thanks.
The profile has a lot of dropped frames markers, seems like almost half of all video frames are dropped? Which seems weird since you said that the video seems fine. Perhaps it's less noticeable in the video? I'm not sure. So maybe we are just struggling to put that many frames on the screen? Moving to graphics under that hypothesis to get a look.
Comment 10•3 years ago
|
||
Driver Vendor: nvidia/unknown
Reporter | ||
Comment 11•3 years ago
|
||
This does not seem like a duplicate. The referenced bug cites enabling EGL as the solution/workaround, and it does not help in my case. I tried starting Firefox with MOZ_X11_EGL=1, about:support says "force_enabled by user: Force enabled by envvar" for X11_EGL, and the issue reproduces exactly as described in the initial post.
I'm on Nvidia driver 470.74 now.
Reporter | ||
Comment 12•3 years ago
|
||
Here is the fresh about:support contents with EGL enabled.
Reporter | ||
Comment 13•3 years ago
|
||
Here is a fresh profile with EGL enabled.
Comment hidden (obsolete) |
Comment 15•3 years ago
|
||
(In reply to andysem from comment #11)
The referenced bug cites enabling EGL as the solution/workaround, and it does not help in my case.
When starting Firefox 92 with MOZ_X11_EGL=1:
Do you encounter the same problem when playing the video in a second regular window instead of a PiP window?
Reporter | ||
Comment 16•3 years ago
|
||
(In reply to Darkspirit from comment #15)
(In reply to andysem from comment #11)
The referenced bug cites enabling EGL as the solution/workaround, and it does not help in my case.
When starting Firefox 92 with MOZ_X11_EGL=1:
Do you encounter the same problem when playing the video in a second regular window instead of a PiP window?
Yes, the issue reproduces with the second window as well, exactly like with PiP.
The page with the video (Youtube) in the new window scrolls smoothly. The original window from which the video was forked scrolls with noticeably reduced frame rate. I can switch to different tabs in the original window - the scrolling frame rate is consistently low on every tab. Even the list of tabs, as I scroll through it with the mouse wheel, is animated at reduced frame rate.
Comment 17•3 years ago
|
||
Is it also reproducible with https://nightly.mozilla.org?
Reporter | ||
Comment 18•3 years ago
|
||
I've recorded a screencast of this issue. On the left is the original window, on the right is the window with the video. You can see the scrolling on the left becomes noticeably choppy when the video on the right starts playing.
Reporter | ||
Comment 19•3 years ago
|
||
(In reply to Darkspirit from comment #17)
Is it also reproducible with https://nightly.mozilla.org?
Yes, it is.
Reporter | ||
Comment 20•3 years ago
|
||
(In reply to andysem from comment #19)
(In reply to Darkspirit from comment #17)
Is it also reproducible with https://nightly.mozilla.org?
Yes, it is.
Forgot to mention that the tested build id is 20210921094642.
Also, in the recorded screencast the issue is not as pronounced as in real use. I had to make the windows smaller to avoid the video encoder from saturating the CPU. In the real life the browser is maximized on a 4K display, and scrolling while the video is playing appears more choppy.
Comment 21•3 years ago
|
||
(In reply to andysem from comment #20)
Forgot to mention that the tested build id is 20210921094642.
Can you still reproduce this if you set layout.frame_rate = 0 and restart Nightly?
Reporter | ||
Comment 22•3 years ago
|
||
(In reply to Darkspirit from comment #21)
Can you still reproduce this if you set layout.frame_rate = 0 and restart Nightly?
Yes, it still reproduces.
Comment 23•3 years ago
|
||
Thanks! Then you have found a new bug. (bug 1631353 comment 16 could also be relevant.)
Can you still reproduce this if you set gfx.webrender.allow-partial-present-buffer-age to false, gfx.webrender.max-partial-present-rects to 0 and restart Nightly? Or does it even become worse?
Reporter | ||
Comment 24•3 years ago
|
||
(In reply to Darkspirit from comment #23)
Can you still reproduce this if you set gfx.webrender.allow-partial-present-buffer-age to false, gfx.webrender.max-partial-present-rects to 0 and restart Nightly? Or does it even become worse?
Yes, it still reproduces. The properties make no difference.
Reporter | ||
Comment 25•3 years ago
|
||
(In reply to andysem from comment #22)
(In reply to Darkspirit from comment #21)
Can you still reproduce this if you set layout.frame_rate = 0 and restart Nightly?
Yes, it still reproduces.
An update. Previously, I tested this property with EGL enabled, and the issue indeed reproduced.
Today I tried this property with EGL force-disabled, and the scrolling issue did not reproduce. However, instead my 4-core CPU is constantly loaded for about 45-50% on all cores (where 100% would mean all cores saturated) while the video is playing - in PiP mode or not. Normally, playing the same video consumes around 15-20% CPU.
Also, I tested gfx.webrender.allow-partial-present-buffer-age and gfx.webrender.max-partial-present-rects with EGL enabled as well.
Comment 26•3 years ago
|
||
Can you still reproduce this bug if you start Nightly with __GL_MaxFramesAllowed=1 environment variable?
$ __GL_MaxFramesAllowed=1 ./firefox
Please try with EGL (default) and with gfx.x11-egl.force-disabled=true (Firefox restart required to apply pref change).
Does __GL_SYNC_TO_VBLANK=0
help?
Reporter | ||
Comment 27•3 years ago
|
||
(In reply to Darkspirit from comment #26)
Can you still reproduce this bug if you start Nightly with __GL_MaxFramesAllowed=1 environment variable?
$ __GL_MaxFramesAllowed=1 ./firefox
Please try with EGL (default) and with gfx.x11-egl.force-disabled=true (Firefox restart required to apply pref change).
__GL_MaxFramesAllowed=1 has no effect, with or without EGL.
Does
__GL_SYNC_TO_VBLANK=0
help?
__GL_SYNC_TO_VBLANK=0 has no effect without EGL. With EGL, it seems partially better, but not completely fixed. It looks like the browser randomly alternates between the normal and reduced frame rates when scrolling, which appears as jittery animation. Sometimes it may look like normal for several seconds but then, presumably after a random CPU spike, the frame rate may drop.
Comment 28•3 years ago
|
||
https://download.nvidia.com/XFree86/Linux-x86_64/410.66/README/openglenvvariables.html
By default, the driver calls sched_yield() to do this. However, this can cause the calling process to be scheduled out for a relatively long period of time if there are other, same-priority processes competing for time on the CPU. One example of this is when an OpenGL-based composite manager is moving and repainting a window and the X server is trying to update the window as it moves, which are both CPU-intensive operations.
Does one of these environment variables make a difference?
__GL_YIELD="NOTHING"
__GL_YIELD="USLEEP"
Reporter | ||
Comment 29•3 years ago
|
||
(In reply to Darkspirit from comment #28)
Does one of these environment variables make a difference?
__GL_YIELD="NOTHING"
__GL_YIELD="USLEEP"
__GL_YIELD="USLEEP" is set globally on my system, all previous testing was done with it.
Unsetting __GL_YIELD has no effect. Setting it to nothing does not fix the scrolling (it is consistently bad), but considerably increases CPU consumption. Both with and without EGL.
I also tried setting __GL_SYNC_DISPLAY_DEVICE to the display on which FF was opened, it had no effect.
Reporter | ||
Comment 30•3 years ago
|
||
(In reply to andysem from comment #29)
(In reply to Darkspirit from comment #28)
Does one of these environment variables make a difference?
__GL_YIELD="NOTHING"
__GL_YIELD="USLEEP"
__GL_YIELD="USLEEP" is set globally on my system, all previous testing was done with it.
Unsetting __GL_YIELD has no effect. Setting it to nothing
I mean "NOTHING", all caps.
does not fix the scrolling (it is consistently bad), but considerably increases CPU consumption. Both with and without EGL.
I also tried setting __GL_SYNC_DISPLAY_DEVICE to the display on which FF was opened, it had no effect.
Description
•