Skip to content

Commit

Permalink
gpu: Disable AImageReader for ARM GPUs on Android P and below.
Browse files Browse the repository at this point in the history
This change adds a temporary workaround to effectively revert the
following changes. While the long term fix for this bug has landed, it
might be too risky to merge to M81. So this change reverts enabling of
AImageReader on these GPUs, to restore the behaviour prior to M80.

Reverted changes:
https://chromium-review.googlesource.com/c/chromium/src/+/2015553
https://chromium-review.googlesource.com/c/chromium/src/+/1873393

TBR=nyquist@chromium.org
R=​dalecurtis@chromium.org

(cherry picked from commit 56d27fb)

Bug: 1051705
Change-Id: I2f7f0828c8ba4a7279c2f6bb95de449402d88f92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087987
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#747355}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2096933
Reviewed-by: Ben Mason <benmason@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Commit-Queue: Ben Mason <benmason@chromium.org>
Cr-Commit-Position: refs/branch-heads/4044@{#742}
Cr-Branched-From: a6d9daf-refs/heads/master@{#737173}
  • Loading branch information
khushalsagar authored and Ben Mason committed Mar 10, 2020
1 parent 5a69b43 commit 2895570
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/android/android_image_reader_compat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@
namespace base {
namespace android {

bool AndroidImageReader::disable_support_ = false;

AndroidImageReader& AndroidImageReader::GetInstance() {
// C++11 static local variable initialization is
// thread-safe.
static base::NoDestructor<AndroidImageReader> instance;
return *instance;
}

void AndroidImageReader::DisableSupport() {
disable_support_ = true;
}

bool AndroidImageReader::IsSupported() {
return is_supported_;
return !disable_support_ && is_supported_;
}

AndroidImageReader::AndroidImageReader() {
Expand Down
4 changes: 4 additions & 0 deletions base/android/android_image_reader_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -64,6 +67,7 @@ class BASE_EXPORT AndroidImageReader {
AndroidImageReader();
bool LoadFunctions();

static bool disable_support_;
bool is_supported_;
pAImage_delete AImage_delete_;
pAImage_deleteAsync AImage_deleteAsync_;
Expand Down
16 changes: 16 additions & 0 deletions gpu/config/gpu_driver_bug_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,22 @@
"features": [
"dont_delete_source_texture_for_egl_image"
]
},
{
"id":335,
"cr_bugs": [1051705],
"description": "Disable AImageReader on ARM GPUs",
"os": {
"type": "android",
"version": {
"op": "<",
"value": "10"
}
},
"gl_vendor": "ARM.*",
"features": [
"disable_aimagereader"
]
}
]
}
1 change: 1 addition & 0 deletions gpu/config/gpu_workaround_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ decode_encode_srgb_for_generatemipmap
depth_stencil_renderbuffer_resize_emulation
disable_2d_canvas_auto_flush
disable_accelerated_vpx_decode
disable_aimagereader
disable_async_readpixels
disable_av_sample_buffer_display_layer
disable_blend_equation_advanced
Expand Down
11 changes: 11 additions & 0 deletions gpu/ipc/service/gpu_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
#endif

#if defined(OS_ANDROID)
// Disable AImageReader if the workaround is enabled.
if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
base::android::AndroidImageReader::DisableSupport();
}
#endif
#if defined(USE_OZONE)
gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
std::move(supported_buffer_formats_for_texturing);
Expand All @@ -545,6 +551,11 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,

default_offscreen_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());

// Disable AImageReader if the workaround is enabled.
if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
base::android::AndroidImageReader::DisableSupport();
}

UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation());
}
#else
Expand Down

0 comments on commit 2895570

Please sign in to comment.