-
Notifications
You must be signed in to change notification settings - Fork 50
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
Determine interaction with back forward cache #326
Comments
Thanks for filing this! The BFCache team and the Web Transport team discussed about this earlier but haven't reached any conclusions on what to do with existing WebTransport connections when the page is put into BFCache. As it is currently specced, it will go through the unloading steps which will fail existing connections (CMIIW). We might want to change this to be more useful/powerful if the page enters BFCache (loses full activity), e.g. maybe keep the connection in some form. In case it might be useful, here's a link to the TAG design principles PR: w3ctag/design-principles#317 (cc @fergald) |
I think it's desirable and POLA to close connections when navigating away from a page. The BFCache is a user agent optimization that some browsers do, but we should consider that most pages that go on it are never to be heard from again. The current behavior matches webrtc and websocket which seems right to me.
It stays closed? |
Ideally the close event was delivered when the page comes back out of BFCache. My understanding is that the close event is not delivered when the connections are closed due to navigating away, so there would be no change for the never-restored case. |
Meeting
|
Is there a spec update needed for this? We can also write a WPT for this now that BFCache WPT support had landed (see also: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/browsers/browsing-the-web/back-forward-cache/README.md) |
Correct me if I'm wrong, but the current state of the spec leaves a document that's made a trip through the bfcache in an invalid state: FAILED, connection dropped, but cleanup() hasn't been run: ready and closed may not be resolved (or rejected), any active streams have not be errored, etc. |
Just want to chime in that running |
FYI, Mozilla is going to block pages with CONNECTING/CONNECTED status from the bfcache for now, until this is resolved. Testing shows us that Chrome appears to be blocking it as well (@ricea ?) including in a case we allow (shared worker with a closed or failed WebTransport). |
@jesup Chrome does not allow pages with shared workers into BFCache. A page with a dedicated worker and an open WT connection would be blocked. If think our current impl is that if the connection object exists, we block, we don't examine the state. This is supposed to be a temporary situation until the correct behaviour is available. |
I see a bunch of options:
There are probably other options I haven't considered.
|
Thanks for exploring the options!
How is doing the same as WebSocket an obstacle to becoming ubiquitous like WebSockets? Pages using WebSocket seem already banned from the bfcache:
Relying on apps to write special code to handle BFCache seems unrealistic, but perhaps with a sufficiently motivating use case that might change. What are some compelling use cases? |
@jan-ivar What do you mean by "what are some compelling use cases?"? Use cases for what? Shoudln't all users of the API should be handling unexpected closures of the WebTransport anyway, just to deal with "normal" failures? BFCache would just be another source of failures. |
Thanks for explaining the rationale. It makes sense to learn from experience with WebSocket. But what's the lesson?
Same question to WebSocket. E.g. what's blocking whatwg/html#1931 from fixing those 2-3%? What makes us think apps would use WebTransport more responsibly than they use WebSocket today? I fear the lesson might be that what apps "should" do is different from what they will do. What I meant with "compelling use cases" is what would compel individual apps to care about navigation performance over convenience, and what sort of apps might they be? The benefit is not lost on me, but we seem to be running out of time to correct this. Unless whatwg/html#1931 harbors some solution I missed, the only incentive I see for apps to handle connection failure from navigation, is for already shipping implementations to require it asap to not break them. |
I believe the same argument applied to WebSock but my understanding is that WebSocket's usage was large enough that it was considered too disruptive. The best time to do make WebTransport compatible with BFCache (as with all APIs) was before launch, the second best time is now, assuming usage is only going to grow.
I don't think that's the right question. The offer in 2 is not "add a close handler and we will give you BFCache", it's "we're giving the user BFCache, add a close handler or your app will be broken (more than it already is)". For 2, the question is whether we (browsers) can justify any breakage that occurs. Arguably any app that breaks with 2 was already broken. Is there a common use case where not handling closure is reasonable? Playing around with https://webtransport.day/, any time I drop off the network, the connection closes pretty quickly. So it does seem like any "serious" apps would already handle closure. It's actually surprising how sensitive it is. I expected that it would survive me going offline for a few seconds. Not sure if that's intrinsic to the feature or just Chrome's implementation. |
Is there a precedent showing this worked, or would WebTransport be first? AFAIK BFCache was/is an optimization some browsers did, with the onus on UAs to not break applications or require their participation to not break. Specs seem to mention BFCache a lot more these days, and more browsers do it, which is encouraging, but is there an explainer doc with current thoughts? I found whatwg/html#5880 but no overview explanation. I'm wondering when this shift happened or if it has. |
In both Chrome and Firefox it fails for me about ~10 seconds after I disconnect WiFI. If I reconnect before that time then the connection survives. WebTransport is fairly low-level, so I'm not surprised. @jesup may know more. |
Mozilla and Safari have had it for years. Chome has it recently. Safari is pretty aggressive and caches in some cases where Mozilla and Chrome don't, e.g. on desktop The TAG design principles were updated in the last year to include a section on making sure your feature works with BFCache (and prerendering). In the last 2 years, Chrome (mostly @rakina) has done a bunch of work to make BFCache better represented in Web Platform docs and to fix up problems in standards. We are trying to make it impossible to add a feature without being explicit BFCache. Safari and Mozlla are quite on-board with this effort. |
We need to specify the behaviour when the page is navigated away and the document is placed in the browser's back forward cache. Also what happens if/when the page is restored from the cache.
The text was updated successfully, but these errors were encountered: