beforeunload
should fire for documents with active Media Capture
#10627
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
What problem are you trying to solve?
When user launches a website that was previously granted
microphone
and/orcamera
permissions, the Media Capture may begin immediately without further interactions from the user. An example would be a conferencing service that launches the conference page when user clicks on a link in an email or calendar or interacts with a Push Notification, and where user had opted in to skip the "waiting room" screen.After some time, the user may interact with the user agent. For example, user may launch a new tab with unrelated web content. Eventually user may decide to close the window to remove the unrelated content from their screen, but user may not realize that the conference call is open in another tab of the same window. Alternatively, user using macOS may close the browser from tray, without realizing they would also be closing PWA with the conference call.
Typically, the website would register
onbeforeunload
event handler in order to prevent accidental navigations from the page with an active Media Capture session. However, thebeforeunload
event would not display the prompt when the page doesn't have sticky activation [ref].This leads to user frustration – the website doesn't behave consistently from user's point of view, as the prompt is seemingly shown some times and not shown other times – and inconsistent user agent behavior for developers.
What solutions exist today?
There are no solutions for this issue. Website can't support "clickless" ("activationless") Media Capture, which is common in native apps, together with accidental navigation protection.
Workarounds include removing any features that rely on consistent
beforeunload
event behavior or removing support for "activationaless" Media Capture from web apps in order to provide consistent user experience.How would you solve it?
The steps to fire
beforeunload
should be amended to have an alternative condition indocument's relevant global object has sticky activation;
.Without question, "activationless" Media Capture does not qualify as document activation, since no isTrusted events are fired as a result of user interactions (since there are none). However, it also goes without question that user expectations include consistent
beforeunload
prompt behavior in described scenarios.To address concerns of abusive
beforeunload
prompts, I would introduce a minimum duration (similar to how transient activation is handled) for Media Capture session to be considered an "alternative activation".Anything else?
There are many ways that active Media Capture can be detected. All evergreen user agents implement some form of indication for active Media Capture sessions (e.g., red/blue circle displayed on the tab and/or in the URL bar, taskbar indicator, changes to document or window title, etc.).
Alternatively, if any of the local devices are attached to a live MediaStreamTrack in mediaDevices's relevant global object's associated Document, it can be considered as an active Media Capture.
The text was updated successfully, but these errors were encountered: