Commit c7e363c6 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[GPU] Explicitly initialize the base::ThreadPoolInstance in time for angle::InitializePlatform

This is equivalent to the ThreadPoolInstance configuration that the
GPU process was implicitly getting from ChildProcess::ChildProcess
(constructed from GPUProcess::GPUProcess). Modulo the added ability to
explicitly name this ThreadPool and have independent metrics :).

The ThreadPoolInstance is still started at virtually the same order as
before so semantics should be equivalent for the GPU process.

This is necessary otherwise etienneb's fix for crbug.com/1091259
is a no-op in production due to the early-bail if there's no
ThreadPoolInstance on init (added for tests, breaks prod).

R=chromium-metrics-reviews@google.com, sunnyps@chromium.org

Bug: 1091259
Change-Id: I3ce25ac70bb4d1980e3d38ae6f90851041632bd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255655
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781944}
parent 865d1b47
......@@ -329,10 +329,15 @@ int GpuMain(const MainFunctionParams& parameters) {
gpu_init->set_sandbox_helper(&sandbox_helper);
// Since GPU initialization calls into skia, its important to initialize skia
// Since GPU initialization calls into skia, it's important to initialize skia
// before it.
InitializeSkia();
// Create the ThreadPool before invoking |gpu_init| as it needs the ThreadPool
// (in angle::InitializePlatform()). Do not start it until after the sandbox
// is initialized however to avoid creating threads outside the sandbox.
base::ThreadPoolInstance::Create("GPU");
// Gpu initialization may fail for various reasons, in which case we will need
// to tear down this process. However, we can not do so safely until the IPC
// channel is set up, because the detection of early return of a child process
......@@ -347,6 +352,9 @@ int GpuMain(const MainFunctionParams& parameters) {
GetContentClient()->SetGpuInfo(gpu_init->gpu_info());
// Start the ThreadPoolInstance now that the sandbox is initialized.
base::ThreadPoolInstance::Get()->StartWithDefaultParams();
const base::ThreadPriority io_thread_priority =
base::FeatureList::IsEnabled(features::kGpuUseDisplayThreadPriority)
? base::ThreadPriority::DISPLAY
......
......@@ -211980,6 +211980,7 @@ regressions. -->
label="ThreadPool for the browser process."/>
<suffix base="true" name="ContentChild"
label="ThreadPools for various instantiations of content::ChildProcess."/>
<suffix base="true" name="GPU" label="ThreadPool for the gpu process."/>
<suffix base="true" name="Renderer"
label="ThreadPools for renderer processes."/>
<affected-histogram name="ThreadPool.DetachDuration"/>
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