Closed Bug 1903980 Opened 4 months ago Closed 4 months ago

Blank DevTools when closing them while iframe is being destroyed

Categories

(DevTools :: General, defect, P2)

defect

Tracking

(firefox129 verified, firefox130 verified)

VERIFIED FIXED
129 Branch
Tracking Status
firefox129 --- verified
firefox130 --- verified

People

(Reporter: ochameau, Assigned: ochameau, NeedInfo)

References

(Blocks 2 open bugs, Regressed 1 open bug)

Details

Attachments

(4 files)

STR:

  • open any Google Doc or this stress test page data:text/html,<script>setInterval(()=>{document.body.innerHTML="";let iframe=document.createElement("iframe"); iframe.src="data:text/html,foo"; document.body.appendChild(iframe); },0);</script>
  • close and reopen devtools during google doc loading, or any time with the stress test

You will see the devtools become blank on closing with NS_ERROR_NOT_AVAILABLE) [nsIDocShell.domWindow] exception in stdout.
You then have to close the tab and reopen your debugged page in a new tab to be able to get functional devtools again.

Assignee: nobody → poirot.alex

The innerWindowId is used as an identifier for frame targets.
It ought to be unique and stable for a given target actor as this is used
in Resource forms as identifier for targets.

Also, getting a live getter may throw when accessing the window object's innerWindowId
when the document starts being destroyed (on iframe unload), but there is still relevant debugging
to be done against the WindowGlobal.

The checks in WindowGlobal Target Watchers were brittle as they were relying on the fact that
the WindowGlobalTargetActor's innerWindowId would be updated to the new WindowGlobal ID
when the BrowsingContext navigated to a new document. The findTargetActor method now uses
BrowsingContext ID to lookup for any existing Target Actor for the current BrowsingContext.
(this still uses WG innerWindowId for WG destruction codepath)

The docshell should be observed only when "EveryFrameTarget" is off for the WindowGlobal Target Actor.
i.e. when followWindowGlobalLifeCycle is false and the target actor manages more than one WindowGlobal.

This docshell observing was redundant with the code managing WindowGlobal target actor lifecycle in the WindowGlobal Target Watcher class.
Make the watcher class use the same event, docshell destruction == webnavigation-destroy,
as that is fired earlier than inner-window-destroyed.
Bug 1892411 will followup to use back the late inner-window-destroyed event and fix late breakpoints.
Before this patch, inner-window-destroyed event listener wasn't useful as the WindowGlobalTargetActor was self destroying itself
via its internal webnavigation-destroy event.

Without the previous changeset, DevTools may become blank and require to close the tab to be functional again.

See Also: → 1898490
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a33f0cac5d62 [devtools] Use a fixed innerWindowId for WindowGlobal Target Actor. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/30115e39cbbe [devtools] Only observe WindowGlobalTargetActor's children docshells for the browser toolbox and web extension debugging. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/dfc931e24fa6 [devtools] Test devtools closing while iframe are being destroyed. r=devtools-reviewers,nchevobbe

Backed out for causing mochitests failures in browser_ext_devtools_inspectedWindow_targetSwitch.js.

Flags: needinfo?(poirot.alex)

WindowGlobalTarget actors are currently being destroyed via
the docshell listeners registered by the WindowGlobalTargetActor class (_watchDocShells).
This is a bit unexpected as the WindowGlobal Watcher Class is meant to
handle the lifecycle (creation and destruction) of these actors.
On top of that, this docshell listener code (_watchDocShells) isn't really
meant to be executed. It's main goal is to implement the non-EFT(EveryFrameTarget)
codepath, where the WindowGlobalTarget actor may be focusing on more than one
WindowGlobal/document instance.

The situation here is that this code throws on creation as well as destruction,
leading to a broken target actor still registered in TargetRegistry/ContentProcessWatcherRegistry.

Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1de44f760746 [devtools] Test devtools closing while iframe are being destroyed. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/1ec92334e400 [devtools] Better handle short lived iframes. r=devtools-reviewers,nchevobbe
Regressions: 1904733
Blocks: 1904788
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch

Reproducible on a 2024-06-21 Nightly build on Windows 10.
Verified as fixed on Firefox 129.0b2 and Firefox Nightly 130.0a1 on Windows 10, Ubuntu 22, macOS 14.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: