Open Bug 1403823 Opened 8 years ago Updated 2 years ago

High CPU on twitch TV stream

Categories

(Core :: Audio/Video: Playback, defect, P3)

57 Branch
x86
Windows 10
defect

Tracking

()

Performance Impact low
Tracking Status
platform-rel --- ?

People

(Reporter: karlcow, Unassigned)

References

()

Details

(Keywords: perf:resource-use, Whiteboard: [platform-rel-Twitch])

Attachments

(1 file)

This is a spin-off of https://webcompat.com/issues/10343 Content of the issue. Description: Extreme memory leaks while watching a busy stream Steps to Reproduce: While watching a busy stream on Twitch.tv, I noticed that Firefox starts to use a lot of memory after a few minutes, ranging from 200MB (initially) to even 600MB~650MB tops. This doesn't happen on Chrome, where the memory usage ranges between 250MB~350MB tops. The CPU usage is also higher in comparison (10~13% on Firefox vs 5%~10% on Chrome). Steps to reproduce: Open Twitch.tv (https://www.twitch.tv) Go to a famous stream with a lot of viewers (a busy chat seems to exacerbate this problem) Watch it for some minutes while also interacting with the page a little bit, like going from top to bottom to spawn the "mini video po-up" or going in and out of theather mode Is this a memory leak problem? I didn't find any bug on bugzilla related to this issue. Note: this happens both on v55 (stable) and v57 (beta).
I can reproduce this issue, High CPU and memory usage, CPU usage became even higher when disable Hardware acceleration. Firefox 57 (beta), Windows 10(1703)
Component: General → Audio/Video: Playback
Product: Firefox → Core
Saw comments like "high cpu on twitch" issue mentioned on a few reddit threads which lead me to this bug. Twitch does seem to use more CPU on my machine for playback than say youtube (55-65% vs 25-35%). Captured a profile as well if that helps: https://perfht.ml/2zH52sM
Some interesting behaviors: Pause the stream - no change in CPU utilization If twitch tab is foreground > 65% If twitch tab is background drops to 2-4% This is with Firefox 57 OSX foreground application. Data from Activity Monitor.
Whiteboard: [perf:p1]
Another update: If you use GEAR icon and turn of chat CPU usage drops to nothing (with video stream paused). We will need to investigate how they implement their chat service.
Another update: Windows machine - i7 4770k @4.8Ghz On Windows desktop Firefox I see a burst of CPU usage than maybe 10% steady state with 23% GPU usage On Windows Chrome I don't see a burst of CPU usage - just steady state 8% CPU and 23% GPU OSX machine MBP 2016 15" @2.9Ghz CHROME OSX - with chat and video - two main processes are 22% and 11% pause video with chat 18% and 5% pause video disable chat 2% and 0% Firefox OSX - with chat and video - 75% 8% 7% pause video with chat on 40% 7% 5% pause video disable chat - 8% 8% 5% Would mark as OSX only but was already marked as Windows 10. Can anyone confirm this is an issue on windows?
Firefox 58b4 32-bit: As high as 65% while loading, but then it sits in the 30s to Low 40s. If I type(Spaming keys), it can climb up to upper 40% it even hit 60%s(rare and wasn't reproduceable, it was able to replicate to the 50s). The climb in % I replicate by spamming keys, or even holding Backspace. Man, just holding the "Backspace" key and the CPU was constantly in the upper 40s. Video paused 7 - 20, random flunctuations. Spamming keys and holding delete can raise it to 40, and upper 10s as long as I hold Backspace. Video paused and chat disabled is lowest 5% and can climb to higher 10s at random times. It wasn't as bad on the key input in their Legacy version, but it is over with, now. Well, the Legacy version was also problematic a long time ago and it got fixed I guess. I opened a problem with the "key input" problem in another Bugzilla ticket for the streaming site Smashcast but it was solved by the Smashcast dev, I had to nag both Bugzilla and their team for a long time about it. Also, I don't know why Microsoft still has the AMD drivers from November 2016, but with those, the CPU usage while watching Twitch was in the high 40s capping at the 90s, but 17.2 version of the AMD drivers lowered it down, the driver thing affected even Chromium browsers but they were still in the 30's and capping in the 60s max. SRWare Iron 62.0.3250.0 32-bit: 62% on loading upper 10%s averaging in the 20%s and rarely hitting 30% While spaming the keys it is in the upper 20s, sometimes but rarely hitting 30%, 40% one time. Video paused 5 - 7, mostly just in 6, rarely 10(upper and lower) with one time hit 19% Spamming keys upper 10s and rare times in the 20s, one time it jumped to 40% Video paused with chat disabled 2% - 6% A6-6310 laptop (4 cores 1.8Ghz, with 2.4Ghz if only using one core), 4 Gigs of RAM. Windows 10 64-bit.
Whiteboard: [perf:p1] → [qf:p1]
Checking this issue in also, high cpu ~40% for Nightly and Nightly CP Web Content when watching Twitch streams. Memory at 700mb/650mb respectively. v59.0a1 OSX 10.13.1 2016 MBP 13 Non-TB
Whiteboard: [qf:p1] → [qf:i60][qf:p1]
Whiteboard: [qf:i60][qf:p1] → [qf:f60][qf:p1]
Could a developer answer a quick question. Why does Gecko need 3 instances/threads of msmpeg2vdec.dll running? All 3 will take 5.5%+ CPU each on top of the other overhead. Other media players and browsers only use 1 instance of this dll including Chrome and MSEdge. I decided to open a Twitch stream and play 1080p60 in all three. MS uses the least at about 5%. Chrome is the runner up but not much more than that 6-8%. Microsoft's built in media players will play at near zero CPU suggesting that they can tap into the hardware decoder. I tested and saw the same issue with YouTube.com live streams. I suspect that the software/hardware decoding of Firefox is broken some how.
Jean-Yves, would you have any ideas about comment #8 and if there's anything to follow up on there? Thanks!
Flags: needinfo?(jyavenard)
platform-rel: --- → ?
Whiteboard: [qf:f60][qf:p1] → [qf:f60][qf:p1][platform-rel-Twitch]
See Also: → 1416554
Whiteboard: [qf:f60][qf:p1][platform-rel-Twitch] → [qf:f61][qf:p1][platform-rel-Twitch]
Even on non-busy streams (less than 10 viewers), on Windows 7 x64 HP, my Core i7 950 sees ~15-20% usage on Twitch.tv. But only when ACTIVELY watch a stream. If you tab away, CPU usage is reduced 2-3%. I use FrankerFaceZ and uBlock Origin with Twitch.
Whiteboard: [qf:f61][qf:p1][platform-rel-Twitch] → [qf:f64][qf:p1][platform-rel-Twitch]
Whiteboard: [qf:f64][qf:p1][platform-rel-Twitch] → [qf:p1:f64][platform-rel-Twitch]
I can confirm this issue with Firefox 60.0.2 on an Ubuntu 18.04. My CPU (Intel i5 7200U) has an average load of around 97% on all 4 cores, when watching a twitch stream in foreground.
could you guys check again with today's nightly? thank you
Flags: needinfo?(jyavenard)
No changes for me, sadly, with 63.0a1 (2018-07-12) (64-Bit)
this only happens when webrender enabled.
1.Go to your favorite streamer. 2.Check the channel description, is the Leaderboard panel extension installed? 3.Block this extension with AdBlock or uBlock origin. In Google Chrome, the CPU load is only when you see this extension, in the Firefox the load is always.
Whiteboard: [qf:p1:f64][platform-rel-Twitch] → [qf:p3:resource][platform-rel-Twitch]

A reddit user bumped into this issue recently:
https://bugzilla.mozilla.org/show_bug.cgi?id=1403823

On the reference laptop I'm not see evidence of a leak but certainly the CPU usage is consistently high.
~35-45% with three tabs streaming twitch.

I've to add an information about the bug occurence on my end.
I disconnected and uninstalled the Linux DisplayLink drivers on my machine, since they are causing a bunch of other problems and it seems that the performance issues are gone now.

(In reply to WhatsUpDoc? from comment #16)

1.Go to your favorite streamer.
2.Check the channel description, is the Leaderboard panel extension
installed?
3.Block this extension with AdBlock or uBlock origin.

In Google Chrome, the CPU load is only when you see this extension, in the
Firefox the load is always.

This instantly dropped the CPU usage for me. Thanks!

I'm having the same problem (even worse on playback of VODs).

Collapsing the chat helps a bit, but not always and it's still using a lot of RAM. The streamers I tested it with don't have the Leaderboard panel extension installed, so I can't try that.

Since Firefox 78, I get this problem again. Hovering between 10 and 20% usage on a Core i7 950 with Hardware Acceleration depending on the stream resolution. So, yeah.

It's a mirror of the comment I made on April 23, 2018 above.

I have Firefox 78.0.2 (64-Bit) and I just noticed the same problem. I had up to 40% of CPU usage coming from the Twitch tab (no matter if active or not). I have a Core i5-3350. I had the stream as a normal sized window with chat being visible. Hardware Acceleration was turned off.

The same issue occurs in the newest nightly I am on, which is 82.0a1 (2020-09-08) (64-bit). Web render is on and it buffers and freezes a lot. I am using an Intel i7 4790k, 32gb ram, and a GeForce GTX 770.

I am also experiencing this bug. I'm running Firefox 91.0 on macOS 11.5.1

I had a similar problem (not sure if the same) on Manjaro linux.

After digging a bit I found out that:

  1. After watching a video for a longer period of time it starts using 100% CPU and playback stops (audio still plays, but video is frozen).
  2. I analysed my netdata information and found out that high CPU usage starts the moment the CPU reaches 95 degrees, which is the value for thermal throttling for most CPUs.
  3. Reading this thread seems that most people experiencing high CPU usage are using either a laptop or MacOS. Both laptops and macs are known for having terrible cooling and often running hot.

Looking at that I think there is some weird interaction between Firefox and the thermal throttling process of the OS,
that causes FF to use much more resources when thermal throttling starts.

I am aware that when a CPU throttles down there is less power so a higher percentage is expected, but a jump from 10% to over 100% CPU is not normal. I would expect that even if my CPU drops from 2.4 GHz to 1.2GHz, then its usage would go up twice, not 10 times.

I suspect there might be a problem with racing for resources: if FF wont get something calculated fast enough it tries to do the calculation again, and again cannot get the answer in time, so it tries it again, etc. causing CPU usage to go mad.
Cannot confirm that though, that is something a FF developer would need to check.

I hope that will help pinpoint the source of the problems.

Performance Impact: --- → P3
Whiteboard: [qf:p3:resource][platform-rel-Twitch] → [platform-rel-Twitch]
Severity: normal → S3

The severity field for this bug is relatively low, S3. However, the bug has 3 duplicates.
:jimm, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jmathies)

The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.

Flags: needinfo?(jmathies)

(In reply to Release mgmt bot (nomail) [:suhaib / :marco/ :calixte] from comment #29)

The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.

yes this is old bug, if not fixed for a long time bugs tend to become the old ones.
I see this bug using 91.13.0esr (32bit) under windows 7

this is still an issue, and it keeps getting worse. on the same hardware, i used to be able to watch 2 streams consecutively without much trouble a year or two ago. now my fans get really loud with just 1 twitch stream open in firefox + the emote extension, but they're dead silent with 3 streams playing simultaneously in chrome - with chat, sound, and extensions on, and even a game in another window. it's clearly a firefox problem, and not hardware or twitch.

as per advice i've seen out there, i've tried tweaking codecs and hardware acceleration, and it has made no difference in performance.

i wonder if it's something that can be fixed even, or if it's just something the users will have to deal with.

(windows 10, firefox 116.0.3 (64-bit))

(In reply to dymorf from comment #31)

this is still an issue, and it keeps getting worse. on the same hardware, i used to be able to watch 2 streams consecutively without much trouble a year or two ago. now my fans get really loud with just 1 twitch stream open in firefox + the emote extension, but they're dead silent with 3 streams playing simultaneously in chrome - with chat, sound, and extensions on, and even a game in another window. it's clearly a firefox problem, and not hardware or twitch.

as per advice i've seen out there, i've tried tweaking codecs and hardware acceleration, and it has made no difference in performance.

i wonder if it's something that can be fixed even, or if it's just something the users will have to deal with.

(windows 10, firefox 116.0.3 (64-bit))

dymorf, can you file a separate bug and link to it from here? There's a lot of different reports and there could be different causes so it's easier to keep things separate. Please include the graphics section of about:support in the new bug.

Flags: needinfo?(dymorf)

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit BugBot documentation.

Flags: needinfo?(dymorf)

Looking at this, I think there's some weird interaction between Firefox and the OS's thermal throttling,
this causes ff to use much more resources when it starts thermal throttling. check it
https://www.twitch.tv/fixoyunnet

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: