Commit 1a9c502d authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

Do not block shutdown for process launch on Windows

Launching a process is racy with browser shutdown, and blocks it. So we
see shutdown hangs when process launch takes a long time. This CL makes
the process launcher use a CONTINUE_ON_SHUTDOWN instead of
BLOCK_SHUTDOWN task on Windows where it's presumably safe to do so given
no non-leaky globals are used, and based on local testing. This is not
safe on Linux since the process launcher there uses SandboxHostLinux
which is a non-leaky base::Singleton.

R=brucedawson,gab
BUG=830954

Change-Id: Ia8c5295924288819dcfdcc087d282a05e6ee7e55
Reviewed-on: https://chromium-review.googlesource.com/1020720Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553294}
parent aec08d44
...@@ -208,13 +208,25 @@ base::SingleThreadTaskRunner* GetProcessLauncherTaskRunner() { ...@@ -208,13 +208,25 @@ base::SingleThreadTaskRunner* GetProcessLauncherTaskRunner() {
launcher_task_runner( launcher_task_runner(
android::LauncherThread::GetMessageLoop()->task_runner()); android::LauncherThread::GetMessageLoop()->task_runner());
return (*launcher_task_runner).get(); return (*launcher_task_runner).get();
#else // defined(OS_ANDROID) #else // defined(OS_ANDROID)
// TODO(http://crbug.com/820200): Investigate whether we could use // TODO(http://crbug.com/820200): Investigate whether we could use
// SequencedTaskRunner on platforms other than Windows. // SequencedTaskRunner on platforms other than Windows.
// Do not block shutdown as process creation can take a while and be reported as
// a hang. This doesn't work on Linux because of SandboxHostLinux non-leaky
// singleton, so only enable this on Windows where the hang was reported, and
// it is safe to do so.
#if defined(OS_WIN)
constexpr base::TaskShutdownBehavior shutdown_behavior =
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN;
#else
constexpr base::TaskShutdownBehavior shutdown_behavior =
base::TaskShutdownBehavior::BLOCK_SHUTDOWN;
#endif // defined(OS_WIN)
static base::LazySingleThreadTaskRunner launcher_task_runner = static base::LazySingleThreadTaskRunner launcher_task_runner =
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER( LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
base::TaskTraits({base::MayBlock(), base::TaskPriority::USER_BLOCKING, base::TaskTraits({base::MayBlock(), base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN}), shutdown_behavior}),
base::SingleThreadTaskRunnerThreadMode::DEDICATED); base::SingleThreadTaskRunnerThreadMode::DEDICATED);
return launcher_task_runner.Get().get(); return launcher_task_runner.Get().get();
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
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