Bug 22994 - Resources loaded from the memory cache do not get correctly inserted into the DocLoader resource map
: Resources loaded from the memory cache do not get correctly inserted into the...
Status: RESOLVED FIXED
: WebKit
Page Loading
: 528+ (Nightly build)
: Macintosh Mac OS X 10.5
: P2 Normal
Assigned To:
: http://nerget.com/bugs/JSInspectorBug...
: InRadar
:
: 61006
  Show dependency treegraph
 
Reported: 2008-12-25 02:35 PST by
Modified: 2011-05-17 17:17 PST (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2008-12-25 02:35:07 PST
* SUMMARY
When using the inspector on a page with unchanging js, reloading may cause the JS documents to disappear.

The issue appears to be that cached js resources that do not trigger a reload do not provide any content to the inspector.

* STEPS TO REPRODUCE
1. Go to http://nerget.com/bugs/JSInspectorBug.html
2. Open the inspector
3. Go to the resources panel
4. Focus the JSInspectorBug.js file, notice that it has content
5. Reload the main window (with cmd-r, or whatever)

* RESULTS
There is no longer any content shown in the inspector, this also makes debugging that file impossible

<rdar://problem/6467206>
------- Comment #1 From 2008-12-31 05:56:18 PST -------
Okay, i've tracked this down to resources loaded from the memory cache not being put in the docloader, and so not providing any information to the inspectorator
------- Comment #2 From 2008-12-31 06:28:52 PST -------
*** Bug 23035 has been marked as a duplicate of this bug. ***
------- Comment #3 From 2008-12-31 06:31:29 PST -------
12/31/08 6:23 AM Oliver Hunt:
Okay, the problem is that resources that validate as not needing to be refetched do not get put into the docloader resource map, this means that this also breaks Web Archives if you have reloaded the page.

Have been discussing with Antti.

He suggested 
mutable HashMap<String, CachedResource*> m_docResources -> 
mutable HashMap<String, CachedResourceHandle<CachedResource> > m_docResources

Which after a quick patch did improve things (although some resources were still not refreshed correctly) , however we also then crashed on exit so it's perfectly possible my patch was doing something stupid.
------- Comment #4 From 2009-01-23 08:21:01 PST -------
This was fixed by Antti Koivisto in r39725.
------- Comment #5 From 2011-05-17 17:15:08 PST -------
I believe that http://trac.webkit.org/changeset/39725 introduced a leak of all CachedResources.

m_documentResources holds a CachedResourceHandle:
    typedef HashMap<String, CachedResourceHandle<CachedResource> > DocumentResourceMap;

The only time that a CachedResource is ever destroyed is when its handle count hits 0:

    bool canDelete() const { return !hasClients() && !m_request && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
http://trac.webkit.org/browser/trunk/Source/WebCore/loader/cache/CachedResource.h#L176

But the only way to ever be removed from this map is from:
void CachedResourceLoader::removeCachedResource(CachedResource* resource) const

Which is only ever called from ~CachedResource().

This has been reported various times to Chromium (but affects all webkit implementations):
http://code.google.com/p/chromium/issues/detail?id=36142

I'll file a WebKit bug shortly.