Closed Bug 554524 Opened 14 years ago Closed 14 years ago

improve nsNPAPIPluginInstance's stream management

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jaas, Assigned: jaas)

References

Details

Attachments

(1 file, 6 obsolete files)

Attached patch fix v1.0 (obsolete) — Splinter Review
We should improve nsNPAPIPluginInstance's stream management. Top two priorities here:

1. Streams shouldn't keep a strong reference to their instance. This puts us at risk for cyclical references and makes incorrect stream handling harder to debug.

2. Stop using an nsInstanceStream-based linked list to keep track of streams. Just use an nsTArray of nsRefPtr objects.
Attachment #434423 - Flags: review?(jst)
Attachment #434423 - Flags: review?(jst) → review?(benjamin)
Attachment #434423 - Flags: review?(benjamin) → review+
Comment on attachment 434423 [details] [diff] [review]
fix v1.0

r=jst (but bsmedberg, feel free to look as well if you want to, of course).
Attached patch fix v1.1 (obsolete) — Splinter Review
update for current mozilla-central
Attachment #434423 - Attachment is obsolete: true
pushed to mozilla-central

http://hg.mozilla.org/mozilla-central/rev/10d2046d2b64
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Depends on: 558130
backed out due to bug 558130

http://hg.mozilla.org/mozilla-central/rev/65aca11d2b37
Status: RESOLVED → REOPENED
No longer depends on: 558130
Resolution: FIXED → ---
Blocks: 558130
Attached patch fix v2.0 (obsolete) — Splinter Review
Fixes the crash that led to a backout of v1.1.
Attachment #437196 - Attachment is obsolete: true
Attached patch fix v2.1 (obsolete) — Splinter Review
Fix some test failures.
Attachment #448873 - Attachment is obsolete: true
Attachment #449011 - Flags: review?(jst)
Comment on attachment 449011 [details] [diff] [review]
fix v2.1

- In nsNPAPIPluginStreamListener::CleanUpStream(NPReason reason):

 {
+  // Null out the instance (mInst) here, we can't depend on it existing after this method completes.
+
   nsresult rv = NS_ERROR_FAILURE;
 
-  if (mStreamCleanedUp)
+  if (mStreamCleanedUp || !mInst)
     return NS_OK;
 
   mStreamCleanedUp = PR_TRUE;
 
   StopDataPump();
 
   // Seekable streams have an extra addref when they are created which must
   // be matched here.
   if (NP_SEEK == mStreamType)
     NS_RELEASE_THIS();

Seems like if this is a seekable stream and mInst got nulled out already, we'll never release this extra reference to the listener and then leak it. Or did I miss another release of this extra addref?
That comment shouldn't be there, it is from an older version of the patch that did have the problem you described. The current patch does not actually null out mInst until all the code in "CleanUpStream" has executed.
Attached patch fix v2.2 (obsolete) — Splinter Review
Update comment.
Attachment #449011 - Attachment is obsolete: true
Attachment #449933 - Flags: review?(jst)
Attachment #449011 - Flags: review?(jst)
Attachment #449933 - Flags: review?(jst) → review+
pushed to mozilla-central

http://hg.mozilla.org/mozilla-central/rev/8e2ff18bc67e
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Backed out because I discovered a bad crash when testing other patches.

http://hg.mozilla.org/mozilla-central/rev/9c15f02468dc
http://hg.mozilla.org/mozilla-central/rev/6d425b6517d6

1. have my patch applied and use the latest Flash 10.1 rc (rc7, iirc)
2. start playing a YouTube video that has sound in a window with a single tab
3. close the top-level window using cmd-w

This will crash parent and child processes, but before they actually go down the sound from the video will continue to play with no window open.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch fix v3.0 (obsolete) — Splinter Review
This patch fixes the crash on destroy with ABP. It is a less aggressive version of fix v2.x in that it doesn't change the actual ownership model, it just improves the object/memory management code.
Attachment #449933 - Attachment is obsolete: true
Attachment #451110 - Flags: review?(jst)
Comment on attachment 451110 [details] [diff] [review]
fix v3.0

-  nsInstanceStream *mStreams;
+  nsTArray<nsNPAPIPluginStreamListener*> mStreams;

It occurred to me that we should probably call this mStreamListeners instead of mStreams, since it really is an array of stream listeners. But I'm fine with doing that as part of a followup cleanup bug if you don't want to do that rename here.

r=jst
Attachment #451110 - Flags: review?(jst) → review+
Attached patch fix v3.1Splinter Review
mStreams -> mStreamListeners
Attachment #451110 - Attachment is obsolete: true
pushed to mozilla-central

http://hg.mozilla.org/mozilla-central/rev/51136ef1b3e1
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Depends on: 584143
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: