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

Do not use AChoreographer on 32 bit devices #50586

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fml/platform/android/ndk_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ void InitOnceCallback() {
LOOKUP(android, AChoreographer_getInstance);
if (_AChoreographer_getInstance) {
LOOKUP(android, AChoreographer_postFrameCallback64);
// See discussion at
// https://github.com/flutter/engine/pull/31859#discussion_r822072987
// This method is not suitable for Flutter's use cases on 32 bit architectures,
// and we should fall back to the Java based Choreographer.
#if FML_ARCH_CPU_64_BITS
if (!_AChoreographer_postFrameCallback64) {
LOOKUP(android, AChoreographer_postFrameCallback);
}
#endif
}

LOOKUP(android, ASurfaceControl_createFromWindow);
Expand Down
14 changes: 14 additions & 0 deletions fml/platform/android/ndk_helpers_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TEST_F(NdkHelpersTest, ATrace) {
EXPECT_FALSE(NDKHelpers::ATrace_isEnabled());
}

#if FML_ARCH_CPU_64_BITS
TEST_F(NdkHelpersTest, AChoreographer32) {
if (android_get_device_api_level() >= 29) {
GTEST_SKIP() << "This test is for less than API 29.";
Expand All @@ -43,6 +44,19 @@ TEST_F(NdkHelpersTest, AChoreographer32) {
NDKHelpers::AChoreographer_postFrameCallback(
NDKHelpers::AChoreographer_getInstance(), &OnVsync32, nullptr);
}
#else
TEST_F(NdkHelpersTest, AChoreographer32NotSupported) {
if (android_get_device_api_level() >= 29) {
GTEST_SKIP() << "This test is for less than API 29.";
}

// The 32 bit framecallback on 32 bit architectures does not deliver
// sufficient resolution. See
// https://github.com/flutter/engine/pull/31859#discussion_r822072987
EXPECT_EQ(NDKHelpers::ChoreographerSupported(),
ChoreographerSupportStatus::kUnsupported);
}
#endif // FML_ARCH_CPU_64_BITS

TEST_F(NdkHelpersTest, AChoreographer64) {
if (android_get_device_api_level() < 29) {
Expand Down