Skip to content

script: No longer do explicit reflows for display#34599

Merged
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:remove-most-explicit-layouts
Dec 13, 2024
Merged

script: No longer do explicit reflows for display#34599
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:remove-most-explicit-layouts

Conversation

@mrobinson
Copy link
Copy Markdown
Member

@mrobinson mrobinson commented Dec 12, 2024

These all happen now in update the rendering, typically after the
message that triggered this code is processed, though in two cases
reflow needs to be triggered explicitly. This makes ReflowReason
redundant though perhaps ReflowCondition can be expanded later to give
more insight into why the page is dirty.

  • Handling of the "reflow timer" concept has been explained a bit more via
    data structures and rustdoc comments.
  • Theme changes are cleaned up a little to simplify what happens during
    reflow and to avoid unecessary reflows when the theme doesn't change.

Notably, layout queries and scrolling still trigger normal reflows and
don't update the rendering. This needs more investigation as it's
unclear to me currently whether or not they should update the rendering
and simply delay event dispatch or only reflow.

In general, this is a simplfication of the code.

Fixes #31871.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Update the rendering: consolidate reflows #31871.
  • These changes are covered by existing WPT tests. In some cases behavior
    may be different, but they do not introduce any changes to layout results as
    far as I can tell.

@mrobinson mrobinson requested a review from gterzian as a code owner December 12, 2024 15:07
Copy link
Copy Markdown
Member

@gterzian gterzian left a comment

Choose a reason for hiding this comment

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

LGTM, with one question.

// parsing, as we need to interrupt it to update contents, but why is this
// necessary when parsing finishes? Not doing the synchronous update in that case
// causes iframe tests to become flaky.
with_script_thread(|script_thread| script_thread.update_the_rendering(false, can_gc))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure it is a good idea to run the full update here, as opposed to only doing a reflow, because finishing parsing a script tag seems to come with it's own approach to performing a microtask checkpoint. Would only doing a reflow here be sufficient? If so, I think it would be the approach with less possible side-effects, either now or if we make changes to the parser(which seems to lag behind the spec from a quick glance).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How would you feel about running update the rendering, but without running a microtask checkpoint? I'm a bit worried about doing reflow of a single pipeline these days. I think it might be leading to early exits of the test runner / flaky result and I'd like to handle this a bit more thoroughly in update the rendering.

Copy link
Copy Markdown
Member Author

@mrobinson mrobinson Dec 13, 2024

Choose a reason for hiding this comment

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

Scratch that. I think the issue is related to our problems with <iframe> sizes. I'm working on that now and should hopefully be able to remove this final reflow (#14719).

@mrobinson mrobinson force-pushed the remove-most-explicit-layouts branch from 677be21 to 8a0b9a8 Compare December 13, 2024 12:16
These all happen now in *update the rendering*, typically after the
message that triggered this code is processed, though in two cases
reflow needs to be triggered explicitly. This makes `ReflowReason`
redundant though perhaps `ReflowCondition` can be expanded later to give
more insight into why the page is dirty.

- Handling of the "reflow timer" concept has been explained a bit more via
  data structures and rustdoc comments.
- Theme changes are cleaned up a little to simplify what happens during
  reflow and to avoid unecessary reflows when the theme doesn't change.

Notably, layout queries and scrolling still trigger normal reflows and
don't update the rendering. This needs more investigation as it's
unclear to me currently whether or not they should update the rendering
and simply delay event dispatch or only reflow.

In general, this is a simplfication of the code.

Fixes servo#31871.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson force-pushed the remove-most-explicit-layouts branch from 8a0b9a8 to e1008d8 Compare December 13, 2024 12:18
@mrobinson mrobinson enabled auto-merge December 13, 2024 12:19
@mrobinson mrobinson added this pull request to the merge queue Dec 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 13, 2024
@mrobinson mrobinson added this pull request to the merge queue Dec 13, 2024
Merged via the queue into servo:main with commit 471d357 Dec 13, 2024
@mrobinson mrobinson deleted the remove-most-explicit-layouts branch December 13, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the rendering: consolidate reflows

2 participants