GetSinkDevice() leaks SourceListeners until the window is navigated
Categories
(Core :: WebRTC: Audio/Video, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox87 | --- | fixed |
People
(Reporter: karlt, Assigned: karlt)
References
Details
Attachments
(7 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
GetSinkDevice()
registers a new SourceListener
, and discards its handle to the SourceListener
.
GetUserMediaWindowListener
holds a strong reference to the SourceListener
and MediaManager
holds a strong reference to the GetUserMediaWindowListener
until the window is navigated.
Assignee | ||
Comment 1•4 years ago
|
||
Assignee | ||
Comment 2•4 years ago
|
||
If GetInnerWindowWithId() returns false then RemoveWindowID() does nothing
but remove the window id from mActiveWindows if present.
https://searchfox.org/mozilla-central/rev/d3343662ce0aced933b30e053b33c93f759292eb/dom/media/MediaManager.cpp#3351,3357
GetUserMediaWindowListener::RemoveAll() is sufficient to call RemoveWindowID()
to do the same if the window id is present in mActiveWindows.
If the window id is not present, then GetWindowListener() returns false and
there is nothing to do.
The additional code path was added because IterateWindowListeners() needed a
nsPIDOMWindow,
https://hg.mozilla.org/mozilla-central/rev/786737c759d771029d393d793dff207d86f18faf#l1.60
but IterateWindowListeners() is no longer used.
https://hg.mozilla.org/mozilla-central/rev/ec16fb789a045e6d644d32bf269ff48944637c2b#l1.21
The "safe" comment is not necessary because mActiveWindows
is clearly
documented as main-thread-only and there are plenty of main thread assertions.
https://searchfox.org/mozilla-central/rev/d3343662ce0aced933b30e053b33c93f759292eb/dom/media/MediaManager.h#332-333
Assignee | ||
Comment 3•4 years ago
|
||
The only caller of MediaManager::EnumerateDevices() checks that the inner
window is [current] after the returned MozPromise settles and
Document::CanSavePresentation() says [no] if
MediaManager::Get()->IsWindowStillActive(win->WindowID()) so there should be
no observable difference in depending on MediaDevices::EnumerateDevices() for
the active window check.
[current]
https://searchfox.org/mozilla-central/rev/4dac9993b609fccc87e82682614faf2a44cda306/dom/media/MediaDevices.cpp#121,149
[no]
https://searchfox.org/mozilla-central/rev/d3343662ce0aced933b30e053b33c93f759292eb/dom/base/Document.cpp#10738
Depends on D105247
Assignee | ||
Comment 4•4 years ago
|
||
This was already happening to some extent due to the recursive relationship of
SourceListener::Stop() and GetUserMediaWindowListener::Remove(), but being
direct about it saves a parameter.
Depends on D105248
Assignee | ||
Comment 5•4 years ago
|
||
Depends on D105249
Assignee | ||
Comment 6•4 years ago
|
||
The task is main-thread, so the second IsWindowStillActive() call always
returned true.
This became obsolete with
https://hg.mozilla.org/mozilla-central/rev/69b1d1c5e010097cfd7c10c9a373f72ea6873e2c#l1.587
Depends on D105250
Assignee | ||
Comment 7•4 years ago
|
||
so that EnumerateDevicesImpl() clients don't need to care about this.
This also adds a SourceListener::Stop() call to fix a leak from the logic in
GetSinkDevice().
Depends on D105251
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 9•4 years ago
|
||
Bug 1693724 may be useful for testing this.
See e.g. https://searchfox.org/mozilla-central/source/dom/media/webaudio/test/test_WebAudioMemoryReporting.html
Comment 10•4 years ago
|
||
Comment 11•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/72d38fc9b2bb
https://hg.mozilla.org/mozilla-central/rev/fff6d438adb9
https://hg.mozilla.org/mozilla-central/rev/861447a14631
https://hg.mozilla.org/mozilla-central/rev/5dda16539d3d
https://hg.mozilla.org/mozilla-central/rev/a4d8f07a3e41
https://hg.mozilla.org/mozilla-central/rev/f2cb3ed27e68
Assignee | ||
Comment 12•4 years ago
|
||
Depends on D106250
Comment 13•4 years ago
|
||
Comment 14•4 years ago
|
||
bugherder |
Assignee | ||
Updated•4 years ago
|
Description
•