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

URL-bar triggered prerendering #7533

Open
domenic opened this issue Jan 25, 2022 · 3 comments
Open

URL-bar triggered prerendering #7533

domenic opened this issue Jan 25, 2022 · 3 comments

Comments

@domenic
Copy link
Member

domenic commented Jan 25, 2022

Today, Safari and Edge ship URL-bar triggered prerendering. Chrome is preparing to do so too. Ideally we'd like to do so in a way that is interoperable, and also clear to developers what is going on.

We've been working on a spec for this at https://wicg.github.io/nav-speculation/prerendering.html . Some of it goes beyond the scope of this issue, e.g. that document has a draft of how we envision <link rel="prerender"> working, and has some (incomplete) considerations for how to handle cross-origin prerendering in a privacy-preserving way, by avoiding storage and credential access. But much of it is applicable to URL-bar triggered prerendering.

In particular, we think it would be valuable to get interop on (and merge into main specs ASAP instead of monkeypatching):

If other implementers are interested in achieving interop in these areas, we'd love to do the work to merge the relevant parts of the spec into HTML, so that web developers have a clear idea of how URL-bar-triggered prerenders affect their page and the APIs they call. Maybe we can even add an API to WebDriver to trigger URL-bar-based prerendering and thus write web platform tests for all these behaviors.

Ideally, this can also serve as a future starting point for more ambitious work on things like <link rel="prerender"> or other web-page-triggered mechanisms of prerendering. But those are much more complicated and we think the right place to start is user-initiated prerenders, which are still web-observable, but involve only a single party.

Thoughts?

@domenic domenic added addition/proposal New features or enhancements topic: navigation topic: browsing context agenda+ To be discussed at a triage meeting labels Jan 25, 2022
@annevk
Copy link
Member

annevk commented Jan 26, 2022

In general this sounds good to me. I wonder what the best way to achieve some of this may be in a way that doesn't lead to new specifications having to build for many types of documents. Can the fully active concept perhaps be reused here?

@domenic
Copy link
Member Author

domenic commented Jan 26, 2022

I wonder what the best way to achieve some of this may be in a way that doesn't lead to new specifications having to build for many types of documents. Can the fully active concept perhaps be reused here?

I don't think it can be used as-is, although maybe it could be split up a bit. In particular, non-fully-active documents have inactive event loops (i.e. with no tasks running), which kind of defeats the point of prerendering.

More generally, for "intrusive" APIs, we have a few broad possibilities for things to do while a page is prerendered or in bfcache:

  • Discard: Cause the prerendered/bfcached document to be discarded
  • (If async) Delay: Delay the promise/callback until the document becomes active
  • Fail: immediately count the process as failed, e.g. return a rejected promise, throw an exception, or silently return a sentinel value (e.g. null from window.open() or false from window.confirm())

It seems like in most bfcache cases we've choosen "fail". Whereas in most prerendering cases we've so far specced "delay", although in the Chromium implementation we plan to start a number of them with "discard" and then move them to "delay" over time to improve coverage.

Part of this difference seems to be based on the does-it-run-JavaScript split. I.e., if you use (say) geolocation from a bfcached page, something pretty weird must have happened, so "fail" seems OK. Whereas if you prerender a page with an embedded map, it could very legitimately request geolocation permissions while prerendering, so "delay" seems much better.

It's probably worth doing some spec footwork though so that for APIs which do want the same result (e.g., window.confirm()) it is easy to get that without too much extra work. And maybe even making the system have a good default, i.e. if you don't specifically account for prerendering, you get fail or delay or something by default?? (Although for bfcache we didn't manage to do that.)

@noamr
Copy link
Contributor

noamr commented Jan 27, 2022

It's probably worth doing some spec footwork though so that for APIs which do want the same result (e.g., window.confirm()) it is easy to get that without too much extra work. And maybe even making the system have a good default, i.e. if you don't specifically account for prerendering, you get fail or delay or something by default?? (Although for bfcache we didn't manage to do that.)

I think it should go with discard by default and we should avoid fail as much as possible. fail means that once the page is activated it's possibly at an error state that could have been avoided if we didn't prerender. That's a potential degradation of user experience...

We should use fail only for cases where anyway the developer can expect failure, e.g. requestFullScreen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants