Skip to content

Instantly share code, notes, and snippets.

@lauromoura
Created March 24, 2020 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lauromoura/d7ba63b7316c5f81903aaf7f985118b2 to your computer and use it in GitHub Desktop.
Save lauromoura/d7ba63b7316c5f81903aaf7f985118b2 to your computer and use it in GitHub Desktop.
WebkitGTK disk-cache fix
From a5b0d220c1527e5a06db46505bc56f7c49ae57b5 Mon Sep 17 00:00:00 2001
From: Lauro Moura <lmoura@igalia.com>
Date: Tue, 24 Mar 2020 00:28:13 -0300
Subject: [PATCH xserver] [GTK] Using --skip-failing-tests cause some
disk-cache tests to fail https://bugs.webkit.org/show_bug.cgi?id=209338
Reviewed by NOBODY (OOPS!).
GLIB's getVolumeFreeSpace implementation requires the file to exist to
return the correct size. During the NetworkProcess initialization it
caused the cache storage to be initially defined with zero capacity.
Further calls to NetworkProcess.setCacheModel worked as expected due
to the file already existing, updating the capacity correctly.
This issue was initially hidden due to
disk-cache/disk-cache-disable.html being one of the first cache tests
run, as it would disable/enable the cache, overriding the initial zero
capacity.
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::open):
---
Source/WebKit/ChangeLog | 21 +++++++++++++++++++
.../NetworkProcess/cache/NetworkCache.cpp | 10 +++++++++
2 files changed, 31 insertions(+)
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index c6bda312a47..1fc8890b335 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,24 @@
+2020-03-23 Lauro Moura <lmoura@igalia.com>
+
+ [GTK] Using --skip-failing-tests cause some disk-cache tests to fail
+ https://bugs.webkit.org/show_bug.cgi?id=209338
+
+ Reviewed by NOBODY (OOPS!).
+
+ GLIB's getVolumeFreeSpace implementation requires the file to exist to
+ return the correct size. During the NetworkProcess initialization it
+ caused the cache storage to be initially defined with zero capacity.
+ Further calls to NetworkProcess.setCacheModel worked as expected due
+ to the file already existing, updating the capacity correctly.
+
+ This issue was initially hidden due to
+ disk-cache/disk-cache-disable.html being one of the first cache tests
+ run, as it would disable/enable the cache, overriding the initial zero
+ capacity.
+
+ * NetworkProcess/cache/NetworkCache.cpp:
+ (WebKit::NetworkCache::Cache::open):
+
2020-03-23 David Kilzer <ddkilzer@apple.com>
IPC::Decoder::decodeFixedLengthData() should be marked WARN_UNUSED_RETURN
diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
index 72ba6bff3da..bbaa8967b2f 100644
--- a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
+++ b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
@@ -86,6 +86,16 @@ RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePat
if (!storage)
return nullptr;
+#if PLATFORM(GTK) || PLATFORM(WPE)
+ // GLIB's getVolumeFreeSpace requires the file to exist to work correctly.
+ // As this may not be the case when initializing the NetworkProcess, the first call
+ // to computeCapacity may fail and we must try again after the file is created.
+ if (!capacity) {
+ capacity = computeCapacity(networkProcess.cacheModel(), cachePath);
+ storage->setCapacity(capacity);
+ }
+#endif
+
return adoptRef(*new Cache(networkProcess, cachePath, storage.releaseNonNull(), options, sessionID));
}
--
2.20.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment