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

Overhaul document unloading/destruction/aborting #9907

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

domenic
Copy link
Member

@domenic domenic commented Nov 2, 2023

As noted in #9148, the way in which destroy calls abort, and unload calls destroy, is not sound when most of these algorithms act on the entire tree. Instead, we need to split these algorithms into single-document base variants, which call each other, and whole-tree "document and its descendant" variants, which proceed carefully.

The whole-tree variants in particular need to take care with how they queue tasks. We cannot fire events (like unload for unloading, or readystatechange for aborting) inside of inactive documents, so we need to delay making a document inactive until its children have been processed. (The related issue #9869 around reloading is not yet solved, however, since that is a special case where the same session history entry is reused and thus making documents inactive is harder to avoid.)

Closes #9148. Closes #9904 while we're in the area.

@kalenikaliaksandr could you take a look? Also CC @ADKaster.


/browsing-the-web.html ( diff )
/document-lifecycle.html ( diff )
/document-sequences.html ( diff )

@domenic domenic requested a review from domfarolino November 2, 2023 08:54
kalenikaliaksandr added a commit to kalenikaliaksandr/serenity that referenced this pull request Nov 3, 2023
See whatwg/html#9907

As far as I understand these changes do not fix bugs in our
implementation but allows us to remove some hacks and be aligned with
the spec.
Copy link
Member

@kalenikaliaksandr kalenikaliaksandr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I applied these changes to my implementation, it fixes the issue and haven't found any new problems yet.

kalenikaliaksandr added a commit to kalenikaliaksandr/serenity that referenced this pull request Nov 3, 2023
See whatwg/html#9907

As far as I understand these changes do not fix bugs in our
implementation but allows us to remove some hacks and be aligned with
the spec.
@domenic domenic force-pushed the recursive-unload-destroy-etc branch from 465ce88 to 2e397f0 Compare November 15, 2023 00:45
As noted in #9148, the way in which destroy calls abort, and unload calls destroy, is not sound when most of these algorithms act on the entire tree. Instead, we need to split these algorithms into single-document base variants, which call each other, and whole-tree "document and its descendant" variants, which proceed carefully.

The whole-tree variants in particular need to take care with how they queue tasks. We cannot fire events (like unload for unloading, or readystatechange for aborting) inside of inactive documents, so we need to delay making a document inactive until its children have been processed. (The related issue #9869 around reloading is not yet solved, however, since that is a special case where the same session history entry is reused and thus making documents inactive is harder to avoid.)

Closes #9148.
@domenic domenic force-pushed the recursive-unload-destroy-etc branch from 2e397f0 to a49f99e Compare November 15, 2023 00:47
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@domenic domenic requested a review from domfarolino January 9, 2024 04:09
@domfarolino
Copy link
Member

domfarolino commented Jan 10, 2024

The build is fine here, so let me close and re-open this which I think is the trick for getting PR preview to work again, just so I can look at this a bit differently.

Edit: Fixed the build.

@domfarolino domfarolino reopened this Jan 10, 2024
Copy link
Member

@domfarolino domfarolino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks for the discussion on the two previously-open threads. LGTM.

@domenic
Copy link
Member Author

domenic commented Jan 11, 2024

Yeah, so the hiding of "in parallel" in the algorithm header can indeed be confusing. I'll open another issue to discuss that, since it's a potential general problem.

@domenic domenic merged commit 4ca6ec0 into main Jan 11, 2024
2 checks passed
@domenic domenic deleted the recursive-unload-destroy-etc branch January 11, 2024 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Potential error in connection between "Document destroy" and "Document abort" algorithms
3 participants