From 4a04af6bbd5b1a55e2e1a7c22f13f8571c2dd7ed Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Fri, 24 Jan 2020 00:30:33 +0000 Subject: [PATCH] Reland "Call PreSandboxStartup after GL initialization in GpuInit" This is a reland of d17c53b341adcfc9e2626162536a08c9f3e24017 Original change's description: > Call PreSandboxStartup after GL initialization in GpuInit > > Fixes "vaInitialize failed: unknown libva error" > on Wayland with LIBVA_DRIVER_NAME=i965 > > VaapiWrapper relies on the GL implementation to decide > which display to use. If the GL implementation is none, > then VaapiWrapper is likely to do the wrong guess resulting > in the above error. > > Bug: 1041229 > Change-Id: I1255a032a5e14b3aaffe3026a886de7e6d9ff0d7 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011640 > Reviewed-by: Maggie Chen > Reviewed-by: Kenneth Russell > Commit-Queue: Julien Isorce > Cr-Commit-Position: refs/heads/master@{#733847} Bug: 1041229 Change-Id: I8e268596a1e2a1b3da7d7e75b8943accc85dd2d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013806 Reviewed-by: Alexandre Courbot Reviewed-by: Maggie Chen Reviewed-by: Kenneth Russell Commit-Queue: Julien Isorce Cr-Commit-Position: refs/heads/master@{#734746} --- diff --git a/gpu/ipc/service/gpu_init.cc b/gpu/ipc/service/gpu_init.cc index 04883fc..4e63f7a 100644 --- a/gpu/ipc/service/gpu_init.cc +++ b/gpu/ipc/service/gpu_init.cc @@ -221,10 +221,16 @@ delayed_watchdog_enable = true; #endif +#if defined(OS_LINUX) // PreSandbox is mainly for resource handling and not related to the GPU // driver, it doesn't need the GPU watchdog. The loadLibrary may take long // time that killing and restarting the GPU process will not help. - sandbox_helper_->PreSandboxStartup(); + if (gpu_preferences_.gpu_sandbox_start_early) { + // The sandbox will be started earlier than usual (i.e. before GL) so + // execute the pre-sandbox steps now. + sandbox_helper_->PreSandboxStartup(); + } +#endif // Start the GPU watchdog only after anything that is expected to be time // consuming has completed, otherwise the process is liable to be aborted. @@ -320,6 +326,23 @@ } } + // The ContentSandboxHelper is currently the only one implementation of + // gpu::GpuSandboxHelper and it has no dependency. Except on Linux where + // VaapiWrapper checks the GL implementation to determine which display + // to use. So call PreSandboxStartup after GL initialization. But make + // sure the watchdog is paused as loadLibrary may take a long time and + // restarting the GPU process will not help. + if (!attempted_startsandbox) { + if (watchdog_thread_) + watchdog_thread_->PauseWatchdog(); + + // The sandbox is not started yet. + sandbox_helper_->PreSandboxStartup(); + + if (watchdog_thread_) + watchdog_thread_->ResumeWatchdog(); + } + bool gl_disabled = gl::GetGLImplementation() == gl::kGLImplementationDisabled; // Compute passthrough decoder status before ComputeGpuFeatureInfo below.