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

Prevent memo'd components that unsuspend from bailing #4711

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

CaptainWang98
Copy link
Contributor

@CaptainWang98 CaptainWang98 commented Feb 26, 2025

Set Memo Component to when unsuspending _force so when the subsequent render arrives there is no possibility of bailing out of the render pass.

fixes #4631

Copy link

github-actions bot commented Feb 26, 2025

📊 Tachometer Benchmark Results

Summary

⏳ Benchmarks are currently running. Results below are out of date.

duration

  • create10k: unsure 🔍 -0% - +1% (-0.48ms - +6.21ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +1% (-0.11ms - +0.10ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.46ms - +0.93ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +1% (-0.07ms - +0.24ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +0% (-0.84ms - +0.31ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +5% (-0.10ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.48ms - +0.47ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -4% - +5% (-1.09ms - +1.43ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.02ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +1% (-0.01ms - +0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -5% - +5% (-0.48ms - +0.48ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +0% (-0.03ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +1% (-0.00ms - +0.02ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +4% (-0.02ms - +0.05ms)
    preact-local vs preact-main
  • update10th1k: slower ❌ 0% - 2% (0.01ms - 0.05ms)
    preact-local vs preact-main

Results

⏳ Benchmarks are currently running. Results below are out of date.
create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local932.22ms - 936.98ms-unsure 🔍
-0% - +1%
-0.48ms - +6.21ms
preact-main929.39ms - 934.08msunsure 🔍
-1% - +0%
-6.21ms - +0.48ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.18ms - 19.20ms-unsure 🔍
-0% - +0%
-0.02ms - +0.01ms
preact-main19.18ms - 19.21msunsure 🔍
-0% - +0%
-0.01ms - +0.02ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.47ms - 16.67ms-unsure 🔍
-1% - +1%
-0.11ms - +0.10ms
preact-main16.55ms - 16.61msunsure 🔍
-1% - +1%
-0.10ms - +0.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.53ms - 1.56ms-unsure 🔍
-1% - +1%
-0.01ms - +0.02ms
preact-main1.53ms - 1.55msunsure 🔍
-1% - +1%
-0.02ms - +0.01ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local74.63ms - 76.57ms-unsure 🔍
-2% - +1%
-1.46ms - +0.93ms
preact-main75.15ms - 76.57msunsure 🔍
-1% - +2%
-0.93ms - +1.46ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local9.29ms - 9.91ms-unsure 🔍
-5% - +5%
-0.48ms - +0.48ms
preact-main9.24ms - 9.96msunsure 🔍
-5% - +5%
-0.48ms - +0.48ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.48ms - 16.60ms-unsure 🔍
-0% - +1%
-0.07ms - +0.24ms
preact-main16.31ms - 16.60msunsure 🔍
-1% - +0%
-0.24ms - +0.07ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.76ms - 3.79ms-unsure 🔍
-1% - +0%
-0.03ms - +0.01ms
preact-main3.77ms - 3.80msunsure 🔍
-0% - +1%
-0.01ms - +0.03ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4589
  • Commit: dfc9c2f

duration

VersionAvg timevs preact-localvs preact-main
preact-local65.76ms - 66.57ms-unsure 🔍
-1% - +0%
-0.84ms - +0.31ms
preact-main66.03ms - 66.83msunsure 🔍
-0% - +1%
-0.31ms - +0.84ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.98ms - 3.00ms-unsure 🔍
-0% - +1%
-0.00ms - +0.02ms
preact-main2.98ms - 2.98msunsure 🔍
-1% - +0%
-0.02ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local29.66ms - 30.19ms-unsure 🔍
-2% - +1%
-0.58ms - +0.19ms
preact-main29.84ms - 30.40msunsure 🔍
-1% - +2%
-0.19ms - +0.58ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local34.12ms - 35.27ms-unsure 🔍
-2% - +3%
-0.61ms - +0.92ms
preact-main34.04ms - 35.04msunsure 🔍
-3% - +2%
-0.92ms - +0.61ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local25.59ms - 25.97ms-unsure 🔍
-1% - +1%
-0.13ms - +0.38ms
preact-main25.49ms - 25.83msunsure 🔍
-1% - +1%
-0.38ms - +0.13ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.71ms - 27.30ms-unsure 🔍
-2% - +1%
-0.67ms - +0.19ms
preact-main26.93ms - 27.55msunsure 🔍
-1% - +2%
-0.19ms - +0.67ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local27.34ms - 28.00ms-unsure 🔍
-1% - +2%
-0.32ms - +0.61ms
preact-main27.20ms - 27.85msunsure 🔍
-2% - +1%
-0.61ms - +0.32ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.11ms - 20.50ms-unsure 🔍
-2% - +1%
-0.41ms - +0.14ms
preact-main20.24ms - 20.64msunsure 🔍
-1% - +2%
-0.14ms - +0.41ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.03ms - 2.19ms-unsure 🔍
-5% - +5%
-0.10ms - +0.10ms
preact-main2.05ms - 2.17msunsure 🔍
-5% - +5%
-0.10ms - +0.10ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.12ms - 1.12ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main1.12ms - 1.12msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local34.60ms - 35.41ms-unsure 🔍
-1% - +1%
-0.48ms - +0.47ms
preact-main34.76ms - 35.25msunsure 🔍
-1% - +1%
-0.47ms - +0.48ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.27ms - 1.32ms-unsure 🔍
-1% - +4%
-0.02ms - +0.05ms
preact-main1.26ms - 1.30msunsure 🔍
-4% - +1%
-0.05ms - +0.02ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.23ms - 32.12ms-unsure 🔍
-4% - +5%
-1.09ms - +1.43ms
preact-main30.17ms - 31.83msunsure 🔍
-5% - +3%
-1.43ms - +1.09ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.95ms - 2.99ms-slower ❌
0% - 2%
0.01ms - 0.05ms
preact-main2.94ms - 2.95msfaster ✔
0% - 2%
0.01ms - 0.05ms
-

tachometer-reporter-action v2 for CI

Comment on lines 61 to 62
// issue #4631
if (vnode.type.name === 'Memoed') vnode._component._force = true;
Copy link
Member

@JoviDeCroock JoviDeCroock Feb 26, 2025

Choose a reason for hiding this comment

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

Suggested change
// issue #4631
if (vnode.type.name === 'Memoed') vnode._component._force = true;
vnode._component._force = true;

Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

This does not fix #3449 yet, for that you would need a different mechanism in error-boundaries. That being said this also needs tests

@CaptainWang98
Copy link
Contributor Author

Thanks
I'll check #3449 later and create a new PR.

@CaptainWang98 CaptainWang98 marked this pull request as ready for review February 26, 2025 12:23
Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

There are no tests asserting that the behaviour is corrected, also see my comment, there is no need for the comment nor for making this exclusive to memoed as this would also trigger for normal sCU components

@@ -2159,4 +2160,38 @@ describe('suspense', () => {
expect(scratch.innerHTML).to.equal('<div><p>hello world</p></div>');
});
});

it('should correctly render memod child component', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This test does not test the behaviour, it even passes on main. You might want to look at the reproduction to more closely reproduce the failure. Currently this component renders successfully and retains said state, what we want to assert is that it can attain new state

@coveralls
Copy link

coveralls commented Mar 5, 2025

Coverage Status

coverage: 99.61%. remained the same
when pulling 46cd53e on CaptainWang98:fix_4631
into f35272e on preactjs:main.

@CaptainWang98
Copy link
Contributor Author

@JoviDeCroock Hi there, could you plz check this pr? Thanks for your time~

@JoviDeCroock JoviDeCroock changed the title fix: Memoed Component bails while detached Prevent memo'd components that unsuspend from bailing Mar 20, 2025
@JoviDeCroock JoviDeCroock merged commit 29b0021 into preactjs:main Mar 20, 2025
12 checks passed
@JoviDeCroock JoviDeCroock mentioned this pull request Mar 20, 2025
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.

useEffect didn't run in some rare case (lazy + memo)
3 participants