Closed Bug 1566870 Opened 9 months ago Closed 9 months ago

Mochitests window leaks when focusing input elements when DevTools runs in a content frame

Categories

(DevTools :: General, task, P2)

task

Tracking

(Fission Milestone:M4, firefox70 fixed)

RESOLVED FIXED
Firefox 70
Fission Milestone M4
Tracking Status
firefox70 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

I am trying to fix the last few failures we have when running DevTools in a frame with type = content.

One of the recurring failures only occurs in debug mode, when a mochitest focuses an <input type="text"> in one of our panels.

This only happens if the input is in a HTML panel.
If the panel uses XHTML or if the input is directly in the toolbox's XUL document, no leaks.

So the setup that fails is:

<iframe src="about:devtools-toolbox"> <-- loads toolbox.xul
  <iframe src="chrome://devtools/content/somepanel/index.html">
    <input type="text">

So far, I have isolated the issue with a minimal devtools panel, I'll try to isolate it further without devtools.

The leaks reported are

 0:18.98 ERROR TEST-UNEXPECTED-FAIL | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | leaked 2 window(s) until shutdown [url = about:devtools-toolbox]
 0:18.98 ERROR TEST-UNEXPECTED-FAIL | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | leaked 1 window(s) until shutdown [url = about:blank]
 0:18.98 ERROR TEST-UNEXPECTED-FAIL | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | leaked 1 window(s) until shutdown [url = chrome://devtools/content/testpanel/index.html]
 0:18.98 INFO TEST-INFO | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | windows(s) leaked: [pid = 1481] [serial = 18], [pid = 1481] [serial = 15], [pid = 1481] [serial = 20], [pid = 1481] [serial = 19]
 0:18.98 INFO TEST-INFO | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | This test created 0 hidden window(s)
 0:18.98 INFO TEST-INFO | devtools/client/testpanel/test/browser/browser_testpanel_focusinput.js | This test created 1 hidden docshell(s)
 0:18.98 INFO runtests.py | Application ran for: 0:00:17.874468

Full log of a basic test at https://gist.github.com/juliandescottes/bf77a5b82c69d6ef559682893fc7d445

Hi Nika,

I see window leaks in debug mochitests which focus inputs when devtools run in a content frame, when the input is loaded in a HTML document (see summary for more info).
While I keep investigating, does this issue ring a bell by any chance?

Thanks

Flags: needinfo?(nika)

This is not a fix, just an easy way to trigger the issue.

  • enable debug mode
  • run ./mach test browser_testpanel_focusinput.js
    -> should leak

this example does not rely on any devtools API but still reproduces the leak.

Attachment #9078742 - Attachment is obsolete: true

Odd - not sure why a html iframe would end up leaking.

Interestingly, this leak appears to not be a "real" leak, as in it gets cleaned up before shutdown, but there are extra windows which are being held by a persistent object after the test completes, and aren't cycle-collected correctly. It's also interesting that we only leak with HTML documents, and not with XHTML documents. Might help pinpoint what the specific problem is.

Specifically it seems to have something to do with framing a HTML document within a content XUL document.

:kmag, any idea off the top of your head why this might be happening?

Flags: needinfo?(nika) → needinfo?(kmaglione+bmo)

Looks like it's being held alive by FormAutofill:

via persistent-Object :
0x1722374da610 [NonSyntacticVariablesObject <no private>]
--[FormAutofillContent]--> 0x386f34b23260 [Object <no private>]
--[_activeItems]--> 0x81b7a6123c0 [Object <no private>]
--[handler]--> 0x3c5e82be7ec0 [Object <no private>]
--[form]--> 0xf9d7d3e6980 [Object <no private>]
--[rootElement]--> 0x1b764360a60 [HTMLHtmlElement <no private>]
--[group]--> 0x1b7643c3400 [object_group]
--[group_global]--> 0x1e8d0f7c74c0 [Window <no private>]

Flags: needinfo?(kmaglione+bmo)

Cleaning the FormAutofillContent on blur seems to fix the leak.

(In reply to Kris Maglione [:kmag] from comment #5)

Looks like it's being held alive by FormAutofill:

via persistent-Object :
0x1722374da610 [NonSyntacticVariablesObject <no private>]
--[FormAutofillContent]--> 0x386f34b23260 [Object <no private>]
--[_activeItems]--> 0x81b7a6123c0 [Object <no private>]
--[handler]--> 0x3c5e82be7ec0 [Object <no private>]
--[form]--> 0xf9d7d3e6980 [Object <no private>]
--[rootElement]--> 0x1b764360a60 [HTMLHtmlElement <no private>]
--[group]--> 0x1b7643c3400 [object_group]
--[group_global]--> 0x1e8d0f7c74c0 [Window <no private>]

Thanks for sharing this! FormAutofillContent does keep a reference on the active element. I am not sure why this only results in a leak in my XUL+html scenario, but clearing the reference seems to fix the leak so I will try to cleanup and propose a patch.

Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8edf64664f1b
Fix FormAutoFill leak when focusing input in HTML frame r=kmag,MattN
Blocks: 1569897
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70
Attachment #9078818 - Attachment is obsolete: true
Fission Milestone: --- → M4
You need to log in before you can comment on or make changes to this bug.