Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable idle/background throttling when using a CanvasCaptureMediaStream #244

Open
aarongustafson opened this issue Dec 7, 2020 · 4 comments
Assignees
Labels
triaged-awaiting-response want Incoming requests from the community

Comments

@aarongustafson
Copy link
Member


title: Disable idle/background throttling when using a CanvasCaptureMediaStream
date: 2020-12-07T23:11:10.731Z
submitter: PRIVATE
number: 5fceb68edacc4423defb920a
tags: [ ]
discussion: https://github.com/WebWeWant/webwewant.fyi/discussions/
status: [ discussing || in-progress || complete ]
related:

  • title:
    url:
    type: [ article || explainer || draft || spec || note || discussion ]

Today, it's easily possible to build full live video mixers using existing APIs such as the CanvasCaptureMediaStream. However, the capability is crippled by the browser attempting to optimize canvas drawing and requestAnimationFrame timers. If the tab/window is backgrounded, drawing to the canvas stops and timers only run once per second. This happens in all common user agents.

When a canvas is being captured, all of this throttling should be disabled.

If necessary, perhaps a permission/request can be made, similar to WakeLock.

The only workaround for this today is to use pop-up windows for the UI. However, this has been proven to be less reliable, as browsers are starting to implement optimizations when the window is covered but not minimized. Additionally, if the user minimizes the window, everything stops. This is preventing the deployment of several video-related applications.

Brad Isbell
[email protected]


If posted, this will appear at https://webwewant.fyi/wants/5fceb68edacc4423defb920a/

@aarongustafson aarongustafson added the want Incoming requests from the community label Dec 7, 2020
@aarongustafson aarongustafson self-assigned this Dec 7, 2020
@guest271314
Copy link
Contributor

This is primarily a Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=1100746#c32, which has been fixed to an appreciable degree https://bugs.chromium.org/p/chromium/issues/detail?id=1145203. This is the specification issue re mute and unmute events being fired w3c/mediacapture-screen-share#141, test stephenlindauer/MediaRecorder-shareTab-issue#1, we do not lose any audio or video when recording at the same time the window where capture is occurring does not have focus. We can manually adjust how many frames are captured using frameRate constraint, when we want more frame per secod or an exact amount of frames for other use cases https://github.com/guest271314/screenshot.

@guest271314
Copy link
Contributor

Some tests for

If the tab/window is backgrounded, drawing to the canvas stops and timers only run once per second. This happens in all common user agents.

Am interested in the results when the tab or window is not focused (note, flags or preferences can also impact media playback and capture, e.g., --disable-gesture-requirement-for-media-playback; --autoplay-policy=no-user-gesture-required).

@aarongustafson aarongustafson removed their assignment Mar 31, 2021
@WebWeWant WebWeWant deleted a comment from bradisbell Apr 6, 2021
@gregwhitworth
Copy link
Contributor

Hey @guest271314 while this is a valid ask but is leading with a solution. It would be good to simply provide the usecases rather than a solution itself as certain areas this won't be possible or the way in which we'd be able to unlock the solution.

@guest271314
Copy link
Contributor

It would be good to simply provide the usecase

If you read the Chromium bug linked in this issue and speification issue you will see my use case.

Which is how I encountered the bug: The specification does not state MediaStreamTrack should or must be muted when no user activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged-awaiting-response want Incoming requests from the community
Projects
None yet
Development

No branches or pull requests

3 participants