Skip to content

[reactive-element] fixes inconsistent initial values in changed properties#4949

Merged
sorvell merged 4 commits intomainfrom
changed-properties-initial
Apr 2, 2025
Merged

[reactive-element] fixes inconsistent initial values in changed properties#4949
sorvell merged 4 commits intomainfrom
changed-properties-initial

Conversation

@sorvell
Copy link
Member

@sorvell sorvell commented Mar 21, 2025

Fixes #4916

@sorvell sorvell requested a review from justinfagnani March 21, 2025 14:19
@sorvell sorvell requested a review from kevinpschaaf as a code owner March 21, 2025 14:20
@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2025

🦋 Changeset detected

Latest commit: ecb081a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@lit/reactive-element Patch
lit Patch
lit-element Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2025

📊 Tachometer Benchmark Results

Summary

nop-update

  • this-change, tip-of-tree, previous-release: unsure 🔍 -7% - +11% (-0.88ms - +1.34ms)
    this-change vs tip-of-tree

render

  • this-change: 43.36ms - 52.18ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -7% - +0% (-1.35ms - +0.03ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -3% - +1% (-0.97ms - +0.41ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +65% (+1.01ms - +30.64ms)
    this-change vs tip-of-tree

update

  • this-change: 478.10ms - 482.00ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -6% - +1% (-2.46ms - +0.47ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +2% (-1.37ms - +1.16ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: faster ✔ 0% - 2% (0.79ms - 11.98ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 472.85ms - 477.01ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +2% (-3.94ms - +9.96ms)
    this-change vs tip-of-tree

Results

this-change

render

VersionAvg timevs
43.36ms - 52.18ms-

update

VersionAvg timevs
478.10ms - 482.00ms-

update-reflect

VersionAvg timevs
472.85ms - 477.01ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
18.63ms - 19.37ms-unsure 🔍
-7% - +0%
-1.35ms - +0.03ms
unsure 🔍
-4% - +1%
-0.85ms - +0.24ms
tip-of-tree
tip-of-tree
19.07ms - 20.23msunsure 🔍
-0% - +7%
-0.03ms - +1.35ms
-unsure 🔍
-2% - +5%
-0.35ms - +1.05ms
previous-release
previous-release
18.91ms - 19.70msunsure 🔍
-1% - +4%
-0.24ms - +0.85ms
unsure 🔍
-5% - +2%
-1.05ms - +0.35ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
36.06ms - 38.35ms-unsure 🔍
-6% - +1%
-2.46ms - +0.47ms
unsure 🔍
-7% - +1%
-2.54ms - +0.37ms
tip-of-tree
tip-of-tree
37.29ms - 39.11msunsure 🔍
-1% - +7%
-0.47ms - +2.46ms
-unsure 🔍
-4% - +3%
-1.37ms - +1.20ms
previous-release
previous-release
37.38ms - 39.19msunsure 🔍
-1% - +7%
-0.37ms - +2.54ms
unsure 🔍
-3% - +4%
-1.20ms - +1.37ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
11.62ms - 13.15ms-unsure 🔍
-7% - +11%
-0.88ms - +1.34ms
unsure 🔍
-14% - +2%
-1.87ms - +0.34ms
tip-of-tree
tip-of-tree
11.35ms - 12.96msunsure 🔍
-11% - +7%
-1.34ms - +0.88ms
-unsure 🔍
-16% - +1%
-2.13ms - +0.14ms
previous-release
previous-release
12.35ms - 13.94msunsure 🔍
-3% - +15%
-0.34ms - +1.87ms
unsure 🔍
-2% - +18%
-0.14ms - +2.13ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
35.33ms - 36.01ms-unsure 🔍
-3% - +1%
-0.97ms - +0.41ms
unsure 🔍
-1% - +1%
-0.40ms - +0.47ms
tip-of-tree
tip-of-tree
35.35ms - 36.55msunsure 🔍
-1% - +3%
-0.41ms - +0.97ms
-unsure 🔍
-1% - +3%
-0.34ms - +0.98ms
previous-release
previous-release
35.36ms - 35.91msunsure 🔍
-1% - +1%
-0.47ms - +0.40ms
unsure 🔍
-3% - +1%
-0.98ms - +0.34ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
67.79ms - 69.72ms-unsure 🔍
-2% - +2%
-1.37ms - +1.16ms
unsure 🔍
-1% - +2%
-0.63ms - +1.58ms
tip-of-tree
tip-of-tree
68.03ms - 69.67msunsure 🔍
-2% - +2%
-1.16ms - +1.37ms
-unsure 🔍
-1% - +2%
-0.41ms - +1.56ms
previous-release
previous-release
67.74ms - 68.82msunsure 🔍
-2% - +1%
-1.58ms - +0.63ms
unsure 🔍
-2% - +1%
-1.56ms - +0.41ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
54.30ms - 77.28ms-unsure 🔍
-2% - +65%
+1.01ms - +30.64ms
unsure 🔍
-16% - +40%
-8.85ms - +22.54ms
tip-of-tree
tip-of-tree
40.60ms - 59.32msfaster ✔
5% - 44%
1.01ms - 30.64ms
-unsure 🔍
-37% - +7%
-23.20ms - +5.23ms
previous-release
previous-release
48.25ms - 69.65msunsure 🔍
-33% - +12%
-22.54ms - +8.85ms
unsure 🔍
-13% - +49%
-5.23ms - +23.20ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
478.12ms - 486.18ms-faster ✔
0% - 2%
0.79ms - 11.98ms
unsure 🔍
-2% - +1%
-7.97ms - +4.27ms
tip-of-tree
tip-of-tree
484.65ms - 492.42msslower ❌
0% - 2%
0.79ms - 11.98ms
-unsure 🔍
-0% - +2%
-1.49ms - +10.56ms
previous-release
previous-release
479.39ms - 488.60msunsure 🔍
-1% - +2%
-4.27ms - +7.97ms
unsure 🔍
-2% - +0%
-10.56ms - +1.49ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
495.16ms - 503.01ms-unsure 🔍
-1% - +2%
-3.94ms - +9.96ms
unsure 🔍
-1% - +2%
-2.97ms - +7.67ms
tip-of-tree
tip-of-tree
490.34ms - 501.81msunsure 🔍
-2% - +1%
-9.96ms - +3.94ms
-unsure 🔍
-1% - +1%
-7.43ms - +6.10ms
previous-release
previous-release
493.15ms - 500.33msunsure 🔍
-2% - +1%
-7.67ms - +2.97ms
unsure 🔍
-1% - +1%
-6.10ms - +7.43ms
-

tachometer-reporter-action v2 for Benchmarks

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2025

The size of lit-html.js and lit-core.min.js are as expected.

@sorvell
Copy link
Member Author

sorvell commented Mar 24, 2025

@freshp86 can you help verify that this version would address the issues you're seeing? Thanks.

@freshp86
Copy link

@freshp86 can you help verify that this version would address the issues you're seeing? Thanks.

Will give it a shot and report back, but unfortunately trying non-released versions of Lit within local Chromium builds is not very straight forward.

@freshp86
Copy link

@freshp86 can you help verify that this version would address the issues you're seeing? Thanks.

Will give it a shot and report back, but unfortunately trying non-released versions of Lit within local Chromium builds is not very straight forward.

I have checked out Lit, patched this PR, and successfully ran npm run build locally. Having said that, in order to try this change in the context of Chromium I need to recreate the files that are distributed by npm install lit and I can't find them. If you can help me recreate those files locally, then I can try verifying whether these fixes are sufficient for our case. Thanks!

@sorvell
Copy link
Member Author

sorvell commented Mar 26, 2025

If you can help me recreate those files locally

For quick testing, maybe you can just copy the ReactiveElement and LitElement out and make your base class extend from those?

@freshp86
Copy link

freshp86 commented Mar 26, 2025

For quick testing, maybe you can just copy the ReactiveElement and LitElement out and make your base class extend from those?

Thanks! I have partially verified that these would work for us. For the record here is how I went about it.

  • Checked out Lit locally, patched this PR, and succesfully ran npm run build
  • Copied the generated packages/reactive-element/reactive-element.js file to Chromium's third_party/node/node_modules/@lit/reactive-element/reactive-element.js.
  • Copied the generated packages/lit-element/lit-element.js file to Chromium's third_party/node/node_modules/lit-element/lit-element.js .
  • Note that we still use "lit": "3.0.2" in our package.json, so the files above have been copied on top of that version.
  • Reverted the workarounds we added at https://chromium-review.googlesource.com/c/chromium/src/+/6349561 and https://chromium-review.googlesource.com/c/chromium/src/+/6373768 (did not revert the updated tests for CrLitElement class)
  • Re-built our tests and ran all CrLitElement tests which passed.

I am not able to actually spawn our trybots with the modified Lit in Chromium's third_party/, to run all of the tests with these changes, so there is still a chance something might have been missed if not covered by the CrLitElement unit tests, but the fact that CrLitElement tests are passing with the workarounds reverted seems very promising.

@sorvell sorvell merged commit 3e2f87f into main Apr 2, 2025
9 checks passed
@sorvell sorvell deleted the changed-properties-initial branch April 2, 2025 16:43
@lit-robot lit-robot mentioned this pull request Apr 10, 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.

[reactive-element] Initial changed properties can be inconsistent

3 participants