Closed Bug 1547198 Opened 6 years ago Closed 11 months ago

Fire Runtime.executionContextDestroyed when the tab closes

Categories

(Remote Protocol :: CDP, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: ochameau, Unassigned)

References

Details

(Whiteboard: [puppeteer-beta2-mvp])

Attachments

(1 obsolete file)

The existing code out of bug 1543098 do try to send this event.
But unfortunately, this ContentProcessSession is being shutdown too early.

ContentProcessSession unregister the message manager here:
https://searchfox.org/mozilla-central/rev/75294521381b331f821aad3d6b60636844080ee2/remote/sessions/ContentProcessSession.jsm#24-27

When the parent process TabSession request to do so from here:
https://searchfox.org/mozilla-central/rev/75294521381b331f821aad3d6b60636844080ee2/remote/sessions/TabSession.jsm#45-47

Which is ultimately call from a TabClose event via Target and Session:
https://searchfox.org/mozilla-central/source/remote/RemoteAgent.jsm#51-53

The TabClose event actually fires early when we just start destroying the tab.
The code from bug 1543098 is still having time to try to emit the executionContextDestroyed event, but as the message manager listeners are unregistered, the packet isn't forwarded.

So may be we could find another event to destroy the target, sligthly more late than TabClose? Otherwise, it means that the parent process code should ensure firing this event.

Component: Agent → Runtime

(In reply to Alexandre Poirot [:ochameau] from comment #0)

So may be we could find another event to destroy the target,
sligthly more late than TabClose? Otherwise, it means that the
parent process code should ensure firing this event.

Perhaps we could listen for the content browser’s message manager
disconnecting?

I can’t remember off the top of my head if that fires before or
after TabClose.

nika: Is there any new event in the platform code that fires when a
browsing context is discarded?

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
Flags: needinfo?(nika)
Priority: -- → P1

(In reply to Andreas Tolfsen ⦗:ato⦘ from comment #2)

(In reply to Alexandre Poirot [:ochameau] from comment #0)

So may be we could find another event to destroy the target,
sligthly more late than TabClose? Otherwise, it means that the
parent process code should ensure firing this event.

Perhaps we could listen for the content browser’s message manager
disconnecting?

I can’t remember off the top of my head if that fires before or
after TabClose.

nika: Is there any new event in the platform code that fires when a
browsing context is discarded?

We don't currently fire an observer notification when a BrowsingContext is fully destroyed IIRC. You should be able to listen to ipc:browser-destroyed to detect when the BrowserParent object is destroyed.

With process switches, however, this will be fired during process changes as well.

https://searchfox.org/mozilla-central/rev/b59a99943de4dd314bae4e44ab43ce7687ccbbec/dom/ipc/BrowserParent.cpp#537-540

Flags: needinfo?(nika)
Assignee: poirot.alex → nobody
Status: ASSIGNED → NEW
Priority: P1 → P2

Looks like we forgot to prioritize it. While this event shows high usage, in combination with closing a tab, it might be not that important. Adding it as a reserved bug but keeping it as P3 for now.

Priority: P2 → P3
Whiteboard: [puppeteer-beta-reserve]
Attachment #9060916 - Attachment is obsolete: true
Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta2-mvp]
Component: CDP: Runtime → CDP
Severity: normal → S3

This is a feature that already exists in WebDriver BiDi and we are not going to add it to CDP.

Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: