From a3fda997a835bd0ca0ddc6363fafc03c0d9f55d1 Mon Sep 17 00:00:00 2001 From: Zhenyao Mo Date: Sat, 16 Sep 2017 01:34:40 +0000 Subject: [PATCH] Move WebGL blacklist decision making to GPU process. Still, if we pass in a commandline switch to disable WebGL1/2, they are still pass to renderer process as WebPreferences. BUG=744658 TEST=bots R=kbr@chromium.org,piman@chromium.org Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I15fc34bc72d1c86d31d392bd34230d366564c318 Reviewed-on: https://chromium-review.googlesource.com/659100 Commit-Queue: Zhenyao Mo Reviewed-by: Daniel Cheng Reviewed-by: Bill Budge Reviewed-by: Bo Reviewed-by: Kenneth Russell Reviewed-by: Antoine Labour Cr-Commit-Position: refs/heads/master@{#502466} --- android_webview/browser/aw_settings.cc | 7 +-- chrome/browser/about_flags.cc | 9 ---- .../browser/chrome_content_browser_client.cc | 6 ++- chrome/browser/flag_descriptions.cc | 3 -- chrome/browser/flag_descriptions.h | 3 -- content/browser/gpu/compositor_util.cc | 5 ++- .../gpu/gpu_data_manager_impl_private.cc | 15 +++---- .../renderer_host/render_process_host_impl.cc | 1 - .../renderer_host/render_view_host_impl.cc | 9 ++-- .../common/common_param_traits_macros.h | 3 +- content/public/common/content_switches.cc | 7 ++- content/public/common/content_switches.h | 3 +- content/public/common/web_preferences.cc | 3 +- content/public/common/web_preferences.h | 3 +- .../pepper/pepper_plugin_instance_impl.cc | 5 --- .../pepper/pepper_plugin_instance_metrics.cc | 26 ----------- .../pepper/pepper_plugin_instance_metrics.h | 11 ----- .../pepper/ppapi_preferences_builder.cc | 1 - content/renderer/render_frame_impl.cc | 7 +-- content/renderer/render_frame_impl.h | 2 +- content/renderer/render_view_impl.cc | 5 +-- .../layout_test/blink_test_helpers.cc | 1 - content/shell/test_runner/test_preferences.cc | 1 - content/shell/test_runner/test_preferences.h | 1 - content/shell/test_runner/test_runner.cc | 2 - gpu/command_buffer/service/context_group.cc | 28 +++++++++--- gpu/command_buffer/service/gpu_preferences.h | 3 -- gpu/config/gpu_feature_info.h | 1 + gpu/config/gpu_util.cc | 45 ++++++++++++++++++- gpu/config/software_rendering_list.json | 6 +++ gpu/ipc/common/gpu_feature_info.mojom | 1 + .../common/gpu_feature_info_struct_traits.h | 5 +++ gpu/ipc/common/gpu_preferences.mojom | 1 - .../common/gpu_preferences_struct_traits.h | 4 -- ppapi/shared_impl/ppapi_preferences.h | 1 - .../backface-visibility-webgl.html | 9 ---- .../draws-content/webgl-background-layer.html | 1 - .../webgl-simple-background.html | 3 -- .../visibility-simple-webgl-layer.html | 1 - .../webgl/webgl-background-color.html | 3 -- .../compositing/webgl/webgl-no-alpha.html | 1 - .../webgl/webgl-nonpremultiplied-blend.html | 3 -- .../compositing/webgl/webgl-reflection.html | 3 -- .../compositing/webgl/webgl-repaint.html | 3 -- .../canvas/webgl/canvas-getContext-crash.html | 3 +- .../canvas/webgl/canvas-resize-crash.html | 10 ----- .../fast/canvas/webgl/pixelated.html | 1 - .../fast/canvas/webgl/resources/webgl-test.js | 4 -- .../webgl/texImage-imageBitmap-from-blob.html | 1 - .../texImage-imageBitmap-from-canvas.html | 1 - .../texImage-imageBitmap-from-image.html | 1 - ...mageBitmap-from-imageBitmap-from-blob.html | 1 - ...geBitmap-from-imageBitmap-from-canvas.html | 1 - ...ageBitmap-from-imageBitmap-from-image.html | 1 - ...itmap-from-imageBitmap-from-imageData.html | 1 - ...rom-imageBitmap-from-offscreen-canvas.html | 1 - .../texImage-imageBitmap-from-imageData.html | 1 - ...age-imageBitmap-from-offscreen-canvas.html | 1 - .../texImage-imageBitmap-from-video.html | 1 - ...texImage-imageBitmap-structured-clone.html | 1 - .../texImage-imageBitmap-transferable.html | 1 - ...texImage-video-last-uploaded-metadata.html | 1 - .../webgl/webgl-composite-modes-repaint.html | 1 - .../webgl-composite-modes-tabswitching.html | 1 - .../canvas/webgl/webgl-composite-modes.html | 1 - .../fast/canvas/webgl/webgl-layer-update.html | 2 - .../resources/webgl-test.js | 4 -- .../webgl/origin-clean-conformance.html | 1 - ...remote-image-allowed-with-credentials.html | 1 - ...ebgl-remote-read-remote-image-allowed.html | 1 - ...d-remote-image-blocked-no-crossorigin.html | 1 - .../core/exported/LocalFrameClientImpl.cpp | 8 ++-- .../core/exported/LocalFrameClientImpl.h | 2 +- .../Source/core/exported/WebSettingsImpl.cpp | 8 +++- .../Source/core/exported/WebSettingsImpl.h | 3 +- .../Source/core/frame/LocalFrameClient.h | 4 +- .../WebKit/Source/core/frame/Settings.json5 | 10 +++-- .../Source/core/html/HTMLCanvasElement.cpp | 36 ++++++++++----- .../Source/core/html/HTMLCanvasElement.h | 4 +- .../html/canvas/CanvasRenderingContextHost.h | 8 +++- .../core/offscreencanvas/OffscreenCanvas.h | 4 +- .../webgl/WebGLRenderingContextBase.cpp | 22 ++++++--- .../WebKit/public/web/WebFrameClient.h | 4 +- third_party/WebKit/public/web/WebSettings.h | 3 +- ui/gl/gl_switches.cc | 6 --- ui/gl/gl_switches.h | 2 - 86 files changed, 198 insertions(+), 232 deletions(-) diff --git a/android_webview/browser/aw_settings.cc b/android_webview/browser/aw_settings.cc index a4e902eb82b6d8..509c20662507e7 100644 --- a/android_webview/browser/aw_settings.cc +++ b/android_webview/browser/aw_settings.cc @@ -434,9 +434,10 @@ void AwSettings::PopulateWebPreferencesLocked(JNIEnv* env, // Using 100M instead of max int to avoid overflows. web_prefs->minimum_accelerated_2d_canvas_size = 100 * 1000 * 1000; } - web_prefs->experimental_webgl_enabled = - web_prefs->experimental_webgl_enabled && - enable_supported_hardware_accelerated_features; + web_prefs->webgl1_enabled = web_prefs->webgl1_enabled && + enable_supported_hardware_accelerated_features; + web_prefs->webgl2_enabled = web_prefs->webgl2_enabled && + enable_supported_hardware_accelerated_features; // If strict mixed content checking is enabled then running should not be // allowed. diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 0773c2e7dcea71..84ad4680c21f3b 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -420,12 +420,6 @@ const FeatureEntry::Choice kEnableGpuRasterizationChoices[] = { switches::kForceGpuRasterization, ""}, }; -const FeatureEntry::Choice kEnableWebGL2Choices[] = { - {flags_ui::kGenericExperimentChoiceDefault, "", ""}, - {flags_ui::kGenericExperimentChoiceEnabled, switches::kEnableES3APIs, ""}, - {flags_ui::kGenericExperimentChoiceDisabled, switches::kDisableES3APIs, ""}, -}; - #if defined(OS_CHROMEOS) const FeatureEntry::Choice kMemoryPressureThresholdChoices[] = { {flags_ui::kGenericExperimentChoiceDefault, "", ""}, @@ -2445,9 +2439,6 @@ const FeatureEntry kFeatureEntries[] = { flag_descriptions::kAutomaticTabDiscardingDescription, kOsWin | kOsMac, FEATURE_VALUE_TYPE(features::kAutomaticTabDiscarding)}, #endif // OS_WIN || OS_MACOSX - {"enable-es3-apis", flag_descriptions::kWebgl2Name, - flag_descriptions::kWebgl2Description, kOsAll, - MULTI_VALUE_TYPE(kEnableWebGL2Choices)}, {"enable-webfonts-intervention-v2", flag_descriptions::kEnableWebfontsInterventionName, flag_descriptions::kEnableWebfontsInterventionDescription, kOsAll, diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 82a5d58d7949a0..c701a4309ccc23 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -2448,8 +2448,10 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs( web_prefs->loads_images_automatically = prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); - if (prefs->GetBoolean(prefs::kDisable3DAPIs)) - web_prefs->experimental_webgl_enabled = false; + if (prefs->GetBoolean(prefs::kDisable3DAPIs)) { + web_prefs->webgl1_enabled = false; + web_prefs->webgl2_enabled = false; + } web_prefs->allow_running_insecure_content = prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent); diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index f4535b8f90c02e..e20ce97a3190c6 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc @@ -1430,9 +1430,6 @@ const char kWalletServiceUseSandboxName[] = const char kWalletServiceUseSandboxDescription[] = "For developers: use the sandbox service for Google Payments API calls."; -const char kWebgl2Name[] = "WebGL 2.0"; -const char kWebgl2Description[] = "Allow web applications to access WebGL 2.0."; - const char kWebglDraftExtensionsName[] = "WebGL Draft Extensions"; const char kWebglDraftExtensionsDescription[] = "Enabling this option allows web applications to access the WebGL " diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index d6ff3e6b4ce72e..983524dfbfe155 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h @@ -881,9 +881,6 @@ extern const char kVideoRotateToFullscreenDescription[]; extern const char kWalletServiceUseSandboxName[]; extern const char kWalletServiceUseSandboxDescription[]; -extern const char kWebgl2Name[]; -extern const char kWebgl2Description[]; - extern const char kWebglDraftExtensionsName[]; extern const char kWebglDraftExtensionsDescription[]; diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc index b5ddf2ef59cc1b..354521ac1f077c 100644 --- a/content/browser/gpu/compositor_util.cc +++ b/content/browser/gpu/compositor_util.cc @@ -80,7 +80,7 @@ const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { " and hardware acceleration will be unavailable.", true}, {kWebGLFeatureName, !manager->IsWebGLEnabled(), - command_line.HasSwitch(switches::kDisableExperimentalWebGL), + command_line.HasSwitch(switches::kDisableWebGL), "WebGL has been disabled via blacklist or the command line.", false}, {"flash_3d", manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D), command_line.HasSwitch(switches::kDisableFlash3d), @@ -142,7 +142,8 @@ const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { " or command line.", true}, {kWebGL2FeatureName, !manager->IsWebGL2Enabled(), - command_line.HasSwitch(switches::kDisableES3APIs), + command_line.HasSwitch(switches::kDisableWebGL) || + command_line.HasSwitch(switches::kDisableWebGL2), "WebGL2 has been disabled via blacklist or the command line.", false}, {kCheckerImagingFeatureName, false, !IsCheckerImagingEnabled(), "Checker-imaging has been disabled via finch trial or the command line.", diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc index 0a9d48f963ea27..4ef4348c950fb7 100644 --- a/content/browser/gpu/gpu_data_manager_impl_private.cc +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc @@ -126,6 +126,9 @@ int GetGpuBlacklistHistogramValueWin(gpu::GpuFeatureStatus status) { case gpu::kGpuFeatureStatusDisabled: entry_index += 2; break; + case gpu::kGpuFeatureStatusSoftware: + entry_index += 3; + break; case gpu::kGpuFeatureStatusUndefined: case gpu::kGpuFeatureStatusMax: NOTREACHED(); @@ -184,9 +187,9 @@ void UpdateStats(const gpu::GPUInfo& gpu_info, command_line.HasSwitch(switches::kDisableAccelerated2dCanvas), command_line.HasSwitch(switches::kDisableGpu), command_line.HasSwitch(switches::kDisableGpuRasterization), - command_line.HasSwitch(switches::kDisableExperimentalWebGL), - (!command_line.HasSwitch(switches::kEnableES3APIs) || - command_line.HasSwitch(switches::kDisableES3APIs))}; + command_line.HasSwitch(switches::kDisableWebGL), + (command_line.HasSwitch(switches::kDisableWebGL) || + command_line.HasSwitch(switches::kDisableWebGL2))}; #if defined(OS_WIN) const std::string kGpuBlacklistFeatureHistogramNamesWin[] = { "GPU.BlacklistFeatureTestResultsWindows.Accelerated2dCanvas", @@ -813,7 +816,6 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( DCHECK(prefs); if (!IsWebGLEnabled()) { - prefs->experimental_webgl_enabled = false; prefs->pepper_3d_enabled = false; } if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) @@ -855,11 +857,6 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences( if (ShouldDisableAcceleratedVideoDecode(command_line)) gpu_preferences->disable_accelerated_video_decode = true; - gpu_preferences->enable_es3_apis = - (command_line->HasSwitch(switches::kEnableES3APIs) || - IsWebGL2Enabled()) && - !command_line->HasSwitch(switches::kDisableES3APIs); - gpu_preferences->gpu_program_cache_size = gpu::ShaderDiskCache::CacheSizeBytes(); } diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 6a6747fc00e3a9..3939599e1ddf24 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -2487,7 +2487,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kDefaultTileWidth, switches::kDefaultTileHeight, switches::kDisable2dCanvasImageChromium, - switches::kDisable3DAPIs, switches::kDisableAcceleratedJpegDecoding, switches::kDisableAcceleratedVideoDecode, switches::kDisableBackgroundTimerThrottling, diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 54ba52788428c6..ad76671e8dcdfc 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -394,10 +394,11 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { prefs.databases_enabled = !command_line.HasSwitch(switches::kDisableDatabases); - prefs.experimental_webgl_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisable3DAPIs) && - !command_line.HasSwitch(switches::kDisableExperimentalWebGL); + prefs.webgl1_enabled = !command_line.HasSwitch(switches::kDisable3DAPIs) && + !command_line.HasSwitch(switches::kDisableWebGL); + prefs.webgl2_enabled = !command_line.HasSwitch(switches::kDisable3DAPIs) && + !command_line.HasSwitch(switches::kDisableWebGL) && + !command_line.HasSwitch(switches::kDisableWebGL2); prefs.pepper_3d_enabled = !command_line.HasSwitch(switches::kDisablePepper3d); diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index 074c17220e9786..b20f90028f22a9 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -156,7 +156,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(hyperlink_auditing_enabled) IPC_STRUCT_TRAITS_MEMBER(allow_universal_access_from_file_urls) IPC_STRUCT_TRAITS_MEMBER(allow_file_access_from_file_urls) - IPC_STRUCT_TRAITS_MEMBER(experimental_webgl_enabled) + IPC_STRUCT_TRAITS_MEMBER(webgl1_enabled) + IPC_STRUCT_TRAITS_MEMBER(webgl2_enabled) IPC_STRUCT_TRAITS_MEMBER(pepper_3d_enabled) IPC_STRUCT_TRAITS_MEMBER(record_whole_document) IPC_STRUCT_TRAITS_MEMBER(use_solid_color_scrollbars) diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 4090fc9a7c8f27..bec6ae27f560e1 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -125,8 +125,11 @@ const char kDisableDatabases[] = "disable-databases"; const char kDisableDomainBlockingFor3DAPIs[] = "disable-domain-blocking-for-3d-apis"; -// Disable experimental WebGL support. -const char kDisableExperimentalWebGL[] = "disable-webgl"; +// Disable all versions of WebGL. +const char kDisableWebGL[] = "disable-webgl"; + +// Disable WebGL2. +const char kDisableWebGL2[] = "disable-webgl2"; // Comma-separated list of feature names to disable. See also kEnableFeatures. const char kDisableFeatures[] = "disable-features"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 4bbf1c3bd8eeb9..f45e936eb95f2c 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -48,7 +48,8 @@ CONTENT_EXPORT extern const char kDisableDatabases[]; CONTENT_EXPORT extern const char kDisableDistanceFieldText[]; CONTENT_EXPORT extern const char kDisableDisplayList2dCanvas[]; extern const char kDisableDomainBlockingFor3DAPIs[]; -CONTENT_EXPORT extern const char kDisableExperimentalWebGL[]; +CONTENT_EXPORT extern const char kDisableWebGL[]; +CONTENT_EXPORT extern const char kDisableWebGL2[]; CONTENT_EXPORT extern const char kDisableFeatures[]; CONTENT_EXPORT extern const char kDisableFileSystem[]; CONTENT_EXPORT extern const char kDisableFlash3d[]; diff --git a/content/public/common/web_preferences.cc b/content/public/common/web_preferences.cc index 528e7996e03c1e..36929cdd6972e1 100644 --- a/content/public/common/web_preferences.cc +++ b/content/public/common/web_preferences.cc @@ -98,7 +98,8 @@ WebPreferences::WebPreferences() hyperlink_auditing_enabled(true), allow_universal_access_from_file_urls(false), allow_file_access_from_file_urls(false), - experimental_webgl_enabled(false), + webgl1_enabled(true), + webgl2_enabled(true), pepper_3d_enabled(false), flash_3d_enabled(true), flash_stage3d_enabled(false), diff --git a/content/public/common/web_preferences.h b/content/public/common/web_preferences.h index 1d4cf92e3471d1..6f35b2e70b9cab 100644 --- a/content/public/common/web_preferences.h +++ b/content/public/common/web_preferences.h @@ -129,7 +129,8 @@ struct CONTENT_EXPORT WebPreferences { bool hyperlink_auditing_enabled; bool allow_universal_access_from_file_urls; bool allow_file_access_from_file_urls; - bool experimental_webgl_enabled; + bool webgl1_enabled; + bool webgl2_enabled; bool pepper_3d_enabled; bool flash_3d_enabled; bool flash_stage3d_enabled; diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index b9c04dc0900af9..7486abc505a206 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -856,11 +856,6 @@ bool PepperPluginInstanceImpl::Initialize( UpdateTouchEventRequest(); UpdateWheelEventRequest(); - SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( - render_frame_->render_view()->webkit_preferences())), - arg_names, - arg_values); - argn_ = arg_names; argv_ = arg_values; std::unique_ptr argn_array(StringVectorToArgArray(argn_)); diff --git a/content/renderer/pepper/pepper_plugin_instance_metrics.cc b/content/renderer/pepper/pepper_plugin_instance_metrics.cc index 2df79b7c8a8207..15068ee284f1ef 100644 --- a/content/renderer/pepper/pepper_plugin_instance_metrics.cc +++ b/content/renderer/pepper/pepper_plugin_instance_metrics.cc @@ -73,30 +73,4 @@ void RecordFlashClickSizeMetric(int width, int height) { height); } -void SetGPUHistogram(const ppapi::Preferences& prefs, - const std::vector& arg_names, - const std::vector& arg_values) { -// Calculate a histogram to let us determine how likely people are to try to -// run Stage3D content on machines that have it blacklisted. -#if defined(OS_WIN) - bool needs_gpu = false; - - for (size_t i = 0; i < arg_names.size(); i++) { - if (arg_names[i] == "wmode") { - // In theory content other than Flash could have a "wmode" argument, - // but that's pretty unlikely. - if (arg_values[i] == "direct" || arg_values[i] == "gpu") - needs_gpu = true; - break; - } - } - // 0 : No 3D content and GPU is blacklisted - // 1 : No 3D content and GPU is not blacklisted - // 2 : 3D content but GPU is blacklisted - // 3 : 3D content and GPU is not blacklisted - UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", - needs_gpu * 2 + prefs.is_webgl_supported, 8); -#endif -} - } // namespace content diff --git a/content/renderer/pepper/pepper_plugin_instance_metrics.h b/content/renderer/pepper/pepper_plugin_instance_metrics.h index 02d92e06056bb9..33739ea631486c 100644 --- a/content/renderer/pepper/pepper_plugin_instance_metrics.h +++ b/content/renderer/pepper/pepper_plugin_instance_metrics.h @@ -5,13 +5,6 @@ #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_METRICS_H_ #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_METRICS_H_ -#include -#include - -namespace ppapi { -struct Preferences; -} - namespace content { // Record size metrics for all Flash instances. @@ -20,10 +13,6 @@ void RecordFlashSizeMetric(int width, int height); // Records size metrics for Flash instances that are clicked. void RecordFlashClickSizeMetric(int width, int height); -void SetGPUHistogram(const ppapi::Preferences& prefs, - const std::vector& arg_names, - const std::vector& arg_values); - } // namespace content #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_METRICS_H_ diff --git a/content/renderer/pepper/ppapi_preferences_builder.cc b/content/renderer/pepper/ppapi_preferences_builder.cc index 34d3f4355d6d59..a487887ad50438 100644 --- a/content/renderer/pepper/ppapi_preferences_builder.cc +++ b/content/renderer/pepper/ppapi_preferences_builder.cc @@ -23,7 +23,6 @@ ppapi::Preferences PpapiPreferencesBuilder::Build( ppapi_prefs.is_stage3d_supported = prefs.flash_stage3d_enabled; ppapi_prefs.is_stage3d_baseline_supported = prefs.flash_stage3d_baseline_enabled; - ppapi_prefs.is_webgl_supported = prefs.experimental_webgl_enabled; ppapi_prefs.is_accelerated_video_decode_enabled = prefs.pepper_accelerated_video_decode_enabled; return ppapi_prefs; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 085a35c4b8e655..3567bc8c089112 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -4741,15 +4741,12 @@ blink::WebString RenderFrameImpl::DoNotTrackValue() { return WebString(); } -bool RenderFrameImpl::AllowWebGL(bool default_value) { - if (!default_value) - return false; - +bool RenderFrameImpl::ShouldBlockWebGL() { bool blocked = true; Send(new FrameHostMsg_Are3DAPIsBlocked( routing_id_, url::Origin(frame_->Top()->GetSecurityOrigin()).GetURL(), THREE_D_API_TYPE_WEBGL, &blocked)); - return !blocked; + return blocked; } bool RenderFrameImpl::AllowContentInitiatedDataUrlNavigations( diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 449d2f949d701d..4a94f637f6c78b 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -661,7 +661,7 @@ class CONTENT_EXPORT RenderFrameImpl blink::WebEncryptedMediaClient* EncryptedMediaClient() override; blink::WebString UserAgentOverride() override; blink::WebString DoNotTrackValue() override; - bool AllowWebGL(bool default_value) override; + bool ShouldBlockWebGL() override; bool AllowContentInitiatedDataUrlNavigations( const blink::WebURL& url) override; blink::WebScreenOrientationClient* GetWebScreenOrientationClient() override; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 2c088141cc3206..af8a2284355f29 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -802,9 +802,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs, settings->SetAllowFileAccessFromFileURLs( prefs.allow_file_access_from_file_urls); - // Enable experimental WebGL support if requested on command line - // and support is compiled in. - settings->SetExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); + settings->SetWebGL1Enabled(prefs.webgl1_enabled); + settings->SetWebGL2Enabled(prefs.webgl2_enabled); // Enable WebGL errors to the JS console if requested. settings->SetWebGLErrorsToConsoleEnabled( diff --git a/content/shell/renderer/layout_test/blink_test_helpers.cc b/content/shell/renderer/layout_test/blink_test_helpers.cc index 930f8a31ff260d..7dae9095cde803 100644 --- a/content/shell/renderer/layout_test/blink_test_helpers.cc +++ b/content/shell/renderer/layout_test/blink_test_helpers.cc @@ -32,7 +32,6 @@ void ExportLayoutTestSpecificPreferences( to->loads_images_automatically = from.loads_images_automatically; to->plugins_enabled = from.plugins_enabled; to->tabs_to_links = from.tabs_to_links; - to->experimental_webgl_enabled = from.experimental_webgl_enabled; // experimentalCSSRegionsEnabled is deprecated and ignored. to->hyperlink_auditing_enabled = from.hyperlink_auditing_enabled; to->allow_running_insecure_content = from.allow_running_of_insecure_content; diff --git a/content/shell/test_runner/test_preferences.cc b/content/shell/test_runner/test_preferences.cc index 61bef1ebfbbd42..da9ae34eaaed7b 100644 --- a/content/shell/test_runner/test_preferences.cc +++ b/content/shell/test_runner/test_preferences.cc @@ -22,7 +22,6 @@ void TestPreferences::Reset() { allow_file_access_from_file_urls = true; allow_running_of_insecure_content = true; default_text_encoding_name = WebString::FromUTF8("ISO-8859-1"); - experimental_webgl_enabled = false; experimental_css_grid_layout_enabled = true; java_script_can_access_clipboard = true; supports_multiple_windows = true; diff --git a/content/shell/test_runner/test_preferences.h b/content/shell/test_runner/test_preferences.h index 216e15f002ba60..0c089a5ec1a725 100644 --- a/content/shell/test_runner/test_preferences.h +++ b/content/shell/test_runner/test_preferences.h @@ -19,7 +19,6 @@ struct TEST_RUNNER_EXPORT TestPreferences { bool allow_file_access_from_file_urls; bool allow_running_of_insecure_content; blink::WebString default_text_encoding_name; - bool experimental_webgl_enabled; bool experimental_css_grid_layout_enabled; bool java_script_can_access_clipboard; bool supports_multiple_windows; diff --git a/content/shell/test_runner/test_runner.cc b/content/shell/test_runner/test_runner.cc index 3ba6e00076b18e..931a0ae0dce440 100644 --- a/content/shell/test_runner/test_runner.cc +++ b/content/shell/test_runner/test_runner.cc @@ -2416,8 +2416,6 @@ void TestRunner::OverridePreference(const std::string& key, prefs->plugins_enabled = value->BooleanValue(); } else if (key == "WebKitTabToLinksPreferenceKey") { prefs->tabs_to_links = value->BooleanValue(); - } else if (key == "WebKitWebGLEnabled") { - prefs->experimental_webgl_enabled = value->BooleanValue(); } else if (key == "WebKitCSSGridLayoutEnabled") { prefs->experimental_css_grid_layout_enabled = value->BooleanValue(); } else if (key == "WebKitHyperlinkAuditingEnabled") { diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc index 11a8eb90e8df10..cffb56a6450654 100644 --- a/gpu/command_buffer/service/context_group.cc +++ b/gpu/command_buffer/service/context_group.cc @@ -128,12 +128,24 @@ ContextGroup::ContextGroup( bool ContextGroup::Initialize(GLES2Decoder* decoder, ContextType context_type, const DisallowedFeatures& disallowed_features) { - bool enable_es3 = context_type == CONTEXT_TYPE_OPENGLES3 || - context_type == CONTEXT_TYPE_WEBGL2; - if (!gpu_preferences_.enable_es3_apis && enable_es3) { - DLOG(ERROR) << "ContextGroup::Initialize failed because ES3 APIs are " - << "not available."; - return false; + switch (context_type) { + case CONTEXT_TYPE_WEBGL1: + if (kGpuFeatureStatusBlacklisted == + gpu_feature_info_.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL]) { + DLOG(ERROR) << "ContextGroup::Initialize failed: WebGL1 baclklisted"; + return false; + } + break; + case CONTEXT_TYPE_WEBGL2: + if (kGpuFeatureStatusBlacklisted == + gpu_feature_info_ + .status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2]) { + DLOG(ERROR) << "ContextGroup::Initialize failed: WebGL2 blacklisted"; + return false; + } + break; + default: + break; } if (HaveContexts()) { if (context_type != feature_info_->context_type()) { @@ -176,7 +188,9 @@ bool ContextGroup::Initialize(GLES2Decoder* decoder, } } - if (enable_es3 || feature_info_->feature_flags().ext_draw_buffers) { + if (context_type == CONTEXT_TYPE_OPENGLES3 || + context_type == CONTEXT_TYPE_WEBGL2 || + feature_info_->feature_flags().ext_draw_buffers) { GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments_); if (max_color_attachments_ < 1) max_color_attachments_ = 1; diff --git a/gpu/command_buffer/service/gpu_preferences.h b/gpu/command_buffer/service/gpu_preferences.h index 8dd0ff114ea671..b37c2cc70ec29c 100644 --- a/gpu/command_buffer/service/gpu_preferences.h +++ b/gpu/command_buffer/service/gpu_preferences.h @@ -141,9 +141,6 @@ struct GPU_EXPORT GpuPreferences { // Turns on calling TRACE for every GL call. bool enable_gpu_service_tracing = false; - // Enable OpenGL ES 3 APIs. - bool enable_es3_apis = true; - // Use the Pass-through command decoder, skipping all validation and state // tracking. bool use_passthrough_cmd_decoder = false; diff --git a/gpu/config/gpu_feature_info.h b/gpu/config/gpu_feature_info.h index 0074f92e1826f3..35455871eadc7d 100644 --- a/gpu/config/gpu_feature_info.h +++ b/gpu/config/gpu_feature_info.h @@ -22,6 +22,7 @@ enum GpuFeatureStatus { kGpuFeatureStatusEnabled, kGpuFeatureStatusBlacklisted, kGpuFeatureStatusDisabled, + kGpuFeatureStatusSoftware, kGpuFeatureStatusUndefined, kGpuFeatureStatusMax }; diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc index e57c7112e55fa0..cfe65da93bd887 100644 --- a/gpu/config/gpu_util.cc +++ b/gpu/config/gpu_util.cc @@ -42,6 +42,14 @@ void StringToIds(const std::string& str, std::vector* list) { } } +bool UseSwiftShader(const base::CommandLine& command_line) { + if (!command_line.HasSwitch(switches::kUseGL)) + return false; + std::string use_gl = command_line.GetSwitchValueASCII(switches::kUseGL); + return (use_gl == gl::kGLImplementationSwiftShaderForWebGLName || + use_gl == gl::kGLImplementationSwiftShaderName); +} + GpuFeatureStatus GetGpuRasterizationFeatureStatus( const std::set& blacklisted_features, const base::CommandLine& command_line) { @@ -68,6 +76,26 @@ GpuFeatureStatus GetGpuRasterizationFeatureStatus( return kGpuFeatureStatusEnabled; } +GpuFeatureStatus GetWebGLFeatureStatus( + const std::set& blacklisted_features, + const base::CommandLine& command_line) { + if (UseSwiftShader(command_line)) + return kGpuFeatureStatusSoftware; + if (blacklisted_features.count(GPU_FEATURE_TYPE_ACCELERATED_WEBGL)) + return kGpuFeatureStatusBlacklisted; + return kGpuFeatureStatusEnabled; +} + +GpuFeatureStatus GetWebGL2FeatureStatus( + const std::set& blacklisted_features, + const base::CommandLine& command_line) { + if (UseSwiftShader(command_line)) + return kGpuFeatureStatusSoftware; + if (blacklisted_features.count(GPU_FEATURE_TYPE_ACCELERATED_WEBGL2)) + return kGpuFeatureStatusBlacklisted; + return kGpuFeatureStatusEnabled; +} + void AppendWorkaroundsToCommandLine(const GpuFeatureInfo& gpu_feature_info, base::CommandLine* command_line) { if (gpu_feature_info.IsWorkaroundEnabled(DISABLE_D3D11)) { @@ -81,6 +109,15 @@ void AppendWorkaroundsToCommandLine(const GpuFeatureInfo& gpu_feature_info, } } +// Adjust gpu feature status based on enabled gpu driver bug workarounds. +void AdjustGpuFeatureStatusToWorkarounds(GpuFeatureInfo* gpu_feature_info) { + if (gpu_feature_info->IsWorkaroundEnabled(DISABLE_D3D11) || + gpu_feature_info->IsWorkaroundEnabled(DISABLE_ES3_GL_CONTEXT)) { + gpu_feature_info->status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2] = + kGpuFeatureStatusBlacklisted; + } +} + } // namespace anonymous void ParseSecondaryGpuDevicesFromCommandLine( @@ -186,9 +223,13 @@ GpuFeatureInfo ComputeGpuFeatureInfo(const GPUInfo& gpu_info, list->MakeDecision(GpuControlList::kOsAny, std::string(), gpu_info); } - // Currently only used for GPU rasterization. + // Currently only computed and used for a few features. gpu_feature_info.status_values[GPU_FEATURE_TYPE_GPU_RASTERIZATION] = GetGpuRasterizationFeatureStatus(blacklisted_features, *command_line); + gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL] = + GetWebGLFeatureStatus(blacklisted_features, *command_line); + gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2] = + GetWebGL2FeatureStatus(blacklisted_features, *command_line); std::set all_disabled_extensions; std::string disabled_gl_extensions_value = @@ -229,6 +270,8 @@ GpuFeatureInfo ComputeGpuFeatureInfo(const GPUInfo& gpu_info, gpu_feature_info.disabled_extensions = base::JoinString(v, " "); } + AdjustGpuFeatureStatusToWorkarounds(&gpu_feature_info); + // TODO(zmo): Find a better way to communicate these settings to bindings // initialization than commandline switches. AppendWorkaroundsToCommandLine(gpu_feature_info, command_line); diff --git a/gpu/config/software_rendering_list.json b/gpu/config/software_rendering_list.json index 82567cc15ee37d..1289a559eddb17 100644 --- a/gpu/config/software_rendering_list.json +++ b/gpu/config/software_rendering_list.json @@ -129,6 +129,9 @@ { "vendor_id": "0x1414", "device_id": ["0x02c1"] + }, + { + "driver_vendor": "swiftshader" } ], "features": [ @@ -1326,6 +1329,9 @@ }, { "gl_renderer": ".*Gallium.*llvmpipe.*" + }, + { + "gl_renderer": "Mesa OffScreen" } ], "features": [ diff --git a/gpu/ipc/common/gpu_feature_info.mojom b/gpu/ipc/common/gpu_feature_info.mojom index f050dae4bc5eeb..fe3ec5750dfef5 100644 --- a/gpu/ipc/common/gpu_feature_info.mojom +++ b/gpu/ipc/common/gpu_feature_info.mojom @@ -10,6 +10,7 @@ enum GpuFeatureStatus { Enabled, Blacklisted, Disabled, + Software, Undefined, Max }; diff --git a/gpu/ipc/common/gpu_feature_info_struct_traits.h b/gpu/ipc/common/gpu_feature_info_struct_traits.h index bc99f168c0b56b..40fc6013b2bec6 100644 --- a/gpu/ipc/common/gpu_feature_info_struct_traits.h +++ b/gpu/ipc/common/gpu_feature_info_struct_traits.h @@ -19,6 +19,8 @@ struct EnumTraits { return gpu::mojom::GpuFeatureStatus::Blacklisted; case gpu::kGpuFeatureStatusDisabled: return gpu::mojom::GpuFeatureStatus::Disabled; + case gpu::kGpuFeatureStatusSoftware: + return gpu::mojom::GpuFeatureStatus::Software; case gpu::kGpuFeatureStatusUndefined: return gpu::mojom::GpuFeatureStatus::Undefined; case gpu::kGpuFeatureStatusMax: @@ -40,6 +42,9 @@ struct EnumTraits { case gpu::mojom::GpuFeatureStatus::Disabled: *out = gpu::kGpuFeatureStatusDisabled; return true; + case gpu::mojom::GpuFeatureStatus::Software: + *out = gpu::kGpuFeatureStatusSoftware; + return true; case gpu::mojom::GpuFeatureStatus::Undefined: *out = gpu::kGpuFeatureStatusUndefined; return true; diff --git a/gpu/ipc/common/gpu_preferences.mojom b/gpu/ipc/common/gpu_preferences.mojom index ed4e9d9918301c..3fea6aaa3891f5 100644 --- a/gpu/ipc/common/gpu_preferences.mojom +++ b/gpu/ipc/common/gpu_preferences.mojom @@ -49,6 +49,5 @@ struct GpuPreferences { bool emulate_shader_precision; bool enable_gpu_service_logging; bool enable_gpu_service_tracing; - bool enable_es3_apis; bool use_passthrough_cmd_decoder; }; diff --git a/gpu/ipc/common/gpu_preferences_struct_traits.h b/gpu/ipc/common/gpu_preferences_struct_traits.h index 15f5bbd6940a91..e8aed0f3510844 100644 --- a/gpu/ipc/common/gpu_preferences_struct_traits.h +++ b/gpu/ipc/common/gpu_preferences_struct_traits.h @@ -101,7 +101,6 @@ struct StructTraits { out->emulate_shader_precision = prefs.emulate_shader_precision(); out->enable_gpu_service_logging = prefs.enable_gpu_service_logging(); out->enable_gpu_service_tracing = prefs.enable_gpu_service_tracing(); - out->enable_es3_apis = prefs.enable_es3_apis(); out->use_passthrough_cmd_decoder = prefs.use_passthrough_cmd_decoder(); return true; } @@ -229,9 +228,6 @@ struct StructTraits { static bool enable_gpu_service_tracing(const gpu::GpuPreferences& prefs) { return prefs.enable_gpu_service_tracing; } - static bool enable_es3_apis(const gpu::GpuPreferences& prefs) { - return prefs.enable_es3_apis; - } static bool use_passthrough_cmd_decoder(const gpu::GpuPreferences& prefs) { return prefs.use_passthrough_cmd_decoder; } diff --git a/ppapi/shared_impl/ppapi_preferences.h b/ppapi/shared_impl/ppapi_preferences.h index 8858bd9b2ff9c9..261216d0b91b53 100644 --- a/ppapi/shared_impl/ppapi_preferences.h +++ b/ppapi/shared_impl/ppapi_preferences.h @@ -30,7 +30,6 @@ struct PPAPI_SHARED_EXPORT Preferences { bool is_3d_supported; bool is_stage3d_supported; bool is_stage3d_baseline_supported; - bool is_webgl_supported; bool is_accelerated_video_decode_enabled; }; diff --git a/third_party/WebKit/LayoutTests/compositing/backface-visibility/backface-visibility-webgl.html b/third_party/WebKit/LayoutTests/compositing/backface-visibility/backface-visibility-webgl.html index b802b4435a00cd..3a25fe9367d080 100644 --- a/third_party/WebKit/LayoutTests/compositing/backface-visibility/backface-visibility-webgl.html +++ b/third_party/WebKit/LayoutTests/compositing/backface-visibility/backface-visibility-webgl.html @@ -43,15 +43,6 @@ - - - - diff --git a/third_party/WebKit/LayoutTests/compositing/draws-content/webgl-background-layer.html b/third_party/WebKit/LayoutTests/compositing/draws-content/webgl-background-layer.html index dc6d806f012f6e..9fd93e993a31e7 100644 --- a/third_party/WebKit/LayoutTests/compositing/draws-content/webgl-background-layer.html +++ b/third_party/WebKit/LayoutTests/compositing/draws-content/webgl-background-layer.html @@ -18,7 +18,6 @@ - - diff --git a/third_party/WebKit/LayoutTests/fast/canvas/webgl/pixelated.html b/third_party/WebKit/LayoutTests/fast/canvas/webgl/pixelated.html index b05e4d9e88c0cc..bfb195d0dae9d9 100644 --- a/third_party/WebKit/LayoutTests/fast/canvas/webgl/pixelated.html +++ b/third_party/WebKit/LayoutTests/fast/canvas/webgl/pixelated.html @@ -26,7 +26,6 @@ - diff --git a/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/resources/webgl-test.js b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/resources/webgl-test.js index 03f7fcf9421fd4..f8dc96a530293a 100644 --- a/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/resources/webgl-test.js +++ b/third_party/WebKit/LayoutTests/fast/mediacapturefromelement/resources/webgl-test.js @@ -1,8 +1,5 @@ //---------------------------------------------------------------------- // Differences with respect to Khronos version of webgl-test.js -if (window.testRunner) - testRunner.overridePreference("WebKitWebGLEnabled", "1"); - function assertMsg(assertion, msg) { if (assertion) { testPassed(msg); @@ -13,7 +10,6 @@ function assertMsg(assertion, msg) { function initNonKhronosFramework(waitUntilDone) { if (window.testRunner) { - testRunner.overridePreference("WebKitWebGLEnabled", "1"); testRunner.dumpAsText(); if (waitUntilDone) { window.jsTestIsAsync = true; diff --git a/third_party/WebKit/LayoutTests/http/tests/canvas/webgl/origin-clean-conformance.html b/third_party/WebKit/LayoutTests/http/tests/canvas/webgl/origin-clean-conformance.html index 7b1a4719491e55..8088328ae27cf6 100644 --- a/third_party/WebKit/LayoutTests/http/tests/canvas/webgl/origin-clean-conformance.html +++ b/third_party/WebKit/LayoutTests/http/tests/canvas/webgl/origin-clean-conformance.html @@ -103,7 +103,6 @@ if (videoFile) { if (window.testRunner) { - testRunner.overridePreference("WebKitWebGLEnabled", "1"); testRunner.dumpAsText(); testRunner.waitUntilDone(); } diff --git a/third_party/WebKit/LayoutTests/http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html b/third_party/WebKit/LayoutTests/http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html index ba9afe42ca02d1..4ca1d03288dc1e 100644 --- a/third_party/WebKit/LayoutTests/http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html +++ b/third_party/WebKit/LayoutTests/http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html @@ -4,7 +4,6 @@