Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit faf213b

Browse files
[Impeller] disable AHBs on devices that were upgraded to 29. (#56202)
Uses `ro.product.first_api_level` to disable AHBs on devices that began life pre 29. Fixes flutter/flutter#157113
1 parent 725c8e4 commit faf213b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

impeller/toolkit/android/shadow_realm.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ bool ShadowRealm::ShouldDisableAHB() {
1515
__system_property_get("ro.com.google.clientidbase", clientidbase);
1616

1717
auto api_level = android_get_device_api_level();
18+
char first_api_level[PROP_VALUE_MAX];
19+
__system_property_get("ro.product.first_api_level", first_api_level);
1820

19-
return ShouldDisableAHBInternal(clientidbase, api_level);
21+
return ShouldDisableAHBInternal(clientidbase, first_api_level, api_level);
2022
}
2123

2224
// static
2325
bool ShadowRealm::ShouldDisableAHBInternal(std::string_view clientidbase,
26+
std::string_view first_api_level,
2427
uint32_t api_level) {
28+
// Most devices that have updated to API 29 don't seem to correctly
29+
// support AHBs: https://github.com/flutter/flutter/issues/157113
30+
if (first_api_level == "28" || first_api_level == "27" ||
31+
first_api_level == "26" || first_api_level == "25" ||
32+
first_api_level == "24") {
33+
return false;
34+
}
2535
// From local testing, neither the swapchain nor AHB import works, see also:
2636
// https://github.com/flutter/flutter/issues/154068
2737
if (clientidbase == kAndroidHuawei && api_level <= 29) {

impeller/toolkit/android/shadow_realm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ShadowRealm {
1818

1919
// For testing.
2020
static bool ShouldDisableAHBInternal(std::string_view clientidbase,
21+
std::string_view first_api_level,
2122
uint32_t api_level);
2223
};
2324

impeller/toolkit/android/toolkit_android_unittests.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,17 @@ TEST(ToolkitAndroidTest, CanPostAndWaitForFrameCallbacks) {
138138
TEST(ToolkitAndroidTest, ShouldDisableAHB) {
139139
EXPECT_FALSE(ShadowRealm::ShouldDisableAHB());
140140

141-
EXPECT_TRUE(ShadowRealm::ShouldDisableAHBInternal("android-huawei", 29));
142-
EXPECT_FALSE(ShadowRealm::ShouldDisableAHBInternal("android-huawei", 30));
143-
EXPECT_FALSE(ShadowRealm::ShouldDisableAHBInternal("something made up", 29));
141+
EXPECT_FALSE(
142+
ShadowRealm::ShouldDisableAHBInternal("android-huawei", "30", 30));
143+
EXPECT_FALSE(
144+
ShadowRealm::ShouldDisableAHBInternal("something made up", "29", 29));
145+
146+
EXPECT_TRUE(
147+
ShadowRealm::ShouldDisableAHBInternal("android-huawei", "29", 29));
148+
EXPECT_TRUE(
149+
ShadowRealm::ShouldDisableAHBInternal("something made up", "27", 29));
150+
EXPECT_TRUE(
151+
ShadowRealm::ShouldDisableAHBInternal("android-huawei", "garbage", 29));
144152
}
145153

146154
} // namespace impeller::android::testing

0 commit comments

Comments
 (0)