Bug 22994 - Resources loaded from the memory cache do not get correctly inserted into the DocLoader resource map
Summary: Resources loaded from the memory cache do not get correctly inserted into the...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL: http://nerget.com/bugs/JSInspectorBug...
Keywords: InRadar
: 23035 (view as bug list)
Depends on:
Blocks: 61006
  Show dependency treegraph
Reported: 2008-12-25 02:35 PST by Oliver Hunt
Modified: 2011-05-17 17:17 PDT (History)
6 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-12-25 02:35:07 PST
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.

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)

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

Comment 1 Oliver Hunt 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 Oliver Hunt 2008-12-31 06:28:52 PST
*** Bug 23035 has been marked as a duplicate of this bug. ***
Comment 3 Oliver Hunt 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 Alexey Proskuryakov 2009-01-23 08:21:01 PST
This was fixed by Antti Koivisto in r39725.
Comment 5 Eric Seidel (no email) 2011-05-17 17:15:08 PDT
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; }

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):

I'll file a WebKit bug shortly.