Closed Bug 1559568 Opened 5 years ago Closed 5 years ago

Ghost windows on soundcloud

Categories

(Core :: Audio/Video: MediaStreamGraph, defect, P2)

69 Branch
defect

Tracking

()

VERIFIED FIXED
mozilla69
Tracking Status
firefox-esr60 --- unaffected
firefox67 --- wontfix
firefox67.0.1 --- wontfix
firefox68 --- wontfix
firefox69 --- verified

People

(Reporter: over68, Assigned: pehrsons)

References

(Regression)

Details

(Keywords: memory-leak, regression, Whiteboard: [MemShrink])

Attachments

(3 files)

Steps to reproduce:

  1. Go to about:preferences#general
  2. Disable "Use recommended performance settings"
  3. Set "Content process limit" to "1"
  4. Restart Firefox.
  5. Open http://example.com/ in first tab.
  6. Open https://soundcloud.com/kapslap/summer-mix-2015 in second tab.
  7. Play the song.
  8. Close the second tab.
  9. Wait two minutes, then go to 'about:memory' then press 'Measure'.

Actual results:

Ghost windows on soundcloud.

│ ├──10.05 MB (07.86%) -- top(none)/ghost/window(https://soundcloud.com/kapslap/summer-mix-2015)

Flags: needinfo?(apehrson)

I can confirm that this is happening. I haven't confirmed the regressor yet.

Assignee: nobody → apehrson
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(apehrson)
OS: Windows 7 → All
Priority: -- → P2
Hardware: x86_64 → All

I can confirm the regressor too.

Status: NEW → ASSIGNED

The regressor moved ownership of MediaStreams and MediaStreamTracks to OutputStreamManager, which is owned by MediaDecoder. When you close a tab, the media elements in that tab become inactive and their associated MediaDecoders are paused and suspended, but not shut down. Because they're not shut down, they stay ready to continue capturing data into any MediaStreams previously returned by mozCaptureStream (which soundcloud uses).

Normally these MediaStreams and MediaStreamTracks would be eligible to be cycle collected, but since MediaDecoder (and its descendant OutputStreamManager) doesn't participate in CC, a reference is left-hanging somewhere here which keeps both the HTMLMediaElement, and MediaStreams and MediaStreamTracks alive until XPCOM_Shutdown, when the MediaShutdownManager shuts the MediaDecoder down.

I have a patch in progress that makes the strong refs to MediaStreams and MediaStreamTracks in OutputStreamManager weak refs instead. That fixes this issue.

Depends on D36569

MediaInputPort::Destroy must always be called, or it will not remove its strong
ref to the MediaStreamGraph. The guard is not even needed, since
MediaInputPort::Disconnect is idempotent.

Depends on D36570

Pushed by pehrsons@gmail.com: https://hg.mozilla.org/integration/autoland/rev/6e2e6b0b0dc5 Make DOMMediaStream support WeakPtr. r=jya https://hg.mozilla.org/integration/autoland/rev/e1f73a7e8dc6 Remove strong refs from OutputStreamManager. r=jya https://hg.mozilla.org/integration/autoland/rev/e3b2bdab221f Remove extraneous dtor guard in OutputStreamData. r=padenot
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
Flags: qe-verify+

Confirmed issue with 69.0a1(20190614215040).
Fix verified with 69.0b5 on Windows 10, macOS 10.13, Ubuntu16.04; no ghosts appeared even after a ~5 minute interval.

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

Attachment

General

Created:
Updated:
Size: