Closed Bug 1275481 Opened 4 years ago Closed 4 years ago

Suspend background video decoders on timer

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: kamidphish, Assigned: kamidphish)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Use a timer to control the suspending of videos in backgrounds tabs so that quick tab away and back doesn't introduce a suspend-then-seek.
Assignee: nobody → dglastonbury
Status: NEW → ASSIGNED
Suspend decoding of video in background tabs once timer fires. The timer
is trigger on switch to invisible and reset each time becomes
visible. Default timer is set at 10 seconds and is controlled via pref
media.suspend-bkgnd-video.delay-ms.

Review commit: https://reviewboard.mozilla.org/r/56198/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/56198/
Attachment #8757787 - Flags: review?(cpearce)
Comment on attachment 8757787 [details]
MozReview Request: Bug 1275481: Suspend video decoding via timer. r?jwwang

I think JW is the best person to review MDSM code now.
Attachment #8757787 - Flags: review?(cpearce) → review?(jwwang)
Comment on attachment 8757787 [details]
MozReview Request: Bug 1275481: Suspend video decoding via timer. r?jwwang

https://reviewboard.mozilla.org/r/56198/#review53030

::: dom/media/MediaDecoderStateMachine.h:936
(Diff revision 1)
> +  // True if video decoding is suspended.
> +  bool mVideoDecodeSuspended;
> +
> +  // Track enabling video decode suspension via timer
> +  RefPtr<MediaTimer> mVideoDecodeSuspendTimer;
> +  MozPromiseRequestHolder<MediaTimerPromise> mVideoDecodeSuspendRequest;

DelayedScheduler should be easier to use.

::: dom/media/MediaDecoderStateMachine.cpp:205
(Diff revision 1)
>        "media.video-queue.send-to-compositor-size", VIDEO_QUEUE_SEND_TO_COMPOSITOR_SIZE);
>    }
>  }
>  
> +// Default delay of 10 seconds.
> +#define SUSPEND_BACKGROUND_VIDEO_DELAY_MS (10*1000)

Favor static const over macro.

::: dom/media/MediaDecoderStateMachine.cpp:211
(Diff revision 1)
> +
>  static bool sSuspendBackgroundVideos = true;
>  
> +// Delay, in milliseconds, that tabs needs to be in background before video
> +// decoding is suspended.
> +static uint32_t sSuspendBackgroundVideoTimerMS;

Use TimeDuration to save worries about confusion between ms and us.

::: dom/media/MediaDecoderStateMachine.cpp:223
(Diff revision 1)
>    static bool sSetupPrefCache = false;
>    if (!sSetupPrefCache) {
>      sSetupPrefCache = true;
>      Preferences::AddBoolVarCache(&sSuspendBackgroundVideos,
>                                   "media.suspend-bkgnd-video.enabled", false);
> +    sSuspendBackgroundVideoTimerMS = Preferences::GetUint(

We should use MediaPrefs whenever possible.
Attachment #8757787 - Flags: review?(jwwang)
Comment on attachment 8757787 [details]
MozReview Request: Bug 1275481: Suspend video decoding via timer. r?jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/56198/diff/1-2/
Attachment #8757787 - Attachment description: MozReview Request: Bug 1275481: Suspend video decoding via timer. r?cpearce → MozReview Request: Bug 1275481: Suspend video decoding via timer. r?jwwang
Attachment #8757787 - Flags: review?(jwwang)
Comment on attachment 8757787 [details]
MozReview Request: Bug 1275481: Suspend video decoding via timer. r?jwwang

https://reviewboard.mozilla.org/r/56198/#review53494
Attachment #8757787 - Flags: review?(jwwang) → review+
Pushed by dglastonbury@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3206ef153b98
Suspend video decoding via timer. r=jwwang
https://hg.mozilla.org/mozilla-central/rev/3206ef153b98
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Blocks: 1214710
You need to log in before you can comment on or make changes to this bug.