Skip to content

Commit 6a1d3e8

Browse files
nornagonJohn Kleinschmidt
authored andcommitted
fix: backport workaround for blockfile cache corruption on macOS (electron#19212)
backport of https://chromium-review.googlesource.com/c/chromium/src/+/1347109
1 parent bfd7412 commit 6a1d3e8

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

patches/common/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ fix_uap_in_imagebitmaploader_filereaderloader.patch
109109
fire_caret_location_change_when_focus_moves_from_ui_to_content.patch
110110
do_not_show_virtual_keyboard_for_all_mouse_inputs.patch
111111
setup_the_observer_before_calling_displayvirtualkeyboard.patch
112+
workaround_apparent_data_corruption_in_blockfile_on_os_x_10_14_by.patch
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Maks Orlovich <morlovich@chromium.org>
3+
Date: Thu, 22 Nov 2018 14:05:57 +0000
4+
Subject: Workaround apparent data corruption in blockfile on OS X 10.14 by
5+
switching backends.
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
9+
10+
This is slower, but it's better than not loading pages at all since important resources
11+
got corrupted:(
12+
13+
Bug: 899874
14+
Change-Id: I19f7eccff0c8aa119e522aee9cf728934906b917
15+
Reviewed-on: https://chromium-review.googlesource.com/c/1347109
16+
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
17+
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
18+
Reviewed-by: Bence Béky <bnc@chromium.org>
19+
Cr-Commit-Position: refs/heads/master@{#610404}
20+
21+
diff --git a/components/network_session_configurator/browser/network_session_configurator.cc b/components/network_session_configurator/browser/network_session_configurator.cc
22+
index 21d34cfab2c426ae367148433d21916fcd92c757..8d98b44fe167f2229dc7204027878f79be533b83 100644
23+
--- a/components/network_session_configurator/browser/network_session_configurator.cc
24+
+++ b/components/network_session_configurator/browser/network_session_configurator.cc
25+
@@ -27,6 +27,10 @@
26+
#include "net/third_party/quic/core/quic_packets.h"
27+
#include "net/third_party/spdy/core/spdy_protocol.h"
28+
29+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
30+
+#include "base/mac/mac_util.h"
31+
+#endif
32+
+
33+
namespace {
34+
35+
// Map from name to value for all parameters associate with a field trial.
36+
@@ -589,12 +593,25 @@ net::URLRequestContextBuilder::HttpCacheParams::Type ChooseCacheType(
37+
if (opt_value.empty() || base::LowerCaseEqualsASCII(opt_value, "on"))
38+
return net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
39+
}
40+
+
41+
const std::string experiment_name =
42+
base::FieldTrialList::FindFullName("SimpleCacheTrial");
43+
if (base::StartsWith(experiment_name, "Disable",
44+
base::CompareCase::INSENSITIVE_ASCII)) {
45+
return net::URLRequestContextBuilder::HttpCacheParams::DISK_BLOCKFILE;
46+
}
47+
+
48+
+ // Blockfile breaks on OSX 10.14 (see https://crbug.com/899874); so use
49+
+ // SimpleCache even when we don't enable it via experiment, as long as we
50+
+ // don't force it off (not used at this time). This unfortunately
51+
+ // muddles the experiment data, but as this was written to be considered for
52+
+ // backport, having it behave differently than in stable would be a bigger
53+
+ // problem.
54+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
55+
+ if (base::mac::IsAtLeastOS10_14())
56+
+ return net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
57+
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
58+
+
59+
if (base::StartsWith(experiment_name, "ExperimentYes",
60+
base::CompareCase::INSENSITIVE_ASCII)) {
61+
return net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
62+
diff --git a/components/network_session_configurator/browser/network_session_configurator_unittest.cc b/components/network_session_configurator/browser/network_session_configurator_unittest.cc
63+
index 1e3f7b89c3c1ef5b3da2c89516acd13ac1ad283f..80e5d7ada3f0044f16aeb73891e20316c6cd2461 100644
64+
--- a/components/network_session_configurator/browser/network_session_configurator_unittest.cc
65+
+++ b/components/network_session_configurator/browser/network_session_configurator_unittest.cc
66+
@@ -25,6 +25,10 @@
67+
#include "net/url_request/url_request_context_builder.h"
68+
#include "testing/gtest/include/gtest/gtest.h"
69+
70+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
71+
+#include "base/mac/mac_util.h"
72+
+#endif
73+
+
74+
namespace network_session_configurator {
75+
76+
class NetworkSessionConfiguratorTest : public testing::Test {
77+
@@ -735,6 +739,12 @@ TEST_F(NetworkSessionConfiguratorTest, DefaultCacheBackend) {
78+
#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)
79+
EXPECT_EQ(net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE,
80+
ChooseCacheType(command_line));
81+
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
82+
+ EXPECT_EQ(
83+
+ base::mac::IsAtLeastOS10_14()
84+
+ ? net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE
85+
+ : net::URLRequestContextBuilder::HttpCacheParams::DISK_BLOCKFILE,
86+
+ ChooseCacheType(command_line));
87+
#else
88+
EXPECT_EQ(net::URLRequestContextBuilder::HttpCacheParams::DISK_BLOCKFILE,
89+
ChooseCacheType(command_line));

0 commit comments

Comments
 (0)