-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
DBW: use navigator.sendBeacon in beforeunload/pagehide handlers #871
Comments
@ebidel I looked at this for a while today, and wanted to ping you about a couple of things. filename for the audit?
Watching network requests
Cheers |
"uses-sendbeacon" sgtm. For the network stuff, it looks like something clever like this could work. I didn't realize you could dispatching
You could wrap the observer and dispatching part in a function that gets injected into the page. Example. You might need to play around with delaying dispatching the events. This would't tell you that the XHR was sync (unless you also grep the console output for the warning chrome throws when sync xhrs are used), but I don't think it would hurt to always suggest |
Does this need to be instrumented in the page itself? Instead, could you look at the initiator field in the trace event log and detect any !beacon requests initiated after unload? PerfObserver does not guarantee synchronous delivery of these events, and since page is being unloaded, there is high likelihood that you may miss requests with the above pattern -- e.g. inject an image beacon and allow page to continue unloading, etc. |
Just looking at the The other thing we miss out on with using the network trace is line/col/source info: |
@igrigorik I also found that |
Yes, they should. Sounds like a bug. If you have a test page.. can you please file a bug? |
@ebidel @igrigorik is this something I can tackle without |
@olingern the bug with I'd experiment with the technique I highlighted in #871 (comment) to see if we catch Definitely add some tests to https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html and let us know. |
Need to get a complete new audit proposal on this one: https://github.com/GoogleChrome/lighthouse/blob/master/docs/new-audits.md It's definitely worthwhile, but will take some work. |
in m75, sync xhr in "page dismissal" is attempted to be removed. I'm pretty sure there is a console.log/violation we could use. Seems good, though we'd have to dismiss the page during gathering. We could try to fire their handlers, though.. But if this removal sticks, then it already did our job for us. |
|
How to check:
beforeunload
/pagehide
handlers (can reuse https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/dobetterweb/document-event-listeners.js)fetch
calls in the handlerhttps://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
The text was updated successfully, but these errors were encountered: