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

fix: case where shrinking a list would cause an exception #4312

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Mar 19, 2024

Basically what happens is the following

item-1
item-2
item-3
item-4

as keyed items transitions to

item-1
item-4 --> is a functional component returning null
item-5
item-6

In the first pass we see that items 2 and 3 can be removed and we set the _nextDom to the _dom of item-4. When we render item-1 we see that we can let it stay in place, we render item-4 and see we can unmount it... However... Our _nextDom will be set to item-4 due to this line. That by extension means that oldDom will always be set to an unmounted item which will cause crashes.

This PR adds safeguards so that if we see that we are dealing with an unmounted dom-node that we transition the oldDom to the next sibling

Fixes #4221

Copy link

github-actions bot commented Mar 19, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -2% - +2% (-1.17ms - +1.52ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -3% - +3% (-1.04ms - +1.09ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -1% - +1% (-9.47ms - +7.90ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -1% - +1% (-0.25ms - +0.10ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +2% (-0.63ms - +1.62ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -4% - +4% (-0.68ms - +0.68ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -3% - +2% (-0.07ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +2% (-0.36ms - +0.49ms)
    preact-local vs preact-main

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main

Results

02_replace1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main74.76ms - 76.51ms-unsure 🔍
-2% - +2%
-1.52ms - +1.17ms
unsure 🔍
-1% - +2%
-0.84ms - +1.36ms
preact-local74.79ms - 76.83msunsure 🔍
-2% - +2%
-1.17ms - +1.52ms
-unsure 🔍
-1% - +2%
-0.78ms - +1.65ms
preact-hooks74.71ms - 76.03msunsure 🔍
-2% - +1%
-1.36ms - +0.84ms
unsure 🔍
-2% - +1%
-1.65ms - +0.78ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.40ms - 3.40ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
1% - 1%
0.02ms - 0.03ms
preact-local3.40ms - 3.40msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
1% - 1%
0.02ms - 0.02ms
preact-hooks3.43ms - 3.43msslower ❌
1% - 1%
0.02ms - 0.03ms
slower ❌
1% - 1%
0.02ms - 0.02ms
-

run-warmup-0

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main29.47ms - 30.21ms-unsure 🔍
-2% - +2%
-0.56ms - +0.52ms
unsure 🔍
-3% - +1%
-0.78ms - +0.31ms
preact-local29.46ms - 30.25msunsure 🔍
-2% - +2%
-0.52ms - +0.56ms
-unsure 🔍
-3% - +1%
-0.78ms - +0.34ms
preact-hooks29.68ms - 30.48msunsure 🔍
-1% - +3%
-0.31ms - +0.78ms
unsure 🔍
-1% - +3%
-0.34ms - +0.78ms
-

run-warmup-1

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main39.76ms - 41.19ms-unsure 🔍
-3% - +2%
-1.14ms - +0.97ms
unsure 🔍
-4% - +0%
-1.63ms - +0.13ms
preact-local39.79ms - 41.33msunsure 🔍
-2% - +3%
-0.97ms - +1.14ms
-unsure 🔍
-4% - +1%
-1.59ms - +0.27ms
preact-hooks40.71ms - 41.74msunsure 🔍
-0% - +4%
-0.13ms - +1.63ms
unsure 🔍
-1% - +4%
-0.27ms - +1.59ms
-

run-warmup-2

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.70ms - 27.18ms-unsure 🔍
-1% - +1%
-0.26ms - +0.38ms
unsure 🔍
-3% - +1%
-0.81ms - +0.32ms
preact-local26.67ms - 27.09msunsure 🔍
-1% - +1%
-0.38ms - +0.26ms
-unsure 🔍
-3% - +1%
-0.86ms - +0.25ms
preact-hooks26.67ms - 27.70msunsure 🔍
-1% - +3%
-0.32ms - +0.81ms
unsure 🔍
-1% - +3%
-0.25ms - +0.86ms
-

run-warmup-3

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main25.11ms - 26.16ms-unsure 🔍
-0% - +5%
-0.06ms - +1.32ms
unsure 🔍
-4% - +2%
-0.93ms - +0.63ms
preact-local24.55ms - 25.46msunsure 🔍
-5% - +0%
-1.32ms - +0.06ms
-faster ✔
0% - 6%
0.05ms - 1.51ms
preact-hooks25.21ms - 26.36msunsure 🔍
-2% - +4%
-0.63ms - +0.93ms
slower ❌
0% - 6%
0.05ms - 1.51ms
-

run-warmup-4

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main28.26ms - 30.01ms-slower ❌
1% - 9%
0.19ms - 2.48ms
unsure 🔍
-7% - +1%
-1.98ms - +0.41ms
preact-local27.06ms - 28.53msfaster ✔
1% - 8%
0.19ms - 2.48ms
-faster ✔
4% - 11%
1.03ms - 3.22ms
preact-hooks29.11ms - 30.73msunsure 🔍
-1% - +7%
-0.41ms - +1.98ms
slower ❌
4% - 12%
1.03ms - 3.22ms
-

run-final

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main23.28ms - 24.08ms-unsure 🔍
-1% - +4%
-0.21ms - +0.91ms
unsure 🔍
-2% - +2%
-0.57ms - +0.53ms
preact-local22.95ms - 23.72msunsure 🔍
-4% - +1%
-0.91ms - +0.21ms
-unsure 🔍
-4% - +1%
-0.91ms - +0.17ms
preact-hooks23.33ms - 24.08msunsure 🔍
-2% - +2%
-0.53ms - +0.57ms
unsure 🔍
-1% - +4%
-0.17ms - +0.91ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main31.66ms - 33.14ms-unsure 🔍
-3% - +3%
-1.09ms - +1.04ms
unsure 🔍
-3% - +3%
-1.09ms - +1.02ms
preact-local31.66ms - 33.19msunsure 🔍
-3% - +3%
-1.04ms - +1.09ms
-unsure 🔍
-3% - +3%
-1.08ms - +1.07ms
preact-hooks31.68ms - 33.18msunsure 🔍
-3% - +3%
-1.02ms - +1.09ms
unsure 🔍
-3% - +3%
-1.07ms - +1.08ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.37ms - 3.38ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
faster ✔
0% - 1%
0.01ms - 0.02ms
preact-local3.37ms - 3.38msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-faster ✔
0% - 1%
0.01ms - 0.02ms
preact-hooks3.38ms - 3.39msslower ❌
0% - 1%
0.01ms - 0.02ms
slower ❌
0% - 1%
0.01ms - 0.02ms
-
07_create10k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main899.47ms - 910.25ms-unsure 🔍
-1% - +1%
-7.90ms - +9.47ms
unsure 🔍
-1% - +1%
-7.54ms - +7.05ms
preact-local897.26ms - 910.88msunsure 🔍
-1% - +1%
-9.47ms - +7.90ms
-unsure 🔍
-1% - +1%
-9.43ms - +7.37ms
preact-hooks900.19ms - 910.01msunsure 🔍
-1% - +1%
-7.05ms - +7.54ms
unsure 🔍
-1% - +1%
-7.37ms - +9.43ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.40ms - 26.40ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-local26.40ms - 26.40msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-hooks26.42ms - 26.42msunsure 🔍
+0% - +0%
+0.02ms - +0.02ms
unsure 🔍
+0% - +0%
+0.02ms - +0.02ms
-
filter_list

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main16.53ms - 16.87ms-unsure 🔍
-1% - +1%
-0.10ms - +0.25ms
unsure 🔍
-1% - +1%
-0.10ms - +0.25ms
preact-local16.59ms - 16.66msunsure 🔍
-1% - +1%
-0.25ms - +0.10ms
-unsure 🔍
-0% - +0%
-0.06ms - +0.06ms
preact-hooks16.59ms - 16.67msunsure 🔍
-1% - +1%
-0.25ms - +0.10ms
unsure 🔍
-0% - +0%
-0.06ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main1.42ms - 1.42ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
faster ✔
2% - 2%
0.03ms - 0.03ms
preact-local1.42ms - 1.42msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-faster ✔
2% - 2%
0.02ms - 0.03ms
preact-hooks1.44ms - 1.45msslower ❌
2% - 2%
0.03ms - 0.03ms
slower ❌
2% - 2%
0.02ms - 0.03ms
-
hydrate1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main74.04ms - 75.05ms-unsure 🔍
-2% - +1%
-1.62ms - +0.63ms
unsure 🔍
-2% - +1%
-1.46ms - +0.70ms
preact-local74.03ms - 76.05msunsure 🔍
-1% - +2%
-0.63ms - +1.62ms
-unsure 🔍
-2% - +2%
-1.27ms - +1.50ms
preact-hooks73.97ms - 75.87msunsure 🔍
-1% - +2%
-0.70ms - +1.46ms
unsure 🔍
-2% - +2%
-1.50ms - +1.27ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main6.10ms - 6.10ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
0% - 1%
0.02ms - 0.04ms
preact-local6.10ms - 6.10msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
0% - 1%
0.02ms - 0.04ms
preact-hooks6.12ms - 6.14msslower ❌
0% - 1%
0.02ms - 0.04ms
slower ❌
0% - 1%
0.02ms - 0.04ms
-
many_updates

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main16.56ms - 17.49ms-unsure 🔍
-4% - +4%
-0.68ms - +0.68ms
unsure 🔍
-4% - +3%
-0.61ms - +0.53ms
preact-local16.52ms - 17.52msunsure 🔍
-4% - +4%
-0.68ms - +0.68ms
-unsure 🔍
-4% - +3%
-0.64ms - +0.55ms
preact-hooks16.74ms - 17.39msunsure 🔍
-3% - +4%
-0.53ms - +0.61ms
unsure 🔍
-3% - +4%
-0.55ms - +0.64ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main4.52ms - 4.53ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-local4.52ms - 4.52msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
0% - 1%
0.02ms - 0.02ms
preact-hooks4.54ms - 4.55msunsure 🔍
+0% - +0%
+0.02ms - +0.02ms
slower ❌
0% - 1%
0.02ms - 0.02ms
-
text_update

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main2.46ms - 2.55ms-unsure 🔍
-2% - +3%
-0.05ms - +0.07ms
faster ✔
5% - 9%
0.13ms - 0.26ms
preact-local2.46ms - 2.54msunsure 🔍
-3% - +2%
-0.07ms - +0.05ms
-faster ✔
5% - 10%
0.14ms - 0.26ms
preact-hooks2.66ms - 2.74msslower ❌
5% - 10%
0.13ms - 0.26ms
slower ❌
6% - 11%
0.14ms - 0.26ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.80ms - 0.80ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
3% - 4%
0.02ms - 0.04ms
preact-local0.80ms - 0.80msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
3% - 4%
0.02ms - 0.04ms
preact-hooks0.82ms - 0.84msslower ❌
3% - 5%
0.02ms - 0.04ms
slower ❌
3% - 4%
0.02ms - 0.04ms
-
todo

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main27.45ms - 27.90ms-unsure 🔍
-2% - +1%
-0.49ms - +0.36ms
faster ✔
1% - 4%
0.39ms - 1.04ms
preact-local27.39ms - 28.10msunsure 🔍
-1% - +2%
-0.36ms - +0.49ms
-faster ✔
1% - 4%
0.22ms - 1.08ms
preact-hooks28.15ms - 28.63msslower ❌
1% - 4%
0.39ms - 1.04ms
slower ❌
1% - 4%
0.22ms - 1.08ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.88ms - 0.88ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
3% - 3%
0.03ms - 0.03ms
preact-local0.88ms - 0.88msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
3% - 3%
0.03ms - 0.03ms
preact-hooks0.91ms - 0.91msslower ❌
3% - 3%
0.03ms - 0.03ms
slower ❌
3% - 3%
0.03ms - 0.03ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link

Size Change: +81 B (0%)

Total Size: 60.2 kB

Filename Size Change
dist/preact.js 4.55 kB +14 B (0%)
dist/preact.min.js 4.58 kB +14 B (0%)
dist/preact.min.module.js 4.58 kB +12 B (0%)
dist/preact.min.umd.js 4.61 kB +14 B (0%)
dist/preact.module.js 4.56 kB +13 B (0%)
dist/preact.umd.js 4.63 kB +14 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 4.05 kB 0 B
compat/dist/compat.module.js 3.98 kB 0 B
compat/dist/compat.umd.js 4.11 kB 0 B
debug/dist/debug.js 3.52 kB 0 B
debug/dist/debug.module.js 3.52 kB 0 B
debug/dist/debug.umd.js 3.6 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 315 B 0 B
hooks/dist/hooks.js 1.55 kB 0 B
hooks/dist/hooks.module.js 1.59 kB 0 B
hooks/dist/hooks.umd.js 1.63 kB 0 B
jsx-runtime/dist/jsxRuntime.js 963 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 938 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 1.04 kB 0 B
test-utils/dist/testUtils.js 453 B 0 B
test-utils/dist/testUtils.module.js 454 B 0 B
test-utils/dist/testUtils.umd.js 536 B 0 B

compressed-size-action

@coveralls
Copy link

coveralls commented Mar 19, 2024

Coverage Status

coverage: 99.468% (+0.001%) from 99.467%
when pulling 8f95e7e on yikes
into a784a62 on main.

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

nice find!

@JoviDeCroock JoviDeCroock merged commit 342b50e into main Mar 19, 2024
13 checks passed
@JoviDeCroock JoviDeCroock deleted the yikes branch March 19, 2024 18:13
@JoviDeCroock JoviDeCroock mentioned this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants