Commit 3662e2b2 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

Allow in-process vulkan for webview

Webview currently crashes on context loss:
https://source.chromium.org/chromium/chromium/src/+/master:android_webview/browser/gfx/output_surface_provider_webview.cc;drc=8bab2d6d39d8399e64d5f8369226403495e86d98;l=38

So that provides a shortcut for enabling vulkan for webview without
having proper clean up.

Move the kWebViewEnableVulkan to gpu/config, and use it to enable vulkan
for in-process gpu, only on android.

Bug: 1095744
Change-Id: Idcf0df6f2776012c2ea695d161f457ad48dde203
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499219
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820971}
parent 8aab07c1
......@@ -8,11 +8,11 @@
#include "android_webview/browser/gfx/aw_vulkan_context_provider.h"
#include "android_webview/browser_jni_headers/AwDrawFnImpl_jni.h"
#include "android_webview/common/aw_switches.h"
#include "base/command_line.h"
#include "base/trace_event/trace_event.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/config/gpu_switches.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/src/gpu/vk/GrVkSecondaryCBDrawContext.h"
......
......@@ -12,7 +12,6 @@
#include "android_webview/browser/gfx/parent_output_surface.h"
#include "android_webview/browser/gfx/skia_output_surface_dependency_webview.h"
#include "android_webview/browser/gfx/task_queue_web_view.h"
#include "android_webview/common/aw_switches.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/feature_list.h"
......@@ -20,6 +19,7 @@
#include "components/viz/common/features.h"
#include "components/viz/service/display_embedder/skia_output_surface_impl.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/ipc/single_task_sequence.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
......
......@@ -14,9 +14,6 @@ const char kWebViewSandboxedRenderer[] = "webview-sandboxed-renderer";
const char kWebViewDisableSafebrowsingSupport[] =
"webview-disable-safebrowsing-support";
// Used to enable vulkan draw mode instead of interop draw mode for webview.
const char kWebViewEnableVulkan[] = "webview-enable-vulkan";
// Enables SafeBrowsing and causes WebView to treat all resources as malicious.
// Use care: this will block all resources from loading.
const char kWebViewSafebrowsingBlockAllResources[] =
......
......@@ -10,7 +10,6 @@ namespace switches {
extern const char kWebViewLogJsConsoleMessages[];
extern const char kWebViewSandboxedRenderer[];
extern const char kWebViewDisableSafebrowsingSupport[];
extern const char kWebViewEnableVulkan[];
extern const char kWebViewSafebrowsingBlockAllResources[];
extern const char kHighlightAllWebViews[];
extern const char kWebViewVerboseLogging[];
......
......@@ -84,4 +84,7 @@ const char kGpuRevision[] = "gpu-revision";
// collection GPU process.
const char kGpuDriverVersion[] = "gpu-driver-version";
// Used to enable vulkan draw mode instead of interop draw mode for webview.
const char kWebViewEnableVulkan[] = "webview-enable-vulkan";
} // namespace switches
......@@ -29,6 +29,7 @@ GPU_EXPORT extern const char kGpuDeviceId[];
GPU_EXPORT extern const char kGpuSubSystemId[];
GPU_EXPORT extern const char kGpuRevision[];
GPU_EXPORT extern const char kGpuDriverVersion[];
GPU_EXPORT extern const char kWebViewEnableVulkan[];
} // namespace switches
......
......@@ -137,6 +137,7 @@ class GpuWatchdogInit {
// TODO(https://crbug.com/1095744): We currently do not handle
// VK_ERROR_DEVICE_LOST in in-process-gpu.
// Android WebView is allowed for now because it CHECKs on context loss.
void DisableInProcessGpuVulkan(GpuFeatureInfo* gpu_feature_info,
GpuPreferences* gpu_preferences) {
if (gpu_feature_info->status_values[GPU_FEATURE_TYPE_VULKAN] ==
......@@ -611,7 +612,13 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
InitializeGLThreadSafe(command_line, gpu_preferences_, &gpu_info_,
&gpu_feature_info_);
DisableInProcessGpuVulkan(&gpu_feature_info_, &gpu_preferences_);
if (!command_line->HasSwitch(switches::kWebViewEnableVulkan)) {
DisableInProcessGpuVulkan(&gpu_feature_info_, &gpu_preferences_);
} else if (gpu_feature_info_.status_values[GPU_FEATURE_TYPE_VULKAN] ==
kGpuFeatureStatusEnabled) {
bool result = InitializeVulkan();
CHECK(result);
}
default_offscreen_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation());
......
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