Skip to content

Commit

Permalink
[GL] Add a switch to disable Android native fence sync
Browse files Browse the repository at this point in the history
https://crrev.com/c/5493084 was reverted because it broke some GL tests.
For simplicity and to minimize the impact, a switch is added in this CL
to disable the native fence sync on Android emulators.

Bug: 337886037, 40259037
Change-Id: I63a1a5a4d956c7134b8ba44912e46c0cbc8be1f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5504854
Reviewed-by: Geoff Lang <[email protected]>
Commit-Queue: William Liu <[email protected]>
Reviewed-by: Khushal Sagar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1296572}
  • Loading branch information
William Liu authored and Chromium LUCI CQ committed May 4, 2024
1 parent 7c2cb63 commit 1414d83
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/gl/gl_display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,11 @@ void GLDisplayEGL::InitializeCommon(bool for_testing) {
base::SysInfo::GetAndroidHardwareEGL() != "emulation") {
egl_android_native_fence_sync_supported_ = true;
}

if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAndroidNativeFenceSyncForTesting)) {
egl_android_native_fence_sync_supported_ = false;
}
#endif // BUILDFLAG(IS_ANDROID)

if (!for_testing) {
Expand Down
11 changes: 11 additions & 0 deletions ui/gl/gl_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ const char* const kGLSwitchesCopiedFromGpuProcessHost[] = {
const size_t kGLSwitchesCopiedFromGpuProcessHostNumSwitches =
std::size(kGLSwitchesCopiedFromGpuProcessHost);

#if BUILDFLAG(IS_ANDROID)
// On some Android emulators with software GL, ANGLE
// is exposing the native fence sync extension but it doesn't
// actually work. This switch is used to disable the Android native fence sync
// during test to avoid crashes.
//
// TODO(https://crbug.com/337886037): Remove this flag once the upstream ANGLE
// is fixed.
const char kDisableAndroidNativeFenceSyncForTesting[] =
"disable-android-native-fence-sync-for-testing";
#endif
} // namespace switches

namespace features {
Expand Down
4 changes: 4 additions & 0 deletions ui/gl/gl_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ GL_EXPORT extern const char kOverrideUseSoftwareGLForTests[];
GL_EXPORT extern const char* const kGLSwitchesCopiedFromGpuProcessHost[];
GL_EXPORT extern const size_t kGLSwitchesCopiedFromGpuProcessHostNumSwitches;

#if BUILDFLAG(IS_ANDROID)
GL_EXPORT extern const char kDisableAndroidNativeFenceSyncForTesting[];
#endif

} // namespace switches

namespace features {
Expand Down

0 comments on commit 1414d83

Please sign in to comment.