Bug 234976

Summary: webkitRequestFullscreen fulfils but will not go into fullscreen with click handler that creates MediaStream and plays video
Product: WebKit Reporter: Will Morgan <will.morgan>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, jer.noble, mark.burrett, peng.liu6, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
fs.html testbed none

Description Will Morgan 2022-01-07 11:57:56 PST
Created attachment 448616 [details]
fs.html testbed

When I click a button that creates a MediaStream with getUserMedia, then plays a video that satisfies the autoplay criteria, then performs webkitRequestFullscreen (WRFS), the WRFS call return but no fullscreen resize event happens.

For compatibility with other browsers, especially with regard to anti-abuse and user activation, the advice is to first getUserMedia, then play a video, then finally requestFullscreen. This is because requestFullscreen clears user activation flags, which means that you can't getUserMedia afterwards.

This is the approach suggested here: https://github.com/whatwg/fullscreen/issues/152#issuecomment-494840412

My expected behaviour here would be for webkitRequestFullscreen to actually go into fullscreen, or at the very minimum if the WebKit team disagree with the WHATWG user activation approach, it should at least throw with a NotAllowedError.

This has downstream implications - sindresorhus's screenfull library returns a promise that never fulfils because WRFS doesn't throw and no change events happen. This effectively deadlocks any application that relies on entering fullscreen unless an arbitrary timeout is used.

I'm discussing the same issue with the team at Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=957558
Comment 1 Mark B 2022-01-10 00:24:17 PST
Is this issue common to macOS and iOS?
And is it new in Safari 15? Are all minor versions affected?
We would also appreciate feedback on whether the current behaviour is intended, and if so some guidance around avoiding the described deadlock.
If not, is a fix already in the pipeline?
Comment 2 Radar WebKit Bug Importer 2022-01-10 09:48:31 PST
<rdar://problem/87346180>