Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (236077 => 236078)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2018-09-17 18:57:53 UTC (rev 236077)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2018-09-17 19:39:35 UTC (rev 236078)
@@ -612,6 +612,7 @@
bool CachedResource::deleteIfPossible()
{
if (canDelete()) {
+ LOG(ResourceLoading, "CachedResource %p deleteIfPossible - can delete, in cache %d", this, inCache());
if (!inCache()) {
InspectorInstrumentation::willDestroyCachedResource(*this);
delete this;
@@ -620,6 +621,8 @@
if (m_data)
m_data->hintMemoryNotNeededSoon();
}
+
+ LOG(ResourceLoading, "CachedResource %p deleteIfPossible - can't delete (hasClients %d loader %p preloadCount %u handleCount %u resourceToRevalidate %p proxyResource %p)", this, hasClients(), m_loader.get(), m_preloadCount, m_handleCount, m_resourceToRevalidate, m_proxyResource);
return false;
}
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (236077 => 236078)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2018-09-17 18:57:53 UTC (rev 236077)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2018-09-17 19:39:35 UTC (rev 236078)
@@ -789,7 +789,7 @@
request.updateReferrerPolicy(document() ? document()->referrerPolicy() : ReferrerPolicy::NoReferrerWhenDowngrade);
URL url = ""
- LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.stringCenterEllipsizedToLength().latin1().data(), request.charset().latin1().data(), request.priority() ? static_cast<int>(request.priority().value()) : -1, forPreload == ForPreload::Yes);
+ LOG(ResourceLoading, "CachedResourceLoader::requestResource '%.255s', charset '%s', priority=%d, forPreload=%u", url.stringCenterEllipsizedToLength().latin1().data(), request.charset().latin1().data(), request.priority() ? static_cast<int>(request.priority().value()) : -1, forPreload == ForPreload::Yes);
if (!url.isValid()) {
RELEASE_LOG_IF_ALLOWED("requestResource: URL is invalid (frame = %p)", frame());
@@ -1329,10 +1329,14 @@
// remove it from the map.
void CachedResourceLoader::garbageCollectDocumentResources()
{
+ LOG(ResourceLoading, "CachedResourceLoader %p garbageCollectDocumentResources", this);
+
typedef Vector<String, 10> StringVector;
StringVector resourcesToDelete;
for (auto& resource : m_documentResources) {
+ LOG(ResourceLoading, " cached resource %p - hasOneHandle %d", resource.value.get(), resource.value->hasOneHandle());
+
if (resource.value->hasOneHandle()) {
resourcesToDelete.append(resource.key);
resource.value->setOwningCachedResourceLoader(nullptr);
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (236077 => 236078)
--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2018-09-17 18:57:53 UTC (rev 236077)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2018-09-17 19:39:35 UTC (rev 236078)
@@ -123,7 +123,7 @@
resourceAccessed(resource);
- LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource.url().string().latin1().data(), &resource);
+ LOG(ResourceLoading, "MemoryCache::add Added '%.255s', resource %p\n", resource.url().string().latin1().data(), &resource);
return true;
}
@@ -298,6 +298,9 @@
{
if (m_inPruneResources)
return;
+
+ LOG(ResourceLoading, "MemoryCache::pruneLiveResourcesToSize(%d, shouldDestroyDecodedDataForAllLiveResources = %d)", targetSize, shouldDestroyDecodedDataForAllLiveResources);
+
SetForScope<bool> reentrancyProtector(m_inPruneResources, true);
MonotonicTime currentTime = FrameView::currentPaintTimeStamp();
@@ -316,6 +319,8 @@
while (it != m_liveDecodedResources.end()) {
auto* current = *it;
+ LOG(ResourceLoading, " live resource %p %.255s - loaded %d, decodedSize %u", current, current->url().string().utf8().data(), current->isLoaded(), current->decodedSize());
+
// Increment the iterator now because the call to destroyDecodedData() below
// may cause a call to ListHashSet::remove() and invalidate the current
// iterator. Note that this is safe because unlike iteration of most
@@ -328,8 +333,10 @@
if (current->isLoaded() && current->decodedSize()) {
// Check to see if the remaining resources are too new to prune.
Seconds elapsedTime = currentTime - current->m_lastDecodedAccessTime;
- if (!shouldDestroyDecodedDataForAllLiveResources && elapsedTime < cMinDelayBeforeLiveDecodedPrune)
+ if (!shouldDestroyDecodedDataForAllLiveResources && elapsedTime < cMinDelayBeforeLiveDecodedPrune) {
+ LOG(ResourceLoading, " current time is less than min delay before pruning (%.3fms)", elapsedTime.milliseconds());
return;
+ }
// Destroy our decoded data. This will remove us from m_liveDecodedResources, and possibly move us
// to a different LRU list in m_allResources.
@@ -343,6 +350,8 @@
void MemoryCache::pruneDeadResources()
{
+ LOG(ResourceLoading, "MemoryCache::pruneDeadResources");
+
unsigned capacity = deadCapacity();
if (capacity && m_deadSize <= capacity)
return;
@@ -355,6 +364,9 @@
{
if (m_inPruneResources)
return;
+
+ LOG(ResourceLoading, "MemoryCache::pruneDeadResourcesToSize(%d)", targetSize);
+
SetForScope<bool> reentrancyProtector(m_inPruneResources, true);
if (targetSize && m_deadSize <= targetSize)
@@ -366,9 +378,12 @@
// destroyDecodedData() can alter the LRUList.
auto lruList = copyToVector(*m_allResources[i]);
+ LOG(ResourceLoading, " lru list (size %lu) - flushing stage", lruList.size());
+
// First flush all the decoded data in this queue.
// Remove from the head, since this is the least frequently accessed of the objects.
for (auto& resource : lruList) {
+ LOG(ResourceLoading, " lru resource %p - in cache %d, has clients %d, preloaded %d, loaded %d", resource, resource->inCache(), resource->hasClients(), resource->isPreloaded(), resource->isLoaded());
if (!resource->inCache())
continue;
@@ -376,6 +391,9 @@
// Destroy our decoded data. This will remove us from
// m_liveDecodedResources, and possibly move us to a different
// LRU list in m_allResources.
+
+ LOG(ResourceLoading, " lru resource %p destroyDecodedData", resource);
+
resource->destroyDecodedData();
if (targetSize && m_deadSize <= targetSize)
@@ -383,9 +401,12 @@
}
}
+ LOG(ResourceLoading, " lru list (size %lu) - eviction stage", lruList.size());
+
// Now evict objects from this list.
// Remove from the head, since this is the least frequently accessed of the objects.
for (auto& resource : lruList) {
+ LOG(ResourceLoading, " lru resource %p - in cache %d, has clients %d, preloaded %d, loaded %d", resource, resource->inCache(), resource->hasClients(), resource->isPreloaded(), resource->isLoaded());
if (!resource->inCache())
continue;
@@ -418,7 +439,7 @@
void MemoryCache::remove(CachedResource& resource)
{
ASSERT(WTF::isMainThread());
- LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", &resource, resource.url().string().latin1().data());
+ LOG(ResourceLoading, "Evicting resource %p for '%.255s' from cache", &resource, resource.url().string().latin1().data());
// The resource may have already been removed by someone other than our caller,
// who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
if (auto* resources = sessionResourceMap(resource.sessionID())) {
@@ -437,8 +458,10 @@
removeFromLRUList(resource);
removeFromLiveDecodedResourcesList(resource);
adjustSize(resource.hasClients(), -static_cast<long long>(resource.size()));
- } else
+ } else {
ASSERT(resources->get(key) != &resource);
+ LOG(ResourceLoading, " resource %p is not in cache", &resource);
+ }
}
resource.deleteIfPossible();
@@ -775,7 +798,7 @@
WTFLogAlways("\nList %d:\n", i);
for (auto* resource : *m_allResources[i]) {
if (includeLive || !resource->hasClients())
- WTFLogAlways(" %.100s %.1fK, %.1fK, accesses: %u, clients: %d\n", resource->url().string().utf8().data(), resource->decodedSize() / 1024.0f, (resource->encodedSize() + resource->overheadSize()) / 1024.0f, resource->accessCount(), resource->numberOfClients());
+ WTFLogAlways(" %p %.255s %.1fK, %.1fK, accesses: %u, clients: %d\n", resource, resource->url().string().utf8().data(), resource->decodedSize() / 1024.0f, (resource->encodedSize() + resource->overheadSize()) / 1024.0f, resource->accessCount(), resource->numberOfClients());
}
}
}