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

Skip to content

Conversation

@justinfagnani
Copy link
Collaborator

We're getting questions about why ResizeController causes two consecutive host updates. It seems like ResizeObservers already call the observer callback unconditionally, so our code to do that as well made there be two updates. Can we just remove our custom initial call to handleChanges? This would let us remove skipInitial altogether.

wdyt @sorvell ?

@justinfagnani justinfagnani requested a review from sorvell March 30, 2023 19:05
@changeset-bot
Copy link

changeset-bot bot commented Mar 30, 2023

⚠️ No Changeset found

Latest commit: 25dddb8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 30, 2023

📊 Tachometer Benchmark Results

Summary

  • reactive-element-list

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -6% - +2% (-1.36ms - +0.53ms)
    this-change vs tip-of-tree

render

  • lit-element-list: 108.97ms - 113.37ms
  • lit-html-kitchen-sink: unsure 🔍 -5% - +7% (-2.48ms - +3.23ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -7% - +6% (-1.06ms - +0.87ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +2% (-2.38ms - +1.43ms)
    this-change vs tip-of-tree

update

  • lit-element-list: 1156.04ms - 1175.68ms
  • lit-html-kitchen-sink: unsure 🔍 -3% - +5% (-3.29ms - +5.27ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -13% - +9% (-54.24ms - +35.10ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -4% - +1% (-6.21ms - +1.96ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: 1122.97ms - 1140.49ms

Results

lit-element-list

render

VersionAvg timevs
108.97ms - 113.37ms-

update

VersionAvg timevs
1156.04ms - 1175.68ms-

update-reflect

VersionAvg timevs
1122.97ms - 1140.49ms-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
45.33ms - 49.42ms-unsure 🔍
-5% - +7%
-2.48ms - +3.23ms
unsure 🔍
-3% - +8%
-1.22ms - +3.78ms
tip-of-tree
tip-of-tree
45.01ms - 48.99msunsure 🔍
-7% - +5%
-3.23ms - +2.48ms
-unsure 🔍
-3% - +7%
-1.55ms - +3.36ms
previous-release
previous-release
44.66ms - 47.53msunsure 🔍
-8% - +2%
-3.78ms - +1.22ms
unsure 🔍
-7% - +3%
-3.36ms - +1.55ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
108.13ms - 114.76ms-unsure 🔍
-3% - +5%
-3.29ms - +5.27ms
unsure 🔍
-5% - +4%
-5.54ms - +4.96ms
tip-of-tree
tip-of-tree
107.74ms - 113.16msunsure 🔍
-5% - +3%
-5.27ms - +3.29ms
-unsure 🔍
-5% - +3%
-6.17ms - +3.60ms
previous-release
previous-release
107.67ms - 115.80msunsure 🔍
-4% - +5%
-4.96ms - +5.54ms
unsure 🔍
-3% - +6%
-3.60ms - +6.17ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
20.90ms - 21.73ms-unsure 🔍
-6% - +2%
-1.36ms - +0.53ms
unsure 🔍
-3% - +3%
-0.70ms - +0.65ms
tip-of-tree
tip-of-tree
20.88ms - 22.58msunsure 🔍
-2% - +6%
-0.53ms - +1.36ms
-unsure 🔍
-3% - +7%
-0.61ms - +1.40ms
previous-release
previous-release
20.80ms - 21.88msunsure 🔍
-3% - +3%
-0.65ms - +0.70ms
unsure 🔍
-6% - +3%
-1.40ms - +0.61ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
13.77ms - 15.26ms-unsure 🔍
-7% - +6%
-1.06ms - +0.87ms
unsure 🔍
-6% - +8%
-0.80ms - +1.13ms
tip-of-tree
tip-of-tree
14.00ms - 15.22msunsure 🔍
-6% - +7%
-0.87ms - +1.06ms
-unsure 🔍
-4% - +8%
-0.60ms - +1.12ms
previous-release
previous-release
13.75ms - 14.96msunsure 🔍
-8% - +5%
-1.13ms - +0.80ms
unsure 🔍
-8% - +4%
-1.12ms - +0.60ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
359.49ms - 419.24ms-unsure 🔍
-13% - +9%
-54.24ms - +35.10ms
unsure 🔍
-11% - +10%
-43.75ms - +38.45ms
tip-of-tree
tip-of-tree
365.72ms - 432.15msunsure 🔍
-9% - +14%
-35.10ms - +54.24ms
-unsure 🔍
-9% - +13%
-36.66ms - +50.51ms
previous-release
previous-release
363.79ms - 420.24msunsure 🔍
-10% - +11%
-38.45ms - +43.75ms
unsure 🔍
-13% - +9%
-50.51ms - +36.66ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
72.56ms - 75.07ms-unsure 🔍
-3% - +2%
-2.38ms - +1.43ms
unsure 🔍
-3% - +2%
-2.59ms - +1.15ms
tip-of-tree
tip-of-tree
72.86ms - 75.72msunsure 🔍
-2% - +3%
-1.43ms - +2.38ms
-unsure 🔍
-3% - +2%
-2.24ms - +1.74ms
previous-release
previous-release
73.15ms - 75.93msunsure 🔍
-2% - +4%
-1.15ms - +2.59ms
unsure 🔍
-2% - +3%
-1.74ms - +2.24ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
155.36ms - 160.78ms-unsure 🔍
-4% - +1%
-6.21ms - +1.96ms
unsure 🔍
-4% - +2%
-5.91ms - +3.45ms
tip-of-tree
tip-of-tree
157.14ms - 163.25msunsure 🔍
-1% - +4%
-1.96ms - +6.21ms
-unsure 🔍
-3% - +4%
-4.00ms - +5.79ms
previous-release
previous-release
155.48ms - 163.12msunsure 🔍
-2% - +4%
-3.45ms - +5.91ms
unsure 🔍
-4% - +2%
-5.79ms - +4.00ms
-

tachometer-reporter-action v2 for Benchmarks

@sorvell
Copy link
Member

sorvell commented Mar 30, 2023

Yeah, I think this stemmed from the fact that the other observers don't have an initial report.

Couple observations. These tests appear to be wrong here since the skipInitial test should be failing. I think it's because we're not waiting until ResizeObserver triggers (fix: maybe just change the await here to be resizeComplete:

).

I'd like to preserve the skipInitial setting since we have that on the other observers. To do so we could just do something like in the main observer callback (

this._observer = new ResizeObserver((entries: ResizeObserverEntry[]) => {
):

  1. have a canObserve flag that's true if skipInitial is true
  2. and any processing is gated on that
  3. it becomes true after await host.updateComplete

@AndrewJakubowicz AndrewJakubowicz self-assigned this Apr 26, 2023
@AndrewJakubowicz
Copy link
Contributor

After fixing the tests and applying the skipInitial setting in the same way that IntersectionController does it, we end up with all tests passing except Safari. This is due to WebKit not calling the callback on observe at the moment. They are working on changing the behavior to match Chrome and Firefox. See: webcompat/web-bugs#117611 (comment)

@justinfagnani
Copy link
Collaborator Author

@AndrewJakubowicz is there a way to detect the browser not calling the callback on observe()? Is that initial call synchronous by any chance?

@AndrewJakubowicz
Copy link
Contributor

It is not synchronous. The first observe callback runs some time after observe is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants