Open Bug 1373694 Opened 2 years ago Updated 2 years ago

Don't block on beforeunload events from third-party tracking domain scripts

Categories

(Core :: DOM: Events, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mconley, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [qf:p3])

Here's a profile where the parent process had to message the child to run beforeunload (and check if the unload should be cancelled) because a beforeunload event handler had been set in a tracking script from edgekey.net:

https://perf-html.io/public/38e1e8bd485695eac865c9f3dfc863128d87a514/calltree/?implementation=js&invertCallstack&range=3.8243_4.0831&thread=5

We're already doing work to throttle down setTimeouts in tracking scripts... can we also not have the parent message the content process if the beforeunload event handlers are being set from a tracking domain script?

We'll still run the beforeunload event handlers, but we won't _block_ the tab closing on it. What I'm suggesting here is that we make it so that tracking domain scripts cannot block tabs or windows from closing.
Whiteboard: [qf][photon-performance]
Whiteboard: [qf][photon-performance] → [qf][photon-performance] [triage]
I don't understand what running the handler without blocking tab closing on it means.  Can you please elaborate?

The last sentence of comment 0 seems to break web pages.  Note that tracking scripts can come from highly popular sites like Facebook or Twitter!
(In reply to :Ehsan Akhgari (needinfo please, extremely long backlog) from comment #1)
> I don't understand what running the handler without blocking tab closing on
> it means.  Can you please elaborate?

From my understanding it means letting the web page do a sync XHR before we remove it from memory, but make the tab close immediately in the UI without offering an opportunity to show a confirm prompt.
Flags: qe-verify-
Priority: -- → P2
Whiteboard: [qf][photon-performance] [triage] → [qf][photon-performance]
Summary: Don't block on beforeunload events from tracking domain scripts → Don't block on beforeunload events from third-party tracking domain scripts
Whiteboard: [qf][photon-performance] → [qf:p3][photon-performance]
Priority: P2 → P3
Whiteboard: [qf:p3][photon-performance] → [qf:p3][reserve-photon-performance]
Priority: P3 → P4
Hi Marco, we don't use P4 for DOM bugs. We use P3 (backlog) and P5 (not plan to fix it but happy to take a patch). Do you think we could remap your P4 into either of them? Thank you.
Flags: needinfo?(mmucci)
Flags: needinfo?(mmucci)
Whiteboard: [qf:p3][reserve-photon-performance] → [qf:p3]
Priority: P4 → P3
Keywords: perf
You need to log in before you can comment on or make changes to this bug.