WesselKroos / youtube-ambilight

This browser extension adds ambient light to YouTube videos
MIT License
78 stars 8 forks source link

Performance regression in Firefox version 123 & 124 #224

Closed Askejm closed 2 months ago

Askejm commented 4 months ago

Troubleshooter First try all the checks and steps in the troubleshooter: https://github.com/WesselKroos/youtube-ambilight/blob/master/TROUBLESHOOT.md

  1. Did it solve your performance problems? yes/no No
  2. What steps made it worse/better: The lower quality settings helped somewhat, although i still get around 15-20fps

Describe the performance you are currently experiencing

  1. Low performance on 4K, 50% res scaling. It only happens in Firefox as of lately. No problems in Chrome.

Device information

  1. Name of your CPU: 5800X3D
  2. Name of your GPU: 3090
  3. Name of the browser: Firefox
  4. Version of the browser: 123.0

Screenshots

  1. Add a screenshot of the Task manager with the CPU and GPU usage charts image Taskmgr_TCARmNszsQ Taskmgr_jeGHXaDNKs
  2. Turn on the Ambient light setting Quality > Show framerate and make a screenshot of your framerates firefox_Z4tWMxsTg5 Describe the performance you would be happy with
  3. At least 30fps on 4k. I prefer the higher bitrate of 4k, but find the delay between scenes quite jarring. I know i can enable the fade duration, but would prefer not to

Describe any workaround you've tried so far

  1. Fade duration and lower quality settings. They both mitigate it somewhat but is not something i am satisfied with.

Additional context Add any other context or screenshots about the feature request here.

  1. It only started happening a little bit ago. I am unsure if it's an automatic update, but I did recently update my driver which may have caused some issues with this plugin.
WesselKroos commented 4 months ago

Hi @Askejm, let's try to figure out what caused the sudden drop in performance. I'm on a Nvidia 2070 Super, so I might be able to reproduce your issue. Some follow up questions:

  1. Since it happens only on Firefox, Do you think it could have happend because of a Firefox update?

  2. Which Nvidia driver version are you currently on? And were you on?

  3. Could you try to see if reverting to the previous NVidia driver does indeed fix the problem? Or using the previous Firefox version?

Askejm commented 4 months ago

Thanks for the quick response @WesselKroos

  1. Well I'm honestly not sure, but 123.0 released almost 2 weeks ago (20/02/2024). I feel like it has been an issue for shorter
  2. I am on 551.61 (22/02/2024) but I can't find which I was on
  3. Tried downloading 537.58 (10/10/2023) and its the same rn, around 10 fps on 4k
WesselKroos commented 4 months ago

It looks like you've found a Firefox version 123 bug. I hit the same framerate ~12 fps limit for a 4K video in Firefox. But after downgrading to Firefox 122 I was able to get 60fps.

I don't have a workaround for you at this moment. But I'll report this performance regression to the Firefox developers. Let's hope we can find a workaround for Firefox 123 in the mean time.

Running Firefox versions 122 and 123 side-by-side:

image

image

Askejm commented 4 months ago

Oh thats odd. Well ill downgrade then, thanks!

WesselKroos commented 4 months ago

The bug has been reported to the Firefox developers: https://bugzilla.mozilla.org/show_bug.cgi?id=1883225

WesselKroos commented 4 months ago

@Askejm I think I found a workaround. Could you verify that executing this javascript code on the /watch page fixes the bug in Firefox 123? (Tip: You can install Firefox 122 and 123 in separate locations to run them side-by-side)

ambientlight.enableMozillaBugReadPixelsWorkaround = false

Because it looks like they have fixed bug 1719154 while introducing bug 1883225

Askejm commented 4 months ago

@WesselKroos Looks like that did it. image Still looks a little bumpy on the graph it appears, but it seems fine to me

Askejm commented 4 months ago

image Sorry, heres the full stats

WesselKroos commented 4 months ago

Then I'll turn off that workaround from Firefox 123. I'll also make the workaround available via an advanced setting. Just in case Firefox decides to revert their change in 124.

WesselKroos commented 3 months ago

The bug will be fixed in Firefox version 125

Askejm commented 3 months ago

Then I'll turn off that workaround from Firefox 123. I'll also make the workaround available via an advanced setting. Just in case Firefox decides to revert their change in 124.

Did you push this update? I still get bad fps without running the javascript. Version 2.38.1 @WesselKroos

WesselKroos commented 3 months ago

@Askejm Not yet, it will be released in 2.38.2.

WesselKroos commented 3 months ago

@WesselKroos Looks like that did it. image Still looks a little bumpy on the graph it appears, but it seems fine to me

Those are some large consistent spikes, more than 2x the normal duration.

My graph seems to be a lot smoother:

image

Even when Firefox's rendering process is a half display frame desynced from the video frame (this alternates every 5 seconds on my pc), the duration (drawtime) stays similar for every frame:

image

Could you share a recording of the Graphics process for 10 seconds? You can follow the steps in Firefox's profiler documentation to create one. Just select "Graphics" instead of "Firefox" in the popup: https://profiler.firefox.com/ image

Askejm commented 3 months ago

Dont know why but its a lot better now firefox_gcsKVAdil6

Firefox 2024-03-14 14.19 profile.json.gz

WesselKroos commented 3 months ago

Most of the stutters are just caused by changes on the webpage that the YouTube design has to recalculate things for.

For some you can reduce the duration. Because all 3 microstutters are partially caused by your Bitwarden extension. It is executing a getPageDetails and fulfilled function (for 95ms + 22ms) in intervals. And a CollectAutofillContentService/this.handleMutationObserverMutation function (for 37ms) when anything changes on the webpage. I can't see what html content it is checking (and I don't want to know), but the function names sounds like an auto-fill feature. Maybe you can turn this feature off in Bitwarden's extension settings. Or you could only disable the extension on the youtube.com domain.

Screenshots of the stutters (the red lines)

Stutter 1 image

Stutter 2 image

Stutter 3 image

Askejm commented 3 months ago

Oh thanks i didnt know autofill would take so much. Thanks for the help! And ill be waiting for firefox v125 or 2.38.2!

WesselKroos commented 2 months ago

@Askejm I noticed that Firefox released version 125. Can you confirm that Mozilla has fixed the bug?

Askejm commented 2 months ago

@WesselKroos Yes works all good now