12 changed files with 283 additions and 14 deletions
@ -0,0 +1,251 @@ |
|||
From: csagan5 <[email protected]> |
|||
Date: Tue, 5 May 2020 07:22:20 +0200 |
|||
Subject: AImageReader CFI crash mitigations |
|||
|
|||
Revert "gpu/android: Remove setup for disabling AImageReader." |
|||
This reverts commit dcd5a39518246eb999f1cc63bf1ec95d93fd5b2f. |
|||
|
|||
Revert "Remove flags to enable/disable AImageReader." |
|||
This reverts commit 463fa0f2e3b9e418bc26e2c8954463f0b0f76634. |
|||
|
|||
Disable AImageReader for ARM64/P and ARM64/Q |
|||
|
|||
Restore GPU bug blacklist for AImageReader on ARM and Qualcomm CPUs |
|||
|
|||
Restore the AImageReader blacklist for ARM/ARM64/Qualcomm chipsets which causes |
|||
crashes on Android 9 and 10 (at different code locations). |
|||
|
|||
See discussions at: |
|||
* https://github.com/bromite/bromite/issues/445 |
|||
* https://github.com/bromite/bromite/issues/814 |
|||
---
|
|||
base/android/android_image_reader_compat.cc | 8 +++++++- |
|||
base/android/android_image_reader_compat.h | 4 ++++ |
|||
chrome/browser/flag-metadata.json | 2 +- |
|||
gpu/config/gpu_driver_bug_list.json | 16 ++++++++++++++++ |
|||
gpu/config/gpu_finch_features.cc | 11 ++++++++++- |
|||
gpu/config/gpu_finch_features.h | 1 + |
|||
gpu/config/gpu_util.cc | 8 ++++++++ |
|||
gpu/config/gpu_workaround_list.txt | 1 + |
|||
gpu/ipc/service/gpu_init.cc | 5 +++++ |
|||
gpu/ipc/service/stream_texture_android.cc | 11 ++++++++++- |
|||
media/base/media_switches.cc | 4 ++++ |
|||
media/base/media_switches.h | 1 + |
|||
12 files changed, 68 insertions(+), 4 deletions(-) |
|||
|
|||
--- a/base/android/android_image_reader_compat.cc
|
|||
+++ b/base/android/android_image_reader_compat.cc
|
|||
@@ -23,6 +23,8 @@
|
|||
namespace base { |
|||
namespace android { |
|||
|
|||
+bool AndroidImageReader::disable_support_ = false;
|
|||
+
|
|||
AndroidImageReader& AndroidImageReader::GetInstance() { |
|||
// C++11 static local variable initialization is |
|||
// thread-safe. |
|||
@@ -30,8 +32,12 @@ AndroidImageReader& AndroidImageReader::
|
|||
return *instance; |
|||
} |
|||
|
|||
+void AndroidImageReader::DisableSupport() {
|
|||
+ disable_support_ = true;
|
|||
+}
|
|||
+
|
|||
bool AndroidImageReader::IsSupported() { |
|||
- return is_supported_;
|
|||
+ return !disable_support_ && is_supported_;
|
|||
} |
|||
|
|||
AndroidImageReader::AndroidImageReader() : is_supported_(LoadFunctions()) {} |
|||
--- a/base/android/android_image_reader_compat.h
|
|||
+++ b/base/android/android_image_reader_compat.h
|
|||
@@ -22,6 +22,9 @@ class BASE_EXPORT AndroidImageReader {
|
|||
// Thread safe GetInstance. |
|||
static AndroidImageReader& GetInstance(); |
|||
|
|||
+ // Disable image reader support.
|
|||
+ static void DisableSupport();
|
|||
+
|
|||
// Check if the image reader usage is supported. This function returns TRUE |
|||
// if android version is >=OREO, image reader support is not disabled and all |
|||
// the required functions are loaded. |
|||
@@ -59,6 +62,7 @@ class BASE_EXPORT AndroidImageReader {
|
|||
jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window); |
|||
|
|||
private: |
|||
+ static bool disable_support_;
|
|||
friend class base::NoDestructor<AndroidImageReader>; |
|||
|
|||
AndroidImageReader(); |
|||
--- a/chrome/browser/flag-metadata.json
|
|||
+++ b/chrome/browser/flag-metadata.json
|
|||
@@ -1712,7 +1712,7 @@
|
|||
{ |
|||
"name": "enable-image-reader", |
|||
"owners": [ "vikassoni", "khushalsagar" ], |
|||
- "expiry_milestone": 90
|
|||
+ "expiry_milestone": -1
|
|||
}, |
|||
{ |
|||
"name": "enable-immersive-fullscreen-toolbar", |
|||
--- a/gpu/config/gpu_driver_bug_list.json
|
|||
+++ b/gpu/config/gpu_driver_bug_list.json
|
|||
@@ -3255,6 +3255,22 @@
|
|||
] |
|||
}, |
|||
{ |
|||
+ "id":335,
|
|||
+ "cr_bugs": [1051705],
|
|||
+ "description": "Disable AImageReader on ARM GPUs",
|
|||
+ "os": {
|
|||
+ "type": "android",
|
|||
+ "version": {
|
|||
+ "op": "<",
|
|||
+ "value": "10"
|
|||
+ }
|
|||
+ },
|
|||
+ "gl_vendor": "ARM.*",
|
|||
+ "features": [
|
|||
+ "disable_aimagereader"
|
|||
+ ]
|
|||
+ },
|
|||
+ {
|
|||
"id": 336, |
|||
"cr_bugs": [625785], |
|||
"description": "DXVA video decoder crashes on some AMD GPUs.", |
|||
--- a/gpu/config/gpu_finch_features.cc
|
|||
+++ b/gpu/config/gpu_finch_features.cc
|
|||
@@ -38,6 +38,11 @@ bool FieldIsInBlocklist(const char* curr
|
|||
} // namespace |
|||
|
|||
#if defined(OS_ANDROID) |
|||
+
|
|||
+// Use android AImageReader when playing videos with MediaPlayer.
|
|||
+const base::Feature kAImageReaderMediaPlayer{"AImageReaderMediaPlayer",
|
|||
+ base::FEATURE_ENABLED_BY_DEFAULT};
|
|||
+
|
|||
// Used to limit GL version to 2.0 for skia raster on Android. |
|||
const base::Feature kUseGles2ForOopR{"UseGles2ForOopR", |
|||
base::FEATURE_ENABLED_BY_DEFAULT}; |
|||
@@ -55,7 +60,11 @@ const base::FeatureParam<std::string> kA
|
|||
|
|||
// Use AImageReader for MediaCodec and MediaPlyer on android. |
|||
const base::Feature kAImageReader{"AImageReader", |
|||
- base::FEATURE_ENABLED_BY_DEFAULT};
|
|||
+#ifdef ARCH_CPU_ARM64
|
|||
+ base::FEATURE_DISABLED_BY_DEFAULT};
|
|||
+#else
|
|||
+ base::FEATURE_ENABLED_BY_DEFAULT};
|
|||
+#endif
|
|||
|
|||
// If webview-draw-functor-uses-vulkan is set, use vulkan for composite and |
|||
// raster. |
|||
--- a/gpu/config/gpu_finch_features.h
|
|||
+++ b/gpu/config/gpu_finch_features.h
|
|||
@@ -17,6 +17,7 @@ namespace features {
|
|||
// All features in alphabetical order. The features should be documented |
|||
// alongside the definition of their values in the .cc file. |
|||
#if defined(OS_ANDROID) |
|||
+GPU_EXPORT extern const base::Feature kAImageReaderMediaPlayer;
|
|||
GPU_EXPORT extern const base::Feature kUseGles2ForOopR; |
|||
GPU_EXPORT extern const base::Feature kAndroidSurfaceControl; |
|||
GPU_EXPORT extern const base::Feature kAImageReader; |
|||
--- a/gpu/config/gpu_util.cc
|
|||
+++ b/gpu/config/gpu_util.cc
|
|||
@@ -111,6 +111,9 @@ GpuFeatureStatus GetAndroidSurfaceContro
|
|||
#if !defined(OS_ANDROID) |
|||
return kGpuFeatureStatusDisabled; |
|||
#else |
|||
+ if (blocklisted_features.count(GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL))
|
|||
+ return kGpuFeatureStatusBlocklisted;
|
|||
+
|
|||
if (!gpu_preferences.enable_android_surface_control) |
|||
return kGpuFeatureStatusDisabled; |
|||
|
|||
@@ -327,6 +330,11 @@ void AdjustGpuFeatureStatusToWorkarounds
|
|||
gpu_feature_info->status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2] = |
|||
kGpuFeatureStatusBlocklisted; |
|||
} |
|||
+
|
|||
+ if (gpu_feature_info->IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
|
|||
+ gpu_feature_info->status_values[GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL] =
|
|||
+ kGpuFeatureStatusBlocklisted;
|
|||
+ }
|
|||
} |
|||
|
|||
// Estimates roughly user total disk space by counting in the drives where |
|||
--- a/gpu/config/gpu_workaround_list.txt
|
|||
+++ b/gpu/config/gpu_workaround_list.txt
|
|||
@@ -13,6 +13,7 @@ decode_encode_srgb_for_generatemipmap
|
|||
depth_stencil_renderbuffer_resize_emulation |
|||
disable_2d_canvas_auto_flush |
|||
disable_accelerated_av1_decode |
|||
+disable_aimagereader
|
|||
disable_accelerated_vp8_decode |
|||
disable_accelerated_vp8_encode |
|||
disable_accelerated_vp9_decode |
|||
--- a/gpu/ipc/service/gpu_init.cc
|
|||
+++ b/gpu/ipc/service/gpu_init.cc
|
|||
@@ -464,6 +464,11 @@ bool GpuInit::InitializeAndStartSandbox(
|
|||
} |
|||
} |
|||
|
|||
+ // Disable AImageReader if the workaround is enabled.
|
|||
+ if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
|
|||
+ base::android::AndroidImageReader::DisableSupport();
|
|||
+ }
|
|||
+
|
|||
if (gpu_feature_info_.status_values[GPU_FEATURE_TYPE_VULKAN] != |
|||
kGpuFeatureStatusEnabled || |
|||
!InitializeVulkan()) { |
|||
--- a/gpu/ipc/service/stream_texture_android.cc
|
|||
+++ b/gpu/ipc/service/stream_texture_android.cc
|
|||
@@ -6,6 +6,7 @@
|
|||
|
|||
#include <string.h> |
|||
|
|||
+#include "base/android/android_image_reader_compat.h"
|
|||
#include "base/android/scoped_hardware_buffer_fence_sync.h" |
|||
#include "base/bind.h" |
|||
#include "base/feature_list.h" |
|||
@@ -47,7 +48,15 @@ std::unique_ptr<ui::ScopedMakeCurrent> M
|
|||
} |
|||
|
|||
TextureOwner::Mode GetTextureOwnerMode() { |
|||
- return features::IsAImageReaderEnabled()
|
|||
+ const bool a_image_reader_supported =
|
|||
+ base::android::AndroidImageReader::GetInstance().IsSupported();
|
|||
+
|
|||
+ // TODO(vikassoni) : Currently we have 2 different flags to enable/disable
|
|||
+ // AImageReader - one for MCVD and other for MediaPlayer here. Merge those 2
|
|||
+ // flags into a single flag. Keeping the 2 flags separate for now since finch
|
|||
+ // experiment using this flag is in progress.
|
|||
+ return a_image_reader_supported && features::IsAImageReaderEnabled() &&
|
|||
+ base::FeatureList::IsEnabled(features::kAImageReaderMediaPlayer)
|
|||
? TextureOwner::Mode::kAImageReaderInsecure |
|||
: TextureOwner::Mode::kSurfaceTextureInsecure; |
|||
} |
|||
--- a/media/base/media_switches.cc
|
|||
+++ b/media/base/media_switches.cc
|
|||
@@ -575,6 +575,10 @@ const base::Feature kMediaDrmPreprovisio
|
|||
const base::Feature kMediaDrmPreprovisioningAtStartup{ |
|||
"MediaDrmPreprovisioningAtStartup", base::FEATURE_ENABLED_BY_DEFAULT}; |
|||
|
|||
+// Enables the Android Image Reader path for Video decoding(for AVDA and MCVD)
|
|||
+const base::Feature kAImageReaderVideoOutput{"AImageReaderVideoOutput",
|
|||
+ base::FEATURE_ENABLED_BY_DEFAULT};
|
|||
+
|
|||
// Prevents using SurfaceLayer for videos. This is meant to be used by embedders |
|||
// that cannot support SurfaceLayer at the moment. |
|||
const base::Feature kDisableSurfaceLayerForVideo{ |
|||
--- a/media/base/media_switches.h
|
|||
+++ b/media/base/media_switches.h
|
|||
@@ -194,6 +194,7 @@ MEDIA_EXPORT extern const base::Feature
|
|||
MEDIA_EXPORT extern const base::Feature kMediaDrmPersistentLicense; |
|||
MEDIA_EXPORT extern const base::Feature kMediaDrmPreprovisioning; |
|||
MEDIA_EXPORT extern const base::Feature kMediaDrmPreprovisioningAtStartup; |
|||
+MEDIA_EXPORT extern const base::Feature kAImageReaderVideoOutput;
|
|||
MEDIA_EXPORT extern const base::Feature kDisableSurfaceLayerForVideo; |
|||
MEDIA_EXPORT extern const base::Feature kCanPlayHls; |
|||
MEDIA_EXPORT extern const base::Feature kPictureInPictureAPI; |
Loading…
Reference in new issue