Mingyu Lei
unread,Nov 6, 2023, 4:41:16 AM11/6/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to webrtc-dev, Guido Urdaneta, bfcache-dev, Mingyu Lei, Fergal Daly, yu...@google.com, webrt...@chromium.org, Harald Alvestrand
Thanks Guido and Harald for your comments. Please find our inline reply below. In short, we still propose keeping the page with open MediaStreamTracks in BFCache as much as possible.
Wrt MediaStreams, they should be closed by stopping all the tracks (not by setting the enabled property to false). This normally happens automatically when a page is navigated away (we just need to make sure it continues to happen if we store the page in BFCache).
Yes, we agree that we should try to stop all of the tracks in the same manner as it’s done in a (non-BFCached) navigation.
My thought is that pages with open mediastreamtracks shouldn't be stored in the bfcache at all.
Just stopping the tracks while storing the JS state of the page will leave the JS portions of the page thinking that it has open devices, while the device management part of the browser thinks that these devices are closed.
It should be possible to keep the “JS part” and the “device management part” in sync right? One way to achieve it is to close the tracks and notify the JS part through the `ended` event. Even if the event is only fired after the page restoration, it should not create any confusion or inconsistent state.
Blocking BFCache should only be used as a last resort. In this case, it seems keeping the page in BFCache while closing all the tracks is a feasible option, so we want to explore this further and address any concerns before considering blocking BFCache.
Reopening would be highly confusing to the user, and might have security implications.
Indeed, it’s not clear whether reopening (or not reopening) is the “right” behavior due to the differences between users’ expectation (that a new page is loaded when they hit the back button) and the actual state of the page (that it is only hidden and then shown). If the JS side is properly notified that the tracks were closed (due to navigation), it’s able to react accordingly on `pageshow`. So it could be a choice to not reopen the tracks during page restoration.