Open Bug 1794000 Opened 2 years ago Updated 2 years ago

Videos in background tabs should stop playing

Categories

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

defect

Tracking

()

People

(Reporter: florian, Unassigned)

References

(Blocks 2 open bugs)

Details

(Keywords: perf:resource-use, power)

When looking at our telemetry for thread wake-ups in background content processes, I see we have lots of wake-ups in the mediasupervisor, mediapdecoder, mediatimer, mediadecoderstatemachine and graphrunner threads.

I thought videos in background tabs were not being decoded, unless the video was playing sound (in which case the tab remains in the foreground priority) or had a muted audio track (in which case the priority was set to background-perceivable).

Until now we weren't sure if seeing these media thread wake-ups in background content processes were a bug of the telemetry (eg. not correctly setting the priority of the content process) or a media bug. Today I noticed that I can reproduce on cnn.com, so I'm thinking it's not a telemetry issue.

Here is a profile of the cnn.com content process while it is in the background: https://share.firefox.dev/3CDgV4S

And here is a profile when I switch the tab to the foreground for a little while: https://share.firefox.dev/3ym9Env

Investigating a bit showed that the page plays a small 4s video and it loops.

In #media padenot suggested we might be pausing decoding after 10s of non-visible playback. So maybe the fact that the video is shorter than 10s but looping is what's causing the issue here?

This seems related to the shutdown-decoder project (bug 1352007).

Didn't see it mentioned but bug 1224973 may be relevant.

Severity: -- → S3

I thought videos in background tabs were not being decoded, unless the video was playing sound (in which case the tab remains in the foreground priority) or had a muted audio track (in which case the priority was set to background-perceivable).

Video decoding is non-relevant with the audio. The problem is that we never fully implement the mechanism of shutting down video decoder. Before the engineer who mainly worked on this feature left Mozilla, the feature is still in the phase 1, which won't suspend all background videos, and these might affect us the most (especially for not-in-tree videos, but we don't have a telemetry to know ) I was planning to keep working on that before but didn't get a chance :(

In #media padenot suggested we might be pausing decoding after 10s of non-visible playback. So maybe the fact that the video is shorter than 10s but looping is what's causing the issue here?

Good point. Whenever the video is going to loop back to the start position, we will close the MDSM and clear the suspend timer so it seems that the video decoding for those short videos would never get shutdowned. I think the bug 1262276 will solve the issue of not being able to shutdown video decoding for those short looping video, and that bug is in my Q4 plan so we would see if that improves the situation or not.

See Also: → 1262276

I can confirm that after applying fixes in bug 1262276, it would stop video decoding for background/invisible looping videos which duration are shorter than 10s (our default threshold for shutting down video decoder) However, they would still be using many media supervisor threads actively, because there are still many tasks running for our state machine and the format reader, which is something we can further improve in the next step.

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