Memory leak on twitch VOD playback with "Block Audio & Video" autoplay policy enabled
Categories
(Core :: Audio/Video, defect, P2)
Tracking
()
People
(Reporter: bug.shivering279, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
System information:
- Firefox Version: 151.0.2
- Build ID: 20260527091838
- User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0
- OS: Linux 7.0.10-201.fc44.x86_64
Prerequisite for reproduction: Enable "Block Audio & Video" for Autoplay permission under Settings -> Privacy & Security -> Permissions -> Autoplay
Reproduction steps
The reproduction can be done from any video (specifically not livestream!) playback on twitch. Hence from my testing there's at least two reproduction paths. To start off either
- Navigate to a twitch channel that is currently OFFLINE (e.g. https://twitch.tv/nihmune)
- Navigate to a direct VOD (i.e. twitch.tv/videos/{vod_id}; Example: https://www.twitch.tv/videos/2787532718 – retrieved 4th June 2026)
After navigating to one such page:
- Do NOT interact with the page, so the autoplay block stays in effect.
- Open Firefox's Process Manager (about:processes) and watch the tab's memory grow & the CPU usage spike.
Important notes:
- If playback of the video has started, the leak will not happen! Hence in that case, reload the page and ensure that the video does not start playing.
- Reproduction Path 1 requires that the channel either has a channel trailer or recently streamed, so a video is displayed in the top center when navigating onto the page, therefore path 2 is likely a more stable reproduction, but:
- For path 2 beware that twitch deletes VODs after 60-90 days (so the example URL I gave may no longer be valid when you read this). In that case you may retrieve any VOD by navigating to any active twitch channel's "Videos" tab.
Actual results
The tab's memory climbs by roughly 1 GB every 2–3 seconds and never stops. CPU for that tab is pinned at its limit. On a 32 GB machine the memory grew until it nearly OOM'd the system. The growth can be stopped in one of the following ways:
- The video is started manually by the user
- The page receives any user interaction that clears the autoplay block (a single click on the canvas should suffice, or navigating to a subroute such as the channel's "Videos" tab).
- The tab is manually killed or unloaded
Clearly the leak is correlated to the blocked-but-attempted playback of the video and ends the moment that playback is allowed to start. Once the playback has been started, the consumed memory will slowly be freed again.
As a side note: A similar conflict between the autoplay block policy and twitch's video player can be observed from any twitch livestream: Playback briefly starts (a few frames) every few seconds then stops, also visible as the play/pause button toggling. No memory leak can observed here though.
Expected results
While the video stays blocked with the aforementioned autoplay policy, the tab's memory should not grow unbounded (or at all) & CPU usage should not spike to the limit.
Comment 2•5 months ago
|
||
Thanks for the exceptionally detailed report — the two reproduction paths and the key observation that the growth stops the moment playback is allowed to start make the trigger very clear.
Analysis
This is a conflict between the "Block Audio & Video" autoplay policy and Twitch's VOD player: while the element is blocked-but-attempting playback, the page repeatedly retries playback and memory grows without ever reaching a steady playing state where buffers are freed — stopping the instant playback is permitted.
We went through your attached about:memory report. The leaking tab is ~11.6 GB resident / ~10.2 GB heap-allocated, but almost all of it is unclassified native heap: the MSE source buffers (~19 MB), decoded image surfaces (~14 MB), and the JS heap (~330 MB) together account for under 4% of it. So the growth is not the usual MSE / JS / decoded-frame pools — it's a lower-level allocation the memory reporters don't attribute. A strong candidate is hardware video-decoder surfaces/textures that aren't released while playback is blocked-but-repeatedly-retried, which would also explain why this may not reproduce on every GPU/driver/OS.
Next Steps
To test that directly, could you re-run the exact repro with hardware video decoding disabled?
- In
about:config, setmedia.hardware-video-decoding.enabledto false. - Fully quit and restart Firefox (the change only takes effect on a fresh start).
- Reproduce as before — "Block Audio & Video" on, open the Twitch VOD, do not interact — and watch the tab's memory in about:processes.
Please report whether the unbounded growth still happens with HW decoding off: if it stops, the leak is in the hardware-decode path; if it persists, we can rule that out.
Two more quick things that would help:
- Does it also leak with the default "Block Audio" setting (Autoplay = "Block Audio", rather than "Block Audio & Video")? That tells us whether it's specific to blocking video too.
- If it's easy, a media-preset profile captured during the leak: open
about:logging-> Logging presets -> "Media playback", set Logging output to "Logging to the Firefox Profiler", click Start Logging, reproduce from a fresh page load (do not interact so the block stays in effect), click Stop Logging, then Upload Local Profile and paste the share URL here. The instruction video walks through it. If you have privacy concerns, email it to media-alerts@mozilla.com instead.
See also: bug 1837553 — a Linux (Mesa/Radeon) media memory leak with the same heap-unclassified signature, in the RDD (decode) process; quite possibly the same underlying hardware-decode issue. Also bug 1501982, another Twitch memory leak (triggered with the DevTools Media Panel open — a different precondition).
Setting S3/P2 and tracking under the autoplay meta.
- I can confirm that the leak can still be reproduced with
media.hardware-video-decoding.enabledset to false. - The "Block Audio" Autoplay setting does not trigger the leak, since the leak relies on the video not being allowed to start playing.
I have attempted to do the logging via about:logging with the "Media Playback" preset and logging to the firefox profiler.
As a heads up about the results of the logging though: When I ran the logging, the Twitch tab crashed before any significant amount of memory was leaking, so I am not sure how helpful the report will be. Please let me know if I should retry with different settings.
You can find the report here: https://share.firefox.dev/3RPRxDc
I have also submitted the corresponding crash report which has the Report ID bp-cd32ee5f-f4a2-4ba0-9fbb-7bba30260605 – if that helps as well.
| Comment hidden (off-topic) |
Description
•