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

Allow certain tasks to run even when document is not fully active? #6699

Closed
rakina opened this issue May 20, 2021 · 5 comments
Closed

Allow certain tasks to run even when document is not fully active? #6699

rakina opened this issue May 20, 2021 · 5 comments

Comments

@rakina
Copy link
Member

rakina commented May 20, 2021

Currently Chrome's implementation of BFCache allows certain tasks to run even when its document is not fully active, as long as it doesn't expose any web-observable behaviors (e.g. events). In particular, we allow in-flight network requests to continue loading, but not new network requests.

However, I think currently fetch tasks are posted with an associated document, which aren't runnable if the document is not fully active (CMIIW!)

I wonder if it's possible to change the spec to allow Chrome's behavior here? Or maybe even just a note that it's possible that some user agents don't 100% follow the "runnable" rule?

cc @domenic @fergal

@domenic
Copy link
Member

domenic commented May 20, 2021

When I looked into something similar for https://wicg.github.io/page-lifecycle/, we found that none of the tasks that Chrome runs while a document is frozen exist in the spec; they all just happen to use similar "task runner" infrastructure.

I suspect something similar is the case here. I.e., there is no observable difference between the spec's behavior (of running no tasks) and Chrome's behavior (of running some tasks, but only if they don't do anything observable). In that case there wouldn't be anything to change in the spec.

Are there cases you have in mind where there are specific tasks that exist in the spec, but which Chrome runs in non-fully active documents? Like, could you point to the "queue a task" line in the spec?

@rakina
Copy link
Member Author

rakina commented May 20, 2021

Thanks! The tasks that I'm concerned about are all the various fetch tasks (example), but maybe as you say since it's not really observable we don't need to update the spec. I guess it's not really 100% not observable in that the server that sends the resource would notice that the page still continues the fetch, but that's probably out of scope of the spec?

@domenic
Copy link
Member

domenic commented May 20, 2021

Hmm, that's still sorta in scope. I'd be curious about @annevk's take, as he was changing that area of the spec recently.

Interestingly, other fetch tasks are completely not observable, e.g. the ones to process end of body. It's just the chunk-reading one that you linked to, I think, which the server would observe.

@annevk
Copy link
Member

annevk commented May 21, 2021

So for downloading (step 19 of https://fetch.spec.whatwg.org/#concept-http-network-fetch) I think we are okay. That currently does not but should queue a task to enqueue the ArrayBuffer, but it queues it after obtaining the bytes. I.e., network retrieval would continue, but task side effects would happen once the document becomes active again. (Unless network tasks are discarded? It would be good to have tests around this.)

For uploading we could make it work for non-actual stream cases (which is currently all of them; what is the plan for upload streams? cc @yutakahirano @yoichio) in a similar manner I suspect, but it would require having a more abstract stream concept. I'm having a hard time recalling if we have notes around some of the JavaScript streams stuff being hand-wavy (especially when in parallel), but that might suffice here (except it would not for upload streams I think).

Hope that helps.

@rakina
Copy link
Member Author

rakina commented May 27, 2021

Thank you!
I talked with @fergald about this earlier today and I think Chrome does not support continuing the upload when a page is in bfcache (at least, intentionally - we're gonna add tests to make sure). Then I think we're good here!

@rakina rakina closed this as completed May 27, 2021
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 19, 2021
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 25, 2021
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 7, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 7, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 25, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}
aarongable pushed a commit to chromium/chromium that referenced this issue Jan 25, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}
past pushed a commit to web-platform-tests/wpt that referenced this issue Jan 25, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}

Co-authored-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 5, 2022
…ch, a=testonly

Automatic update from web-platform-tests
[WPT] BFCache eligibility: in-flight fetch (#31227)

When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}

Co-authored-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
--

wpt-commits: 847d71c7a865d9c3a6e16dad5e95a6cc37c7e13a
wpt-pr: 31227
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Feb 7, 2022
…ch, a=testonly

Automatic update from web-platform-tests
[WPT] BFCache eligibility: in-flight fetch (#31227)

When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}

Co-authored-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
--

wpt-commits: 847d71c7a865d9c3a6e16dad5e95a6cc37c7e13a
wpt-pr: 31227
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
When there is an in-flight network request at the time of navigation,

Chrome: The page is BFCached and
        the fetch request completes successfully after restored.
Firefox: The page is not BFCached
Safari: The page is BFCached but
        the fetch request is canceled.

Bug: whatwg/html#6699
Change-Id: I1d84d92c6396abad62eab9306f8656cbf303f8c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222281
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962858}
NOKEYCHECK=True
GitOrigin-RevId: 419fccc6c3301a0d8702a860195ec2fc780505d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants