Commit 3e84de85 authored by Janusz Majnert's avatar Janusz Majnert Committed by Commit Bot

Disable prerendering in single-process mode

Prerendering causes creation of additional RenderProcessHostImpl
objects, which hold it's own blink instance. In single-process mode this
causes blink to be initialized multiple times, which in turn triggers a
DCHECK "FATAL:platform.cc(180)] Check failed: !did_initialize_blink_."

This change disables prerendering in single-process mode.

Test: load http://jmajnert.github.io/tests/prerender_landing.html in
      debug single-process build

Bug: 1151372
Change-Id: I23992afbf681089b4b25e084eeccf470484b2320
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550560Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830249}
parent 6c4edc0a
......@@ -46,6 +46,7 @@
#include "components/no_state_prefetch/common/prerender_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/unique_receiver_set.h"
......@@ -1654,4 +1655,14 @@ TEST_F(PrerenderTest, PrerenderContentsIncrementsByteCount) {
EXPECT_EQ(12, prerender_contents->network_bytes());
}
TEST_F(PrerenderTest, NoPrerenderInSingleProcess) {
GURL url("http://www.google.com/");
auto* command_line = base::CommandLine::ForCurrentProcess();
ASSERT_TRUE(command_line != nullptr);
command_line->AppendSwitch(switches::kSingleProcess);
EXPECT_FALSE(AddSimplePrerender(url));
histogram_tester().ExpectUniqueSample("Prerender.FinalStatus",
FINAL_STATUS_SINGLE_PROCESS, 1);
}
} // namespace prerender
......@@ -15,6 +15,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
......@@ -49,6 +50,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "net/http/http_cache.h"
#include "net/http/http_request_headers.h"
......@@ -491,6 +493,13 @@ PrerenderManager::AddPrerenderWithPreconnectFallback(
SessionStorageNamespace* session_storage_namespace) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line && command_line->HasSwitch(switches::kSingleProcess)) {
SkipPrerenderContentsAndMaybePreconnect(url_arg, origin,
FINAL_STATUS_SINGLE_PROCESS);
return nullptr;
}
// Disallow prerendering on low end devices.
if (IsLowEndDevice()) {
SkipPrerenderContentsAndMaybePreconnect(url_arg, origin,
......@@ -925,7 +934,7 @@ void PrerenderManager::SkipPrerenderContentsAndMaybePreconnect(
}
static_assert(
FINAL_STATUS_MAX == FINAL_STATUS_NAVIGATION_PREDICTOR_HOLDBACK + 1,
FINAL_STATUS_MAX == FINAL_STATUS_SINGLE_PROCESS + 1,
"Consider whether a failed prerender should fallback to preconnect");
}
......
......@@ -74,6 +74,7 @@ const char* kFinalStatusNames[] = {
"GWS Holdback",
"Unknown",
"Navigation Predictor Holdback",
"Single Process Mode",
"Max",
};
static_assert(base::size(kFinalStatusNames) == FINAL_STATUS_MAX + 1,
......
......@@ -79,6 +79,7 @@ enum FinalStatus {
FINAL_STATUS_GWS_HOLDBACK = 59,
FINAL_STATUS_UNKNOWN = 60,
FINAL_STATUS_NAVIGATION_PREDICTOR_HOLDBACK = 61,
FINAL_STATUS_SINGLE_PROCESS = 62,
FINAL_STATUS_MAX,
};
......@@ -88,4 +89,4 @@ const char* NameFromFinalStatus(FinalStatus final_status);
} // namespace prerender
#endif // COMPONENTS_NO_STATE_PREFETCH_COMMON_PRERENDER_FINAL_STATUS_H_
\ No newline at end of file
#endif // COMPONENTS_NO_STATE_PREFETCH_COMMON_PRERENDER_FINAL_STATUS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment