diff --git a/engine/src/flutter/shell/platform/android/flutter_main.cc b/engine/src/flutter/shell/platform/android/flutter_main.cc index 31aa094b07..3458175bfa 100644 --- a/engine/src/flutter/shell/platform/android/flutter_main.cc +++ b/engine/src/flutter/shell/platform/android/flutter_main.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,23 @@ namespace { fml::jni::ScopedJavaGlobalRef* g_flutter_jni_class = nullptr; +/// These are SoCs that crash when using AHB imports. +static constexpr const char* kBLC[] = { + // Most Exynos Series SoC + "exynos7870", // + "exynos7880", // + "exynos7872", // + "exynos7884", // + "exynos7885", // + "exynos8890", // + "exynos8895", // + "exynos7904", // + "exynos9609", // + "exynos9610", // + "exynos9611", // + "exynos9810" // +}; + } // anonymous namespace FlutterMain::FlutterMain(const flutter::Settings& settings) @@ -237,6 +255,18 @@ bool FlutterMain::IsDeviceEmulator(std::string_view product_model) { return std::string(product_model).find("gphone") != std::string::npos; } +// static +bool FlutterMain::IsKnownBadSOC(std::string_view hardware) { + // TODO(jonahwilliams): if the list gets too long (> 16), convert + // to a hash map first. + for (const auto& board : kBLC) { + if (strcmp(board, hardware.data()) == 0) { + return true; + } + } + return false; +} + // static AndroidRenderingAPI FlutterMain::SelectedRenderingAPI( const flutter::Settings& settings) { @@ -280,6 +310,12 @@ AndroidRenderingAPI FlutterMain::SelectedRenderingAPI( return kVulkanUnsupportedFallback; } + __system_property_get("ro.product.board", product_model); + if (IsKnownBadSOC(product_model)) { + // Avoid using Vulkan on known bad SoCs. + return kVulkanUnsupportedFallback; + } + // Determine if Vulkan is supported by creating a Vulkan context and // checking if it is valid. impeller::ScopedValidationDisable disable_validation; diff --git a/engine/src/flutter/shell/platform/android/flutter_main.h b/engine/src/flutter/shell/platform/android/flutter_main.h index 4db1230882..66af0012a0 100644 --- a/engine/src/flutter/shell/platform/android/flutter_main.h +++ b/engine/src/flutter/shell/platform/android/flutter_main.h @@ -28,6 +28,8 @@ class FlutterMain { static bool IsDeviceEmulator(std::string_view product_model); + static bool IsKnownBadSOC(std::string_view hardware); + private: const flutter::Settings settings_; DartServiceIsolate::CallbackHandle vm_service_uri_callback_ = 0; diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_unittests.cc b/engine/src/flutter/shell/platform/android/platform_view_android_unittests.cc index 321e2e26b9..52a25cf3bc 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_unittests.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android_unittests.cc @@ -42,5 +42,13 @@ TEST(AndroidPlatformView, FallsBackToGLESonEmulator) { EXPECT_FALSE(FlutterMain::IsDeviceEmulator(device_product)); } +TEST(AndroidPlatformView, FallsBackToGLESonMostExynos) { + std::string exynos_board = "exynos7870"; + std::string snap_board = "smg1234"; + + EXPECT_TRUE(FlutterMain::IsKnownBadSOC(exynos_board)); + EXPECT_FALSE(FlutterMain::IsKnownBadSOC(snap_board)); +} + } // namespace testing } // namespace flutter