Bug 4357 - crash related to animated GIFs, reproducible in non-Safari WebKit application
Summary: crash related to animated GIFs, reproducible in non-Safari WebKit application
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-09 11:55 PDT by Scott Garner
Modified: 2005-09-05 15:19 PDT (History)
0 users

See Also:


Attachments
A small application that illustrates the bug. (13.29 KB, application/zip)
2005-08-09 11:59 PDT, Scott Garner
no flags Details
patch to fix the problem (was a retain from inside dealloc!) (7.73 KB, patch)
2005-09-03 16:44 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
patch to fix the problem (retain inside dealloc) (4.45 KB, patch)
2005-09-04 12:40 PDT, Darin Adler
sullivan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Garner 2005-08-09 11:55:37 PDT
This one is a little hard to explain, but basically once a page with an animated gif is loaded, used and 
released, *something* still tries to access the documentView containing the gif, thus causing an 
exception.
Comment 1 Scott Garner 2005-08-09 11:59:27 PDT
Created attachment 3291 [details]
A small application that illustrates the bug.
Comment 2 Scott Garner 2005-08-09 12:04:52 PDT
An obviously inelegant workaround that I've been using:

- (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame
{
	WebDataSource*  dataSource;
	dataSource = [frame dataSource];
	NSEnumerator *enumerate = [[dataSource subresources] objectEnumerator];
	WebResource *curResource;
	
	while (curResource = [enumerate nextObject]) {
		if ([[curResource MIMEType] isEqualTo:@"image/gif"]) {
			NSView *documentView  = [[frame frameView] documentView];
			[documentView retain];
			break;
		}			
	}
}

The idea is to retain any DocumentViews that might contain an animated GIF.  Since this is all for an 
Automator action (Download URLs as PDFs), the resulting leak isn't terribly problematic. 
Comment 3 Scott Garner 2005-08-09 12:12:30 PDT
For a little more commentary on this issue along with some attempted workarounds:

http://lists.apple.com/archives/Webkitsdk-dev//2005/Jul/msg00030.html
Comment 4 Darin Adler 2005-09-03 16:08:16 PDT
Using zombie mode, I see a WebHTMLView being overreleased when I use this test program.
Comment 5 Darin Adler 2005-09-03 16:20:18 PDT
I found the bug. Working on a fix.
Comment 6 Darin Adler 2005-09-03 16:23:47 PDT
The problem is that this code, in a roundabout way, calls retain on a WebHTMLView object that's in its 
dealloc function. I'm fixing that now.
Comment 7 Darin Adler 2005-09-03 16:24:38 PDT
By "this code", I mean "the WebImageData class".
Comment 8 Darin Adler 2005-09-03 16:44:12 PDT
Created attachment 3734 [details]
patch to fix the problem (was a retain from inside dealloc!)
Comment 9 Darin Adler 2005-09-04 12:40:45 PDT
Created attachment 3757 [details]
patch to fix the problem (retain inside dealloc)