1 of 31

PRESENTER STEPS:

  • Ensure your backup presenter is available
  • Present your slides or pre-recorded talk by:
    • selecting "Present now";
    • selecting "Your entire screen," "A window," or "Chrome tab;" and
    • selecting "Share"
  • If applicable, remove participants by:
    • [Non-Googlers] asking a Google participant to remove participants
    • [Googlers] selecting "Remove from meeting" in a participant's thumbnail image

TECHNICAL CONSIDERATIONS:

  • Turn on captions by:
    • selecting "Turn on captions"
  • If you experience quality issues, change your send and receive resolutions to 360p by:
    • selecting "Settings"
    • selecting "Video" and then the setting you want to change

2 of 31

Prerendering:

Design and Status

Matt Falkenhagen, on behalf of the team

BlinkOn 14

3 of 31

Prerender

Without

With

See also previous talk (slides) from BlinkOn 13

BlinkOn 14

4 of 31

Status and updates

  • Minimal core functionality mostly works ;)
    • Built on MPArch: see the BlinkOn 14 Talk just before this one
  • Origin Trial targeting Q3/Q4
    • Restricted to same-origin URL targets.
    • Triggered by the speculationrules API.

BlinkOn 14

5 of 31

Same-origin

  • Why
    • Reduces privacy/security risk.
    • Reduces compat risk: site opt-in.
  • Plan to support omnibox-triggered and cross-origin later.

BlinkOn 14

6 of 31

Speculation rules

  • New flexible, powerful API
  • Less risk of breakage than changing <link rel=prerender> behavior.

<script type="speculationrules">�{ prerender: [{ source: 'list', urls: ['next.html'] }] }�</script>

BlinkOn 14

7 of 31

Behaviors of prerendered content

BlinkOn 14

8 of 31

Restrictions on prerendered content

  • We restrict certain APIs used by prerendered content.
    • As part of the specification
  • Don’t want disruptive behavior: audio, popups, prompts, tab title change, etc.
  • Generally this applies to both same-origin and cross-origin
    • Some restrictions may vary

BlinkOn 14

9 of 31

Restricted APIs will mostly defer

document.addEventListener('prerenderingchange', () => {� console.log('activated!');�});

console.log(document.prerendering); // true;const result = await navigator.frobinate();�console.log(document.prerendering); // false;

Outputs: “true”, “activated!”, “false”.

BlinkOn 14

10 of 31

What APIs to restrict

  • APIs that already are restricted in some contexts are candidates for being restricted in prerendered content.
    • Permissions API-controlled features
    • Policy-controlled features (that are not permitted by default)

BlinkOn 14

11 of 31

Specification text

  • See in progress spec.
  • Example of deferral:

Modify the getCurrentPosition() method steps by prepending the following step:

If this's relevant global object's browsing context is a prerendering browsing context, then append the following steps to this's post-prerendering activation steps list and return.

BlinkOn 14

12 of 31

How this is implemented (idealized)

  • Blink-side

getCurrentPosition() {� if (document->IsPrerendering()) {

document->AddPostPrerenderActivationStep(

WTF::Bind(&getCurrentPosition));

return;�}

  • Browser-side
    • See lingqi@ and toyoshim@’s Day 3 lightning talk “Mojo capability control”

BlinkOn 14

13 of 31

WPT

  • Tests are landing at wpt_internal/prerender.
  • Before upstreaming we need a deterministic way to trigger prerendering in a test (speculationrules are just hints), and others.

BlinkOn 14

14 of 31

What have we done

  • We have identified 110 desired restrictions and finished 47% of them.
  • Many thanks to {myid.shin, gyuyoung, jkim} at Igalia for contributions.

BlinkOn 14

15 of 31

Special cases

BlinkOn 14

16 of 31

Storage

  • We plan to grant it during same-origin prerendering.
  • Sync storage APIs are very popular and cannot be deferred → grant.
  • Async APIs also granted for consistency.
  • Same-origin vs. Cross-origin
    • Cross-origin: privacy risk and lack of opt-in, needs a different solution.
  • Also considered isolated storage ideas + merging on click: may pursue in future (cross-origin may use this).

BlinkOn 14

17 of 31

Session storage

  • Problem: Session storage is intended to be scoped to the “tab”. Is the prerendered page in the tab?
  • Problem: If so, there are now multiple live pages in the same “tab”. Do all these pages use the same storage?
  • Problem: Current browsers cannot handle multiple processes using the same session storage.
  • Proposal:

BlinkOn 14

18 of 31

Service worker

  • Problem: Service workers can intercept resource requests. Should service worker see prerender navigations and loads?
  • Problem: Service workers can see open pages. Should service worker see prerendered pages?
  • Problem: Can a service worker started for prerendering be used to bypass the API restrictions?
  • Proposal:
    • SW can see prerender navigations.
    • SW can see prerendered pages as clients.
    • “Prerendered SW” is restricted. SW counts as “prerendered SW” iff all its clients are prerendered.

BlinkOn 14

19 of 31

Session history

  • Problem: What does history.back() do in a prerendered context?
    • Does it go to the previous state in the prerendered context?
  • Problem: What does history.back() do after activation occurred?
    • Does it go to the previous state from the prerendered context, or to the previous state from the primary context?
  • Problem: What does history.length look like before and after activation?
  • Proposal:
    • Prerendered page's window.history.length is always 1.
    • When a prerendered page is activated, its solo history entry is appended to the joint session history.

BlinkOn 14

20 of 31

Try it now

  • chrome://flags/#enable-prerender2 (or --enable-features=prerender2)
    • Uses <link rel=prerender> currently, and same-origin only.
  • Demo page: https://prerender2.glitch.me/ (from arthursonzogni@)
  • Bugs are tracked at Internals>Preload>Prerender
  • See design doc
  • We are looking for help! Contact falken@chromium.org.

BlinkOn 14

21 of 31

Discussion

BlinkOn 14

22 of 31

Archive

BlinkOn 14

23 of 31

Agenda

  • What is Prerendering
  • Launch plan
  • Same-origin
  • Speculation rules
  • Restrictions/behaviors of prerendered content
    • Session storage
    • Service worker
    • Session history
  • Specification
  • Testing
  • Metrics

BlinkOn 14

24 of 31

Metrics (maybe drop this one)

  • TODO add text

BlinkOn 14

25 of 31

BlinkOn 14

26 of 31

BlinkOn 14

27 of 31

BlinkOn 14

28 of 31

BlinkOn 14

29 of 31

BlinkOn 14

30 of 31

BlinkOn 14

31 of 31

BlinkOn 14