-
Notifications
You must be signed in to change notification settings - Fork 30
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
Measuring beforeunload
#190
Comments
I just tried a few experiments, but I'm just learning here and may be making mistakes:
Here is what I think that all looks like: I think that diagram, which is already the state of measures today (~event timing change), feels correct to me. If the previous document delays loading the next document, it should count towards LCP -- but that seems only possible for Same Origin navigations already. If redirects delay a Cross Origin navigation, that's tricky but we already have separate issues tracking choices there. There seems to be a reporting gap to measure final INP -- which gets smaller if we change Event Timing to hard stop at beforeunload processingEnd. Then, the previous page could use PerformanceObserver.takeRecords as part of its last beacon. The problem I see is: we are recommending visibilitychange as the reliable way to send a final beacon, but that doesn't work reliably. The other events have other reliability issues especially mobile. Useful background If all of that is correct, I think the question becomes: How can we reliably report final Event Timing data that lead to page unload? ...and not to consider this part of navigation timing. |
That's an amazing diagram!! Thank you! :)
I agree this is not necessarily a navigation timing issue. We can move this to a more appropriate repo when we see fit. |
It's a while since I last looked at this in detail but in 2018 the overhead of beforeunload handlers was non trivial There's some examples on this slide https://noti.st/andydavies/oW1edg/ab-testing-ads-other-3rd-party-tags#sRX5BLv |
The current timeorigin is set when a the navigation request fetch starts, in between
beforeunload
and theunload
event. As a result of that, there's some a timespan between the hardware timestamp of the user's interaction that navigates away and the next navigation that's kinda hard to measure today, even on the same origin.Arguably, this is measurable using LT/LoAF+EventTiming, but if the user's navigation is delayed on main thread activity that delays the
click
event or thebeforeunload
event or the event handlers themselves, that's unlikely to be captured by a PerformanceObserver before the page navigates away.Given that, it seems like we could measure the last click HW timestamp -> next nav fetch or unload as a separate measurement. How we report it may be tricky though. A few options:
The text was updated successfully, but these errors were encountered: