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

Perf-Dashboard.Render sync phase sets location.hash, but the actual DOM modifications happen asynchronously in the onhashchange() callback. #488

Merged
merged 1 commit into from
Mar 1, 2025

Conversation

mattwoodrow
Copy link
Contributor

@mattwoodrow mattwoodrow commented Feb 17, 2025

This results in nothing interesting being measured during the sync phase, and the resulting rendering update (during the async phase) not including the change.

Change the test to manually and synchronously trigger the onhashchange() callback, and change the page content to detect and omit duplicate events.

Crossbench results before/after the change:

label                                       macos.arm64.local_0    macos.arm64.local_1    macos.arm64.local_2
browser                                     Firefox                Safari                 Google Chrome
version                                     135.0                  18.3 (20620.2.4)       133.0.6943.99
os                                          macos 15.3.1 arm64     macos 15.3.1 arm64     macos 15.3.1 arm64
device                                      MacBookPro18,2         MacBookPro18,2         MacBookPro18,2
cpu                                         Apple M1 Max 10 cores  Apple M1 Max 10 cores  Apple M1 Max 10 cores
runs                                        1                      1                      1
failed runs                                 0                      0                      0
Perf-Dashboard                              34.5                   33.9999999999995       29.539999999850988


Perf-Dashboard                              44.2                   40.2                   38.01000000089407

Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for webkit-speedometer ready!

Name Link
🔨 Latest commit f7cb31b
🔍 Latest deploy log https://app.netlify.com/sites/webkit-speedometer/deploys/67be2a583897a50008c928fa
😎 Deploy Preview https://deploy-preview-488--webkit-speedometer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

return;
if(unescapedHash == this._previousHash)
return;
this._previousHash = unescapedHash;
this.route();
this._hash = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not clear to me why this._hash is set to null here. In _updateURLState above it looks like we want to keep it synced with location.hash.
Then if we don't reset it, we probably don't need _previousHash and the check above would work, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, much simpler to do that. Fixed :)

modifications happen asynchronously in the onhashchange() callback.

This results in nothing interesting being measured during the sync phase, and
the resulting rendering update (during the async phase) not including the
change.

Change the test to manually and synchronously trigger the onhashchange()
callback, and change the page content to detect and omit duplicate events.
@mattwoodrow mattwoodrow force-pushed the perf-dashboard-sync-hashchange branch from f8884de to f7cb31b Compare February 25, 2025 20:38
@mattwoodrow mattwoodrow requested a review from julienw February 25, 2025 23:36
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

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

Thanks, this looks better to me.
I also looked with a firefox profiler, this clearly captures more work, which sounds good to me.

It would be too to have a sign-off from somebody at Apple who initially brought this in speedometer.

There's just one small correctness issue left to fix, I believe.

Thanks for the fix!

@@ -97,10 +97,11 @@ class PageRouter {

_hashDidChange()
{
if (unescape(location.hash) == this._hash)
let unescapedHash = unescape(location.hash);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want decodeURI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly? That's not new to this change though, I just added a local var to cache the result.

Copy link
Contributor

Choose a reason for hiding this comment

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

mmm right
If the hash doesn't have any encoded char this is OK, but I think this will be buggy as soon as you start having some. Probably we don't have any at the moment.

@rniwa rniwa merged commit c760d16 into WebKit:main Mar 1, 2025
8 checks passed
@flashdesignory
Copy link
Contributor

do we also want to merge the same changes into the 3.1 release branch?

@rniwa
Copy link
Member

rniwa commented Mar 1, 2025

Yeah, we should probably do that.

rniwa pushed a commit that referenced this pull request Mar 1, 2025
…OM (#488)

modifications happen asynchronously in the onhashchange() callback.

This results in nothing interesting being measured during the sync phase, and
the resulting rendering update (during the async phase) not including the
change.

Change the test to manually and synchronously trigger the onhashchange()
callback, and change the page content to detect and omit duplicate events.

Co-authored-by: Matt Woodrow <[email protected]>
@rniwa
Copy link
Member

rniwa commented Mar 1, 2025

Here's a PR to merge the fix into release/3.1: #496

rniwa added a commit that referenced this pull request Mar 3, 2025
…OM (#488) (#496)

modifications happen asynchronously in the onhashchange() callback.

This results in nothing interesting being measured during the sync phase, and
the resulting rendering update (during the async phase) not including the
change.

Change the test to manually and synchronously trigger the onhashchange()
callback, and change the page content to detect and omit duplicate events.

Co-authored-by: Matt Woodrow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants