Closed Bug 971593 Opened 11 years ago Closed 10 years ago

[RTSP] Resource leak of HTMLMediaElement containing RTSP media resource


(Firefox OS Graveyard :: RTSP, defect, P1)

Gonk (Firefox OS)



2.0 S1 (9may)
tracking-b2g backlog


(Reporter: ethan, Assigned: ethan)



(Whiteboard: [p=1])

The reproduction of this bug is based on the WIP patch of bug 945603.
With the WIP patch, we could render RTSP streaming inside the browser, just like HTTP streaming.

But we found a critical resource leak problem of RTSP streaming.
The HTMLMediaElement containing RtspMediaResource will never be released by cycle collector.

From the analysis result of headgraph, we identified the "nsDocument" object has an unknown edge.
0x4417d000 [nsDocument normal (xhtml) rtsp://]
    --[mChildren[i]]--> 0x44154c10 [FragmentOrElement (xhtml) html rtsp://]
    --[mAttrsAndChildren[i]]--> 0x4415ee80 [FragmentOrElement (xhtml) body rtsp://]
    --[mAttrsAndChildren[i]]--> 0x434da900 [FragmentOrElement (xhtml) video rtsp://]
    Root 0x4417d000 is a ref counted object with 1 unknown edge(s).
    known edges:
       0x43456190 [nsNodeInfoManager] --[mDocument]--> 0x4417d000
       0x4343e210 [nsGlobalWindow #3] --[mDoc]--> 0x4417d000
       0x438970a0 [JS Object (HTMLDocument)] --[UnwrapDOMObject(obj)]--> 0x4417d000

Then we identified the root cause by using GDB.
MediaDocumentStreamListener, which holds a strong reference to nsDocument, will be constructed by RtspChannel.
But its OnStopRequest function, which release the reference to nsDocument, is never called by RtspChannel.
Assignee: nobody → ettseng
Blocks: 945603
Severity: normal → blocker
Priority: -- → P1
Component: General → RTSP
Update some information.

1. We resolved more resource leaks of RTSP in bug 977518.
Those resource leaks were all caused by cyclic references of RTSP components.
We cannot fix this bug until those internal leaks are sorted out. Fortunately, bug 977518 is fixed right now.
2. This bug is to resolve the resource leak caused by the reference to nsDocument hold by MediaDocumentStreamListener. The fix of this bug could possibly involve changes of RtspChannel. We are refactoring RtspChannel in bug 949675, and the resource leak issue of this bug might be resolved in the refactoring patch.
Depends on: 992568
This bug will be resolved by bug 992568 (Refactor RtspChannel to support HTTP->RTSP redirection and rendering inside the browser).
blocking-b2g: --- → backlog
Resolved fixed by bug 992568.
RTSP doesn't leak resource now.
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [p=1]
Target Milestone: --- → 2.0 S1 (9may)
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.