Firefox/Shutdown Decoders: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 141: Line 141:
* [https://bugzil.la/1295844 Bug 1295844 - Test suspended videos with webm files]
* [https://bugzil.la/1295844 Bug 1295844 - Test suspended videos with webm files]
** done
** done
 
== Logged bugs ( blocking [https://bugzilla.mozilla.org/show_bug.cgi?id= 1276556 ] ) ==
<bugzilla>
    {
        "blocks":[1276556],
        "include_fields": "id, priority, component, assigned_to, summary, status, target_milestone"
    }
</bugzilla>
 
=Team=
=Team=



Revision as of 16:14, 30 September 2016

Overview

Suspending video element's video decoder, when the video element is in background tabs or is invisible even in the foreground tab, is a Firefox feature that reduces CPU/GPU & memory usage.

The mechanism is that, when a video element is invisible, we replace its original video decoder with blank video decoder which only produces white frames with right resolution and right time information. The original video decoder is released and the black video decoder is light so that we reduce CPU/GPU & memory usage.

The drawback is that, while the suspended-video-element is switched back to be visible again, we should resume its original video decoder. The resuming operation must be asynchronous and might be time-consuming which depends on the resolution of the video file and whether it contains audio tracks or not.

In the prototype (Phase 0), we have enabled this feature on the Firefox Nightly channel for any video element. We also add telemetry to collect needed information, especially on the resuming time. Currently (Phase 1), we are going to enable this feature on the Firefox Release channel for videos that is able to be resumed quickly and the criteria is 1) videos without audio track or 2) videos with both audio and video tracks but with low resolution (480P for now). In the future (Phase 2), our goal is to enable this feature on all videos without observable latency while resuming.

The following is a step-by-step description of suspending decoder working flow.

  1. At the very beginning of the decoding framework, the raw media data is sent to demuxer.
  2. Demuxer helps to separate a combined signal, e.g., a streaming can be separated into audio data and video data by demuxer. After that, audio and video data are sent to audio and video decoder separately.
  3. In data decoding period, audio decoder keeps working as normal because a user may be listening to the music. But, Firefox uses a blank video decoder to replace current video decoder if the video element is invisible.

Fx Shutdown Decoder Architecture v2.png


Key Documents

Other Resources

Install

Stable Release

Stay tuned.

Developer Release

The developer release is updated each time code is committed to Mozilla-central in HG.

Reporting Issues

If you find a bug or have a suggestion, please submit it on Bugzilla: https://goo.gl/coRinl

Known Issues

Decoder resuming latency

While the suspended-video-element is switched back to be visible again, we should resume its original video decoder. The resuming operation must be asynchronous since we don't want to block the main thread and might be time-consuming which depends on the resolution of the video file and whether it contains audio tracks or not.

Currently, we have no way to boost the resuming time, however, we have telemetries for collecting the needed time of different resolutions on different platforms.


Related telemetries:

Related bugs:

Video element as content source

The situation is about the video element itself is used as a content source and its decoder might be suspended at the same time. This issue could be split into two cases:

  • Case 1: The decoder is suspended AFTER the {cpatureStream(), drawImage(), createImageBitmap()} is called.
  • Case 2: The decoder is suspended BEFORE the {cpatureStream(), drawImage(), createImageBitmap()} is called.

Case 1 is relatively easy, we could mark the video element as being a content source while {cpatureStream(), drawImage(), createImageBitmap()} is invoked and then its decoder should never be suspended.

Case 2 is rather complicated. The critical issue is that resuming decoder is an async operation with latency. So, while {cpatureStream(), drawImage(), createImageBitmap()} is invoked on an already-suspended-video, there must be several "blank" frames been leaked, even though we resume the decoder immediately. To completely solve this problem, we must make "resuming decoder" a blocking operation, however, it might block the main thread; otherwise, we leak the blank frames.


Related bugs:

Planning

Goals

  • Help users to reduce device resource usage (CPU & Memory)
  • Finish tasks across videos
  • No impact on current user flow

Feature Plan

  • Phase 0: Shutdown decoders when video element is invisible
  • Phase 1: Using a blank video decoder to replace video decoder instead of shutdown decoders directly. In this phase, the mechanism is applied to 1) Low-resolution video (480P) and 2) Video film without audio track
  • Phase 2: We're going to enhance the mechanism and make sure it can apply to all video files.

Success

  • Effective cross-discipline teams solving problems across platforms
  • Validation of key assumptions through telemetrics
  • video decode suspend in the hands of all our users

Schedule

Product Milestones

Engineering

Shutdown_Decoders [status: Green]

Current Goals:

  • Ship disabling video decoders for ads
  • Silent, looping videos where user doesn't really care the exact point

Next Milestone:


Milestones

Optimizations

Telemetry

Mochitests

Logged bugs ( blocking 1276556 )

Full Query
ID Priority Component Assigned to Summary Status Target milestone
1224973 P2 Audio/Video: Playback u480271 Reduced decoder usage for background videos RESOLVED mozilla49
1272919 P3 Audio/Video: Playback u480271 Video shows the frame that was on screen when I switched from youtube to a different tab for a fraction of a second VERIFIED ---
1274626 P3 Audio/Video: Playback Tzuhao Kuo [:kaku] video fasts forwards when it was sitting in a background tab VERIFIED mozilla51
1275481 P2 Audio/Video: Playback u480271 Suspend background video decoders on timer RESOLVED mozilla49
1275538 P1 Audio/Video: Playback Jean-Yves Avenard [:jya] Crash in mozilla::MediaFormatReader::RequestVideoData RESOLVED mozilla49
1276495 P1 Audio/Video: Playback u480271 Crash in mozilla::MediaFormatReader::RequestAudioData RESOLVED mozilla49
1282710 P2 Audio/Video: Playback Tzuhao Kuo [:kaku] Suspend and resume foreground video decoders according to visibility events. RESOLVED mozilla50
1284177 P3 Audio/Video: Playback u480271 Add tests for video suspend in background RESOLVED mozilla51
1285419 P3 Audio/Video: Playback Gerald Squelart (he/him) (not at Mozilla since 2022-09-15) Telemetry to support background video decoder suspend: Hidden play time RESOLVED mozilla50
1286875 P3 Audio/Video: Playback Firefox Nightly play/pause on Youtube creates syncronization issue between video and audio RESOLVED ---
1287987 -- Audio/Video: Playback Gerald Squelart (he/him) (not at Mozilla since 2022-09-15) Telemetry to support background video decoder suspend: Percentage hidden/total play time, keyed by audio presence and height ranges RESOLVED mozilla50
1289668 -- Audio/Video: Playback Gerald Squelart (he/him) (not at Mozilla since 2022-09-15) Telemetry to support background video decoder suspend: Inter-keyframe timings RESOLVED mozilla50
1293145 -- Audio/Video: Playback Gerald Squelart (he/him) (not at Mozilla since 2022-09-15) Telemetry to support background video decoder suspend: Percentage video-decode-suspended/total play time RESOLVED mozilla51
1294345 P3 Audio/Video: Playback JW Wang [:jwwang] [:jw_wang] Remove the TrackSet parameter from MediaDecoderStateMachine::InitiateDecodeRecoverySeek() RESOLVED mozilla51
1294349 -- Audio/Video: Playback Gerald Squelart (he/him) (not at Mozilla since 2022-09-15) Telemetry to support background video decoder suspend: Recovery time from video-decode-suspended RESOLVED mozilla51
1294352 P3 Audio/Video: Playback JW Wang [:jwwang] [:jw_wang] Merge MDSM::InitiateSeek() and MDSM::InitiateDecodeRecoverySeek() RESOLVED mozilla51
1294358 P3 Audio/Video: Playback u480271 Add test for suspended videos still fire 'ended' event RESOLVED mozilla51
1295844 P3 Audio/Video: Playback u480271 Test suspended videos with webm files. RESOLVED mozilla51
1299065 -- Audio/Video: Playback Tzuhao Kuo [:kaku] Telemetry to support background video decoder suspend: invisible elements in the foreground should also be recorded RESOLVED mozilla51
1299718 P3 Audio/Video: Playback u480271 Telemetry to support background video decoder suspend: the usage of a hidden video element as a content source RESOLVED mozilla51
1301059 P3 Audio/Video: Playback Jean-Yves Avenard [:jya] When suspending decode, the BlankDecoder shouldn't be wrapped in a H264Converter RESOLVED mozilla51
1301061 P3 Audio/Video: Playback Background video decode will cause issue when use with EME RESOLVED ---
1305338 P1 Audio/Video: Playback Mark Liang(:mark_liang) [UX] UX Spec for Shutdown Decoder Phase 1 RESOLVED ---
1306551 P5 Audio/Video: Playback JW Wang [:jwwang] [:jw_wang] Intermittent dom/media/test/test_background_video_suspend.html | Assertion count 115 is greater than expected range 0-0 assertions from "ASSERTION: Clock should go forwards" RESOLVED mozilla52
1309492 P3 Audio/Video: Playback Tzuhao Kuo [:kaku] If a video element's video is suspended, make it draw black frames. RESOLVED ---
1309494 P3 Audio/Video: Playback Tzuhao Kuo [:kaku] Use spinning loading UI if resuming video element's video decoder is longer than 250ms. RESOLVED mozilla55
1310140 P3 Audio/Video: Playback JW Wang [:jwwang] [:jw_wang] Reconcile suspend-video-decoder with the states of MDSM RESOLVED mozilla52
1313955 P3 Audio/Video: Playback u480271 Paused videos in background tabs change time position slightly when the tab is selected VERIFIED mozilla52
1346120 -- Audio/Video: Playback Tzuhao Kuo [:kaku] If a video element's video is suspended, keep the last decoded video frame on the screen RESOLVED mozilla55

29 Total; 0 Open (0%); 26 Resolved (89.66%); 3 Verified (10.34%);


Team

Product owner:

Eng: Alastor, Daniel, Gerald, JW, Kaku,

Program Management: Blake, Josh

UX: Mark, Morpheus

QA: SoftVision and William

Communications

IRC:

Email:

VidyoRoom: