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

Programatically disabling hardware encoding/decoding in WebRTC #728

Closed
fippo opened this issue Jan 11, 2023 · 15 comments
Closed

Programatically disabling hardware encoding/decoding in WebRTC #728

fippo opened this issue Jan 11, 2023 · 15 comments
Assignees

Comments

@fippo
Copy link

fippo commented Jan 11, 2023

Request for Mozilla Position on an Emerging Web Specification

Other information

See also w3c/webrtc-extensions#98, spec PR was in w3c/webrtc-extensions#128

@ekr
Copy link
Contributor

ekr commented Jan 11, 2023

I certainly understand why one would want to disable hardware encoding, but I'm skeptical that the right API answer is to have the JS do it rather than the browser. This seems like it is sure to create situations where the JS is turning off the HW encoder long after it would be fine to have it on because whatever bug it is trying to work around has been fixed.

@fippo
Copy link
Author

fippo commented Jan 11, 2023

That is indeed a risk and the usage of such an API should be closely monitored since prolonged use suggests there is an underlying bug that needs to be fixed. See slide 68+ from TPAC.

I do hope that in general hardware acceleration is desirable enough that folks won't blindly disable it.

Browser release cycles make it hard to react quickly. If you look at this Chrome issue you can imagine what two weeks of basically complete breakage mean for a product.

@ekr
Copy link
Contributor

ekr commented Jan 11, 2023

It seems to me the fix there is for browsers not to introduce that kind of bustage.

@fippo
Copy link
Author

fippo commented Jan 11, 2023

See my list-of-doom which shows we are not winning that battle. Sadly CI doesn't help much since this often boils down to a combination of hardware and driver versions.

@ekr
Copy link
Contributor

ekr commented Jan 11, 2023

Browsers are perfectly free to disable hardware encoding entirely.

@fippo
Copy link
Author

fippo commented Jan 11, 2023

True but that will make users use a different browser. Also hey, this used to be one of @jesup's favorite topics!

@fabricedesre
Copy link

As someone working with various chipset vendors, I agree with @ekr that this kind of api should not be exposed to web content. It is usually set on a per-chipset basis (either through configuration or some autodetection mechanism) and there is not really a meaningful choice to make at the content or end user level.

@nils-ohlmeier
Copy link

I believe the topic of hardware acceleration boils down to maintaining big white and black lists of chipset, firmware, driver combinations.
Neither have the services access to all of this through JS to maintain such lists. Nor do the browser vendors, to the best of my knowledge, have the resources in their CI systems to regularly check all the possible combinations and maintain good lists.

I can fully understand that a service would want to have the option to turn off all hardware acceleration to avoid having their support spending endless time trying to figure out what is causing issues.
But I'm not convinced that doing this on a per sender/receiver level is right level of granularity for that.

@HuaChunbo
Copy link

My concern is that this kind of high level JS API will hide the benefits and also potential issues of hw codecs deep inside WebRTC. Currently browsers have workaround list or blacklist to do the hardware/drivers info based detection and avoidance.

@slightlyoff
Copy link

Presumably there will still be enough traffic to HW-accelerated content to find hw/driver issues; a toggle like this makes good sense to me in the interest of keeping services working while those sorts of concerns can be worked out, particularly given the long lead times for some vendors in delivering driver fixes.

@fippo
Copy link
Author

fippo commented Jan 19, 2023

@nils-ohlmeier this is a static method so not per-sender (mostly in order not to create another bit of information by comparing the available codecs with/without HW directly) but equivalent in scope to the currently available chrome://flags for disabling HW which do allow the user to unbust their device (@fabricedesre this is the kind of choice a user can make, possibly guided by a support team)
Using this API in a service-wide manner "disable HW on all cards from this particular vendor" is possible (with methods for detecting the vendor outside the scope of WebRTC) but much less fine-grained than solving the issue(s) with the more detailed information that is not available to JS.

@ekr WebCodecs allows a much more fine-grained control already here. WebRTC has traditionally been much more "highlevel" as an API (as you know).
The status quo in Chromium is CBP not being accelerated and other hw-accelerated profiles emitting a ton of keyframes and/or tens of keyframes during the ramp-up (and I am quite surprised that no bugs have been filed about that).
That is (just like disabling HW by default as done in Firefox) not an ideal state I would like to get out of but it needs to be done in a manner that does allow a service to run A/B experiments guiding the changes in the wild. Browser-wide metrics have proven unsuitable for this kind of things.

@ekr
Copy link
Contributor

ekr commented Jan 19, 2023

@fippo I understand what you are trying to achieve, but I believe the ecosystem effects of allowing sites to turn off acceleration will be quite bad and lead to excessive disablement. In particular, I think it's quite likely that they will create a differentially negative impact on smaller browsers because sites will have less incentive to re-test and re-enable hardware. Therefore, I am not in favor of this.

@fippo
Copy link
Author

fippo commented Jan 24, 2023

@ekr: will note Mozilla as "not in favor".

Please note that other ways to resolve this such as origin trials (or reverse origin trials) are even more unfair towards smaller browsers.

@zcorpan zcorpan changed the title Request for Position: programatically disabling hardware encoding/decoding in WebRTC Programatically disabling hardware encoding/decoding in WebRTC Oct 18, 2024
@zcorpan zcorpan moved this from Unscreened to Needs assignees in standards-positions review Oct 18, 2024
@zcorpan zcorpan moved this from Needs assignees to Needs proposed position in standards-positions review Oct 21, 2024
@jan-ivar
Copy link
Member

jan-ivar commented Oct 21, 2024

The Media team might be OK to move forward with a slightly different surface that links to https://w3c.github.io/webcodecs/#hardware-acceleration (which has a page-long note about when the UA might override webpage preference).

partial interface RTCRtpReceiver {
  HardwareAcceleration hardwareAcceleration = "no-preference";  
}

We think this would resolve some of the concerns raised above, specifically the UAs ability to override website preference in situations like after a hardware codec fix.

Would this work for everyone? With such an API I think we would be able to propose a positive position.

@jan-ivar
Copy link
Member

I've filed w3c/webrtc-extensions#229 to propose the API above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Position is proposed
Development

No branches or pull requests

9 participants