Skip to content

Conversation

@WorldSEnder
Copy link
Member

@WorldSEnder WorldSEnder commented Aug 27, 2025

Previously, the fixup of next_siblings was done in the first "priority" render, now this happens immediately in the render that transitions from ComponentRenderState::Hydration to ComponentRenderState::Render.

We do so by threading through a reference to the sibling that needs a fix

Fixes #3913

Checklist

  • I have reviewed my own code
  • I have added tests

previously, the fixup was done in the first "real" render, now this
happens immediately in the render that transitions from
ComponentRenderState::Hydration to ComponentRenderState::Render.

We do so by threading through a reference to the sibling that needs
a fix
github-actions[bot]
github-actions bot previously approved these changes Aug 27, 2025
@github-actions
Copy link

github-actions bot commented Aug 27, 2025

Visit the preview URL for this PR (updated for commit de85d40):

https://yew-rs-api--pr3914-fix-early-rerender-daywzpi8.web.app

(expires Tue, 16 Sep 2025 10:11:03 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

github-actions bot commented Aug 27, 2025

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.463 ns      │ 3.721 ns      │ 2.469 ns      │ 2.809 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.462 ns      │ 3.733 ns      │ 2.466 ns      │ 2.666 ns      │ 100     │ 1000000000

@github-actions
Copy link

github-actions bot commented Aug 27, 2025

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 310.657 318.801 312.297 2.579
Hello World 10 464.129 482.973 472.466 5.242
Function Router 10 1603.743 1651.915 1630.303 14.265
Concurrent Task 10 1006.374 1008.145 1007.113 0.599
Many Providers 10 1099.507 1149.708 1120.262 14.000

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 312.367 313.603 312.939 0.497
Hello World 10 469.491 473.541 471.351 1.415
Function Router 10 1627.290 1640.471 1634.880 3.776
Concurrent Task 10 1006.600 1007.758 1007.074 0.447
Many Providers 10 1086.938 1133.868 1120.437 13.072

@github-actions
Copy link

github-actions bot commented Aug 27, 2025

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 99.403 99.387 -0.017 -0.017%
boids 168.695 168.756 +0.061 +0.036%
communication_child_to_parent 91.689 91.724 +0.034 +0.037%
communication_grandchild_with_grandparent 102.709 102.796 +0.087 +0.085%
communication_grandparent_to_grandchild 97.718 97.805 +0.087 +0.089%
communication_parent_to_child 87.607 87.642 +0.034 +0.039%
contexts 103.773 103.939 +0.166 +0.160%
counter 85.107 85.091 -0.017 -0.020%
counter_functional 85.279 85.263 -0.017 -0.019%
dyn_create_destroy_apps 87.906 87.922 +0.016 +0.018%
file_upload 98.469 98.452 -0.017 -0.017%
function_delayed_input 91.740 91.724 -0.017 -0.018%
function_memory_game 170.643 170.835 +0.192 +0.113%
function_router 337.664 338.255 +0.591 +0.175%
function_todomvc 163.279 163.419 +0.140 +0.086%
futures 238.370 238.354 -0.017 -0.007%
game_of_life 104.434 104.417 -0.017 -0.016%
immutable 194.620 194.705 +0.085 +0.044%
inner_html 79.994 79.978 -0.017 -0.021%
js_callback 108.272 108.330 +0.058 +0.053%
keyed_list 196.418 196.452 +0.034 +0.017%
mount_point 83.318 83.302 -0.017 -0.020%
nested_list 115.036 115.123 +0.087 +0.076%
node_refs 90.795 90.829 +0.034 +0.038%
password_strength 1776.479 1776.513 +0.034 +0.002%
portals 93.260 93.294 +0.034 +0.037%
router 307.312 307.707 +0.395 +0.128%
suspense 112.228 112.338 +0.110 +0.098%
timer 88.680 88.663 -0.017 -0.019%
timer_functional 95.011 95.045 +0.034 +0.036%
todomvc 143.627 143.610 -0.017 -0.012%
two_apps 85.722 85.705 -0.017 -0.019%
web_worker_fib 134.766 134.829 +0.063 +0.047%
web_worker_prime 187.477 187.540 +0.063 +0.034%
webgl 82.934 82.917 -0.017 -0.020%

✅ None of the examples has changed their size significantly.

github-actions[bot]
github-actions bot previously approved these changes Aug 27, 2025
@WorldSEnder
Copy link
Member Author

Small explanation why the previous approach was not always correctly working:
Both the initial hydrating render and the priority re-render work top-down. When trusting the latter to fix-up internal reference, these could still be wrong for child components that haven't gotten their priority re-render yet. This is only an issue if this first re-render causes elements to get moved around or added, which is usually not the case (but also not wrong per se, as by that point hydration is over).

@WorldSEnder WorldSEnder changed the title Fix internally tracked sibling positions earlier Fix internally tracked sibling positions earlier when hydrating Aug 27, 2025
github-actions[bot]
github-actions bot previously approved these changes Sep 9, 2025
@WorldSEnder WorldSEnder merged commit b7a599b into yewstack:master Sep 9, 2025
25 checks passed
@WorldSEnder WorldSEnder added the A-yew Area: The main yew crate label Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-yew Area: The main yew crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic when hydrating components with unstable render order

1 participant