summarylogtreecommitdiffstats
path: root/vaapi-fix-wayland-init.patch
blob: a07814969f41a2caa07d18e277b1f326c62595fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From 4a04af6bbd5b1a55e2e1a7c22f13f8571c2dd7ed Mon Sep 17 00:00:00 2001
From: Julien Isorce <julien.isorce@chromium.org>
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 <magchen@chromium.org>
> Reviewed-by: Kenneth Russell <kbr@chromium.org>
> Commit-Queue: Julien Isorce <julien.isorce@chromium.org>
> 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 <acourbot@chromium.org>
Reviewed-by: Maggie Chen <magchen@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Julien Isorce <julien.isorce@chromium.org>
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.