Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incremental/parallel tree construction#247

Merged
nicoburns merged 33 commits intoDioxusLabs:mainfrom
nicoburns:incremental-construction
Sep 2, 2025
Merged

Incremental/parallel tree construction#247
nicoburns merged 33 commits intoDioxusLabs:mainfrom
nicoburns:incremental-construction

Conversation

@nicoburns
Copy link
Collaborator

@nicoburns nicoburns commented Aug 13, 2025

Objective

Greatly improve performance by:

  • Doing construction / layout / paint incrementally where possible.
  • Doing some parts of the construction in parallel

Todo

Parley

  • Invalidate all parley layouts when a new font is loaded
  • Invalidate all parley layouts when scale factor changes
  • Make underline/strikethrough/textcolor updates work without rebuilding parley layout
  • Reuse parley::Layout when reconstructing (use build_into)
  • Cache intrinsic sizes + compute in pconstruct phase (if no children)

Bugs

Optimisations

  • Don't request redraw if scroll event has no effect (try to scoll past end of doc)
  • Optimise style diffing (ptr comparisons) moved to issue
  • Limit damage to formatting context where appropriate moved to issue
  • Make use of REPAINT damage (don't repaint if no damage) moved to issue

@nicoburns nicoburns force-pushed the incremental-construction branch 8 times, most recently from 94d2787 to 5217f4f Compare August 20, 2025 14:22
@nicoburns nicoburns force-pushed the incremental-construction branch 4 times, most recently from bc01085 to 4a81662 Compare August 25, 2025 15:36
@Aeledfyr
Copy link

Looks like there's an issue with width computation and psuedoelements: With a 2-deep nested flex layout, with widths determined by the content sizes, adding a pseudo-element on hover breaks text-align: center on all but the 2 most recently hovered elements.

Example test file: align-bug.html
Tested with cargo run --release --package readme --features incremental ./align-bug.html

Behavior with incremental enabled: https://github.com/user-attachments/assets/3fb691a8-dc37-40a1-bfa3-2908d58af767
Behavior without incremental: https://github.com/user-attachments/assets/e5374ec2-f2ee-4c67-be5d-f178a5ea56bc

@nicoburns nicoburns force-pushed the incremental-construction branch from 4a81662 to 0e9b0c8 Compare August 29, 2025 16:07
@nicoburns nicoburns changed the title Incremental tree construction Incremental/parallel tree construction Aug 29, 2025
@nicoburns nicoburns force-pushed the incremental-construction branch 9 times, most recently from 6e0083b to d995e2a Compare September 1, 2025 12:17
@nicoburns
Copy link
Collaborator Author

@Aeledfyr That is really bizarre behaviour. Thanks for the reproduction! I think I've managed to track down the issue.

This is a bit technical, but what was happening was that the "measure content width" stages of subsequent layout runs were "clobbering" the layout in order to measure the text (but were unable to correctly compute alignment as they didn't yet have the width to align to available at that stage). Normally the later "final layout" stage would overwrite that, but in this case that stage was hitting the cache and not running at all.

The fix I've pushed is a bit of hack which runs the "measure content width" stage on a clone of the layout. I would have expected this to be slow, but in practice it doesn't seem to make much difference. So I've put it in for now, and we can clean it up later.

@nicoburns nicoburns force-pushed the incremental-construction branch 2 times, most recently from 582f6d4 to 09c4c67 Compare September 2, 2025 13:04
@nicoburns nicoburns marked this pull request as ready for review September 2, 2025 13:10
Signed-off-by: Nico Burns <[email protected]>
Signed-off-by: Nico Burns <[email protected]>
due to not differentiating between the min-content and max-content sizes
of inline boxes without the layout.
@nicoburns nicoburns force-pushed the incremental-construction branch from 09c4c67 to 257c221 Compare September 2, 2025 14:31
@nicoburns nicoburns merged commit c4fd1e5 into DioxusLabs:main Sep 2, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants