-
Notifications
You must be signed in to change notification settings - Fork 110
Prevent submitting URL Metric if viewport size changed #1712
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
Merged
westonruter
merged 2 commits into
trunk
from
fix/od-abort-url-metrics-submission-on-viewport-size-change
Dec 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From @felixarntz in #1697 (comment):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awaiting an answer to this question, otherwise LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it cannot be moved up. Note the immediately preceding code:
performance/plugins/optimization-detective/detect.js
Lines 497 to 511 in a5bd367
Recall that the URL Metric is now sent when someone leaves the page, not as soon as the page is fully loaded. So data is collected up until the moment someone leaves the page, and if at this moment we see that the page is not the same dimensions, then we abort sending the URL Metric.
That said, I realize that a
resize
event listener would be more robust, as it could be that someone resizes the window once the page has loaded, and then before leaving they resize it back to the original size. That wouldn't be detected as it is here. I've implementedresize
event in e222c85.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixarntz Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter Makes sense. I wonder though, would there be other tasks here that could be deferred to when leaving the page so that they don't run unnecessarily? For example some of the LCP element logic that runs before then as far as I can see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although I think if we wait until this point to call
onLCP()
I'd worry about increasing the amount of time needing to be spent at thispagehide
phase and risk the browser killing the tasks before it gets a chance to send the beacon. But I think that is something that we can investigate further in a follow-up.