Bug 19786 - LEAK when rapidly closing multiple tabs while they are still loading content
Summary: LEAK when rapidly closing multiple tabs while they are still loading content
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-26 21:19 PDT by Dylan
Modified: 2008-06-27 00:14 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dylan 2008-06-26 21:19:28 PDT
When multiple tabs are opened and then closed before they are loaded, I see several memory leaks. Most recently, the following (although exactly what is leaked seems to vary somewhat)

1 BrowserDocument object, 1 WebView object, 1 WebFrame object, 1 WebDataSource object, 1 WebFrameView object, 1 WebHTMLRepresentation object, 1 JavaScript global object.



To reproduce
1) Close all safari windows except one.
2) If you do not have a bookmark folder with 10 or more bookmarks in it, you'll need to make one, preferably with a few pages that take a while to load fully near the end of the list and a page that loads fast first (this is not required, it just helps). 
3) Hover your fingers over Cmd-W, because you are going to need to be fast on the uptake here.
4) Open the bookmark folder in tabs (Cmd-click or select from the bottom of the folder list)
5) As soon as ANY content is displayed on the first page (use a fast page to ensure that the other pages are still loading!), press and hold Cmd-W until all tabs and finally the window are closed. Note that if you do not HOLD Cmd-W down the entire time, it happens much less often (if at all). 

The "Leaks" window comes up, and often displays again several times after you press OK (it seems like each tab may leak that or something similar)


Another run of this to make sure it still happens in r34822 (it does), and I got the following (the window displaying this information re-opened 5 times, FWIW)

1 BrowserDocument object, 1 WebView object, 1 WebFrame object, 2 WebDataSource objects, 1 WebFrameView object, 2 WebHTMLRepresentation objects, 2 JavaScript global objects.




It should work with any collection of webpages so long as at least a couple are still loading content (or is still trying to start loading content) when it is closed and so long as the first tab loads at least a little data (realistically, ANY tab needs to load some data, but it is easiest to tell on the first tab, obviously). I can post the bookmarks in a folder I have that always reproduces this if need be, but if it isn't needed I won't. It has worked with every random collection of webpages I have tried it with. 


This is not a regression, also happens in shipping safari 3.1.1 on 10.5.3. shipping safari's leak message:

1 BrowserDocument object, 1 WebView object, 1 WebFrame object, 1 WebDataSource object, 1 WebFrameView object, 1 WebHTMLRepresentation object, 1 WebBridge object.


Again, what exactly is leaked seems to vary (probably depending on what pages are loading, loaded, or trying to load at the time, etc), but it is always a long list like that. 


This does NOT happen if you "close all tabs" (Shift-Cmd-W), even in the same circumstances. I just never REMEMBER that keyboard shortcut exists, so if I accidentally open a tab group i usually just hold Cmd-W.
Comment 1 Mark Rowe (bdash) 2008-06-26 21:48:34 PDT
If you follow your steps, then open a new window, wait a few moments, then close it do you see another leak dialog?
Comment 2 Dylan 2008-06-26 22:05:57 PDT
(In reply to comment #1)
> If you follow your steps, then open a new window, wait a few moments, then
> close it do you see another leak dialog?
> 

Not right now, I don't. I know I have seen that before fairly recently (within the week), but I'll be honest I usually just quit Safari (or WebKit if I am using a nightly) and launch it again when I see when of those messages, so I am not sure when exactly. I just tried several times in both r34822, r34824, and shipping 3.1.1 and could not get it to come up on the next window (i tried both letting the new window's page load fully or cutting it off before it loaded). If I see that happen in the near future, I'll be sure to note it here.

Comment 3 Dylan 2008-06-26 22:07:42 PDT
(In reply to comment #2)
> (In reply to comment #1)
> > If you follow your steps, then open a new window, wait a few moments, then
> > close it do you see another leak dialog?
> > 
> 
> Not right now, I don't. 

Open mouth, insert foot. In an attempt to test it "one more time, just in case", I did get it to come up for the next (and all subsequent) window(s) opened in r34824

this time, the leak is
1 WebFrame object.

Comment 4 Mark Rowe (bdash) 2008-06-26 22:13:03 PDT
If you close tabs rapidly then the leak detection timer can fire before all the relevant cleanup has completed, leading to many false positives.  I believe that is what you are seeing based on the steps that you describe.  To verify that it is a legitimate leak you need to pause for five or ten seconds, open a blank window, close it, and wait to see if you see another dialog.  If you can reproduce a leak after following these extra steps, please let me know.
Comment 5 Dylan 2008-06-26 22:34:22 PDT
(In reply to comment #4)
> If you close tabs rapidly then the leak detection timer can fire before all the
> relevant cleanup has completed, leading to many false positives.  I believe
> that is what you are seeing based on the steps that you describe.  To verify
> that it is a legitimate leak you need to pause for five or ten seconds, open a
> blank window, close it, and wait to see if you see another dialog.  If you can
> reproduce a leak after following these extra steps, please let me know.
> 


More testing, and I can't get it to happen. i guess I am hitting this, then.

Would it be possible to make the timer on the leak check wait a little longer to lessen the amount of this and similar false positives (i just tested rapidly Cmd-N, Cmd-W-ing over and over and got a similar message)? Or would it have to be lengthened to such a degree that the dialog would no longer open more or less at the same time as the window closes?

It is just annoying because the dialogs prevent Safari/WebKit from doing ANYTHING until they are all dismissed (like a javascript alert() dialog), and since i get 5 to 10 of them opened back to back, it makes it annoying to get rid of them all just so that I can open a new window. Maybe could the leaks dialog be made into a simple HTML document loaded in a borderless/chromeless standard webkit window, so that it doesn't prevent the program from responding? or is that getting into the Safari chrome and not the webkit guts?
Comment 6 Mark Rowe (bdash) 2008-06-27 00:14:05 PDT
The alert only appears if you have explicitly turned on "Always Check for World Leaks" in Safari's "Debug" menu. If you're not interested in them, feel free to turn it back off.