Bug 11523 - WebBaseNetscapePluginView leaks like a mofo
Summary: WebBaseNetscapePluginView leaks like a mofo
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Plug-ins (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2006-11-05 18:08 PST by Steve Gehrman
Modified: 2007-01-26 21:22 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Gehrman 2006-11-05 18:08:38 PST
In my app, an interactive flash swf is constantly sending info back and forth to the client app and each communication creates a stream but never releases it.  It was eating memory like crazy.

Add this to WebBaseNetscapePluginView.m

- (void)streamIsDead:(WebBaseNetscapePluginStream*)stream;
{
    [[stream retain] autorelease];
    
    // don't want to retain the stream anylonger
    [streams removeObjectIdenticalTo:stream];
}

In WebBaseNetscaplePluginStream.m add this one line to setPluginPointer....

- (void)setPluginPointer:(NPP)pluginPointer
{
    if (pluginPointer) {
        instance = pluginPointer;
        pluginView = [(WebBaseNetscapePluginView *)instance->ndata retain];
        WebNetscapePluginPackage *plugin = [pluginView plugin];
        NPP_NewStream = [plugin NPP_NewStream];
        NPP_WriteReady = [plugin NPP_WriteReady];
        NPP_Write = [plugin NPP_Write];
        NPP_StreamAsFile = [plugin NPP_StreamAsFile];
        NPP_DestroyStream = [plugin NPP_DestroyStream];
        NPP_URLNotify = [plugin NPP_URLNotify];
    } else {
        instance = NULL;
        
        [pluginView streamIsDead:self];  // <-- added this line only
        
        [pluginView release];
        pluginView = nil;
        NPP_NewStream = NULL;
        NPP_WriteReady = NULL;
        NPP_Write = NULL;
        NPP_StreamAsFile = NULL;
        NPP_DestroyStream = NULL;
        NPP_URLNotify = NULL;
    }
}
Comment 1 Alexey Proskuryakov 2006-11-14 22:24:46 PST
Thank you for making the fix! It would be easier (and therefore faster) to process if you could submit it according to the guidelines from <http://webkit.org/coding/contributing.html>.
Comment 2 Steve Gehrman 2006-11-15 15:09:53 PST
It would be easier and faster if you just fixed the code rather than wasting my time telling me to reformat my bug report.  It's super simple.
Comment 3 Mark Rowe (bdash) 2007-01-22 17:09:35 PST
Thanks for your cooperation Steve.
Comment 4 Mark Rowe (bdash) 2007-01-22 17:15:03 PST
<rdar://problem/4946922>
Comment 5 David Kilzer (:ddkilzer) 2007-01-25 14:14:49 PST
Committed by kdecker in r19131.

Comment 6 David Kilzer (:ddkilzer) 2007-01-25 19:28:01 PST
Patch backed out in r19135 because it crashes espn.com.

Comment 7 David Kilzer (:ddkilzer) 2007-01-26 19:36:40 PST
Committed by kdecker in r19167.

http://trac.webkit.org/projects/webkit/changeset/19167

Comment 8 David Kilzer (:ddkilzer) 2007-01-26 20:22:29 PST
With a locally-built debug build of WebKit r19181 with Safari 2.0.4 (419.3) on Mac OS X 10.4.8 (8N1037), http://mail.yahoo.com/ now crashes (when you have that goofy persona-head-thingy defined):

objc: FREED(id): message destroyStreamWithError: sent to freed object=0xf487860
Trace/BPT trap

Stack trace:

Exception:  EXC_BREAKPOINT (0x0006)
Code[0]:    0x00000002
Code[1]:    0x00000000


Thread 0 Crashed:
0   libobjc.A.dylib                	0x90a5eb09 _objc_error + 86
1   libobjc.A.dylib                	0x90a5eb40 __objc_error + 45
2   libobjc.A.dylib                	0x90a5d1a0 _freedHandler + 53
3   com.apple.WebKit               	0x003132a7 -[WebBaseNetscapePluginStream cancelLoadAndDestroyStreamWithError:] + 72 (WebBaseNetscapePluginStream.m:342)
4   com.apple.WebCore              	0x0139af5b WebCore::NetscapePlugInStreamLoader::didReceiveResponse(WebCore::ResourceResponse const&) + 331 (NetscapePlugInStreamLoaderMac.mm:85)
5   com.apple.WebCore              	0x013c6ced WebCore::ResourceLoader::didReceiveResponse(WebCore::ResourceHandle*, WebCore::ResourceResponse const&) + 31
6   com.apple.WebCore              	0x013a698b -[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:] + 115 (ResourceHandleMac.mm:340)
7   com.apple.Foundation           	0x9265e8a7 -[NSURLConnection(NSURLConnectionInternal) _sendDidReceiveResponseCallback] + 56
8   com.apple.Foundation           	0x9265ce1f -[NSURLConnection(NSURLConnectionInternal) _sendCallbacks] + 614
9   com.apple.Foundation           	0x9265cb41 _sendCallbacks + 201
10  com.apple.CoreFoundation       	0x9082afd2 CFRunLoopRunSpecific + 1213
11  com.apple.CoreFoundation       	0x9082ab0e CFRunLoopRunInMode + 61
12  com.apple.HIToolbox            	0x92ddabef RunCurrentEventLoopInMode + 285
13  com.apple.HIToolbox            	0x92dda2fd ReceiveNextEventCommon + 385
14  com.apple.HIToolbox            	0x92dda154 BlockUntilNextEventMatchingListInMode + 81
15  com.apple.AppKit               	0x9327f465 _DPSNextEvent + 572
16  com.apple.AppKit               	0x9327f056 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 137
17  com.apple.Safari               	0x00006cea 0x1000 + 23786
18  com.apple.AppKit               	0x93278ddb -[NSApplication run] + 512
19  com.apple.AppKit               	0x9326cd2f NSApplicationMain + 573
20  com.apple.Safari               	0x0005f54a 0x1000 + 386378
21  com.apple.Safari               	0x0005f471 0x1000 + 386161

Comment 9 David Kilzer (:ddkilzer) 2007-01-26 20:31:53 PST
(In reply to comment #8)
> With a locally-built debug build of WebKit r19181 with Safari 2.0.4 (419.3) on
> Mac OS X 10.4.8 (8N1037), http://mail.yahoo.com/ now crashes (when you have
> that goofy persona-head-thingy defined):

That would be the head of your Yahoo! Avatar.
Comment 10 David Kilzer (:ddkilzer) 2007-01-26 21:22:28 PST
FIx for mail.yahoo.com avatar committed by ddkilzer in r19182.  Patch by Darin.

http://trac.webkit.org/projects/webkit/changeset/19182