Closed Bug 1816693 Opened 1 year ago Closed 1 year ago

(latent) permafailing TEST-UNEXPECTED-FAIL | browser/base/content/test/webrtc/browser_devices_get_user_media.js | leaked 1 window(s) until shutdown [url = chrome://browser/content/webrtcLegacyIndicator.xhtml]

Categories

(Firefox :: Toolbars and Customization, defect, P1)

Unspecified
All
defect

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox110 --- wontfix
firefox111 --- wontfix
firefox112 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 file)

When re-enabling browser/base/content/test/webrtc/browser_devices_get_user_media.js for test/webrtc/legacyIndicator I get on linux-debug locally (and on try (including for other platforms)) the following permafailing errors:

ERROR TEST-UNEXPECTED-FAIL | browser/base/content/test/webrtc/browser_devices_get_user_media.js | leaked 1 window(s) until shutdown [url = chrome://browser/content/webrtcLegacyIndicator.xhtml]
ERROR TEST-UNEXPECTED-FAIL | browser/base/content/test/webrtc/browser_devices_get_user_media.js | leaked 1 window(s) until shutdown [url = about:blank]

These are caused by opening the permissions panel through the legacy indicator. get_user_media_screen.js exhibits the same issue.

I am getting this with the patches on bug 1775945, but also on m-c.

Did a big effort analyzing this but pernosco and DMD were not much help in this case unfortunately.

The leak is in nsXULPopupManager which is not participating in GC but has a member mNativeMenuSubmenuState a nsTHashMap<RefPtr<mozilla::dom::Element>, nsPopupState> where the hash key keeps a strong ref to a dom::Element.

I haven't worked out the exact chain of events but have verified that making the key a rawptr solves the leak. The keys are never accessed directly so as long as the caller of these native menu event handlers keeps a strong ref it should be safe. I'll put it up for review and take it from there.

Status: NEW → ASSIGNED
Component: Site Permissions → Layout
OS: Unspecified → All
Product: Firefox → Core
Regressed by: 1704554

Sorry, I'll have to backtrack on the regressor. Still looks suspect but for the failing test case this hash map is not used. I had removed a verification thing from a .js file and only did ./mach build binaries so got a false positive.

No longer regressed by: 1704554

It appears to be the _openPopupCancelCallback from bug 1434883 which captures the entire scope, including the OpenPopupOptions where triggerEvent has a strong ref to the webrtcLegacyIndicator.xhtml window.

OTOH the options with triggerEvent were added later in bug 1506503 so I guess both combined count as regressors.

Component: Layout → Toolbars and Customization
Product: Core → Firefox
Regressed by: 1434883, 1506503

(In reply to Andreas Pehrson [:pehrsons] from comment #3)

It appears to be the _openPopupCancelCallback from bug 1434883 which captures the entire scope, including the OpenPopupOptions where triggerEvent has a strong ref to the webrtcLegacyIndicator.xhtml window.

OTOH the options with triggerEvent were added later in bug 1506503 so I guess both combined count as regressors.

I wonder if this leak is related to bug 1809000 as well - though that is macOS only, and comment 0 suggests that is happening on linux debug.

I'm also confused because that ref (ie to _openPopupCancelCallback) gets nulled out here which is called here when the window closes. Does that not happen?

(In reply to :Gijs (he/him) from comment #4)

I wonder if this leak is related to bug 1809000 as well - though that is macOS only, and comment 0 suggests that is happening on linux debug.

Linux debug is circumstantial. It's what I run locally. The webrtc legacy indicator is disabled on mac in favor of the MacOSWebRTCStatusbarIndicator, but would happen there otherwise. It happens on Windows on try.

I guess it doesn't happen on non-debug because there is no ShutdownLeaks check.

I wonder if bug 180900 could be a result of the stray strongref in comment 1. It can be active when a native popup is showing and was added mac-specifically. I'll comment.

(In reply to :Gijs (he/him) from comment #5)

I'm also confused because that ref (ie to _openPopupCancelCallback) gets nulled out here which is called here when the window closes. Does that not happen?

We are just leaking past the ShutdownLeaks check, which happens before the main window is closed (in the callback passed to finish()). See pernosco.

It appears that even a noop function () => {} will capture the entire scope,
so this patch also changes the normal state of the cancel callback to be
undefined.

Pushed by pehrsons@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/83e6cd1dfb3f
In PanelMultiView.jsm don't tie the openPopup args to the main window lifetime through the cancelCallback capture. r=Gijs

Thanks for driving this!

Severity: -- → S3
Priority: -- → P1
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: