From a4712d2673c5f16c42faba96fec239208d368110 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 14:34:42 -0800 Subject: [PATCH 1/6] Clean up additional NDK helper related code --- ci/licenses_golden/licenses_flutter | 4 -- shell/platform/android/BUILD.gn | 2 - shell/platform/android/flutter_main.cc | 18 +---- shell/platform/android/library_loader.cc | 3 + shell/platform/android/ndk_helpers.cc | 69 +++++++++++++++++-- shell/platform/android/ndk_helpers.h | 37 +++++++++- .../platform/android/vsync_waiter_android.cc | 54 +++++++++------ shell/platform/android/vsync_waiter_android.h | 1 - 8 files changed, 134 insertions(+), 54 deletions(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index e87ee01ef7089..d7f0d1c76d2d6 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -6290,8 +6290,6 @@ ORIGIN: ../../../flutter/shell/gpu/gpu_surface_vulkan_delegate.h + ../../../flut ORIGIN: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/AndroidManifest.xml + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/android/android_choreographer.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/android/android_choreographer.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_impeller.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_impeller.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_skia.cc + ../../../flutter/LICENSE @@ -9130,8 +9128,6 @@ FILE: ../../../flutter/shell/gpu/gpu_surface_vulkan_delegate.h FILE: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.cc FILE: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.h FILE: ../../../flutter/shell/platform/android/AndroidManifest.xml -FILE: ../../../flutter/shell/platform/android/android_choreographer.cc -FILE: ../../../flutter/shell/platform/android/android_choreographer.h FILE: ../../../flutter/shell/platform/android/android_context_gl_impeller.cc FILE: ../../../flutter/shell/platform/android/android_context_gl_impeller.h FILE: ../../../flutter/shell/platform/android/android_context_gl_skia.cc diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index f850d83ab8f0b..21429607f2435 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -78,8 +78,6 @@ source_set("flutter_shell_native_src") { visibility = [ ":*" ] sources = [ - "android_choreographer.cc", - "android_choreographer.h", "android_context_gl_impeller.cc", "android_context_gl_impeller.h", "android_context_gl_skia.cc", diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index 042e5fd769bae..8a2e9eaca5e66 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -24,6 +24,7 @@ #include "flutter/runtime/dart_vm.h" #include "flutter/shell/common/shell.h" #include "flutter/shell/common/switches.h" +#include "flutter/shell/platform/android/ndk_helpers.h" #include "third_party/dart/runtime/include/dart_tools_api.h" #include "txt/platform.h" @@ -39,21 +40,6 @@ extern const intptr_t kPlatformStrongDillSize; namespace { -// This is only available on API 23+, so dynamically look it up. -// This method is only called once at shell creation. -// Do this in C++ because the API is available at level 23 here, but only 29+ in -// Java. -bool IsATraceEnabled() { - auto libandroid = fml::NativeLibrary::Create("libandroid.so"); - FML_CHECK(libandroid); - auto atrace_fn = - libandroid->ResolveFunction("ATrace_isEnabled"); - if (atrace_fn) { - return atrace_fn.value()(); - } - return false; -} - fml::jni::ScopedJavaGlobalRef* g_flutter_jni_class = nullptr; } // anonymous namespace @@ -95,7 +81,7 @@ void FlutterMain::Init(JNIEnv* env, // Turn systracing on if ATrace_isEnabled is true and the user did not already // request systracing if (!settings.trace_systrace) { - settings.trace_systrace = IsATraceEnabled(); + settings.trace_systrace = NDKHelpers::ATrace_isEnabled(); if (settings.trace_systrace) { __android_log_print( ANDROID_LOG_INFO, "Flutter", diff --git a/shell/platform/android/library_loader.cc b/shell/platform/android/library_loader.cc index 646f232e8bc4b..103a3aeb2a111 100644 --- a/shell/platform/android/library_loader.cc +++ b/shell/platform/android/library_loader.cc @@ -14,6 +14,9 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { // Initialize the Java VM. fml::jni::InitJavaVM(vm); + // Registery dlsym lookups for NDK functions + flutter::NDKHelpers::Init(); + JNIEnv* env = fml::jni::AttachCurrentThread(); bool result = false; diff --git a/shell/platform/android/ndk_helpers.cc b/shell/platform/android/ndk_helpers.cc index 8a11cc50fea0f..6543133c5f231 100644 --- a/shell/platform/android/ndk_helpers.cc +++ b/shell/platform/android/ndk_helpers.cc @@ -25,6 +25,18 @@ typedef void (*fp_AHardwareBuffer_describe)(AHardwareBuffer* buffer, typedef void (*fp_AHardwareBuffer_getId)(AHardwareBuffer* buffer, uint64_t* outId); +typedef bool (*fp_ATrace_isEnabled)(void); + +typedef AChoreographer* (*fp_AChoreographer_getInstance)(void); +typedef void (*fp_AChoreographer_postFrameCallback)( + AChoreographer* choreographer, + AChoreographer_frameCallback callbackk, + void* data); +typedef void (*fp_AChoreographer_postFrameCallback64)( + AChoreographer* choreographer, + AChoreographer_frameCallback64 callbackk, + void* data); + typedef EGLClientBuffer (*fp_eglGetNativeClientBufferANDROID)( AHardwareBuffer* buffer); @@ -37,6 +49,17 @@ void (*_AHardwareBuffer_describe)(AHardwareBuffer* buffer, AHardwareBuffer_Desc* desc) = nullptr; void (*_AHardwareBuffer_getId)(AHardwareBuffer* buffer, uint64_t* outId) = nullptr; +bool (*_ATrace_isEnabled)() = nullptr; +AChoreographer* (*_AChoreographer_getInstance)() = nullptr; +void (*_AChoreographer_postFrameCallback)( + AChoreographer* choreographer, + AChoreographer_frameCallback callbackk, + void* data) = nullptr; +void (*_AChoreographer_postFrameCallback64)( + AChoreographer* choreographer, + AChoreographer_frameCallback64 callbackk, + void* data) = nullptr; + EGLClientBuffer (*_eglGetNativeClientBufferANDROID)(AHardwareBuffer* buffer) = nullptr; @@ -75,6 +98,28 @@ void InitOnceCallback() { ->ResolveFunction( "AHardwareBuffer_describe") .value_or(nullptr); + + _ATrace_isEnabled = + android->ResolveFunction("ATrace_isEnabled") + .value_or(nullptr); + + _AChoreographer_getInstance = + android + ->ResolveFunction( + "AChoreographer_getInstance") + .value_or(nullptr); + if (_AChoreographer_getInstance) { + _AChoreographer_postFrameCallback = + android->ResolveFunction( + "AChoreographer_postFrameCallback64"); +#if FML_ARCH_CPU_64_BITS + if (!_AChoreographer_postFrameCallback64) { + _AChoreographer_postFrameCallback = + android->ResolveFunction( + "AChoreographer_postFrameCallback"); + } +#endif + } } } // namespace @@ -83,8 +128,24 @@ void NDKHelpers::Init() { std::call_once(init_once, InitOnceCallback); } +bool NDKHelpers::ATrace_isEnabled() { + if (_ATrace_isEnabled) { + return _ATrace_isEnabled(); + } + return false; +} + +ChoreographerSupportStatus NDKHelpers::ChoreographerSupported() { + if (_AChoreographer_postFrameCallback64) { + return ChoreographerSupportStatus::kSupported64; + } + if (_AChoreographer_postFrameCallback) { + return ChoreographerSupportStatus::kSupported32; + } + return ChoreographerSupportStatus::kUnsupported; +} + bool NDKHelpers::HardwareBufferSupported() { - NDKHelpers::Init(); const bool r = _AHardwareBuffer_fromHardwareBuffer != nullptr; return r; } @@ -92,33 +153,28 @@ bool NDKHelpers::HardwareBufferSupported() { AHardwareBuffer* NDKHelpers::AHardwareBuffer_fromHardwareBuffer( JNIEnv* env, jobject hardwareBufferObj) { - NDKHelpers::Init(); FML_CHECK(_AHardwareBuffer_fromHardwareBuffer != nullptr); return _AHardwareBuffer_fromHardwareBuffer(env, hardwareBufferObj); } void NDKHelpers::AHardwareBuffer_acquire(AHardwareBuffer* buffer) { - NDKHelpers::Init(); FML_CHECK(_AHardwareBuffer_acquire != nullptr); _AHardwareBuffer_acquire(buffer); } void NDKHelpers::AHardwareBuffer_release(AHardwareBuffer* buffer) { - NDKHelpers::Init(); FML_CHECK(_AHardwareBuffer_release != nullptr); _AHardwareBuffer_release(buffer); } void NDKHelpers::AHardwareBuffer_describe(AHardwareBuffer* buffer, AHardwareBuffer_Desc* desc) { - NDKHelpers::Init(); FML_CHECK(_AHardwareBuffer_describe != nullptr); _AHardwareBuffer_describe(buffer, desc); } std::optional NDKHelpers::AHardwareBuffer_getId( AHardwareBuffer* buffer) { - NDKHelpers::Init(); if (_AHardwareBuffer_getId == nullptr) { return std::nullopt; } @@ -129,7 +185,6 @@ std::optional NDKHelpers::AHardwareBuffer_getId( EGLClientBuffer NDKHelpers::eglGetNativeClientBufferANDROID( AHardwareBuffer* buffer) { - NDKHelpers::Init(); FML_CHECK(_eglGetNativeClientBufferANDROID != nullptr); return _eglGetNativeClientBufferANDROID(buffer); } diff --git a/shell/platform/android/ndk_helpers.h b/shell/platform/android/ndk_helpers.h index 0c7885758d6a5..8fe5f3e665bee 100644 --- a/shell/platform/android/ndk_helpers.h +++ b/shell/platform/android/ndk_helpers.h @@ -10,16 +10,44 @@ #include "flutter/impeller/toolkit/egl/egl.h" +#include #include +#include +#include namespace flutter { using HardwareBufferKey = uint64_t; +enum class ChoreographerSupportStatus { + // Unavailable, API level < 24. + kUnsupported, + // Available, but only with postFrameCallback. + kSupported32, + // Available, but only with postFrameCallback64. + kSupported64, +}; + // A collection of NDK functions that are available depending on the version of // the Android SDK we are linked with at runtime. class NDKHelpers { public: + // Safe to call multiple times. + // Normally called from JNI_OnLoad. + static void Init(); + + // API Version 23 + static bool ATrace_isEnabled(); + + // API Version 24 + static ChoreographerStatus ChoreographerSupported(); + static AChoreographer* AChoreographer_getInstance(); + // Deprecated in 29, available since 24. + static void AChoreographer_postFrameCallback( + AChoreographer* choreographer, + AChoreographer_frameCallback callback, + void* data); + // API Version 26 static bool HardwareBufferSupported(); static AHardwareBuffer* AHardwareBuffer_fromHardwareBuffer( @@ -32,14 +60,17 @@ class NDKHelpers { static EGLClientBuffer eglGetNativeClientBufferANDROID( AHardwareBuffer* buffer); + // API Version 29 + static void AChoreographer_postFrameCallback64( + AChoreographer* choreographer, + AChoreographer_frameCallback64 callback, + void* data); + // API Version 31 // Returns std::nullopt on API version 26 - 30. static std::optional AHardwareBuffer_getId( AHardwareBuffer* buffer); - - private: - static void Init(); }; } // namespace flutter diff --git a/shell/platform/android/vsync_waiter_android.cc b/shell/platform/android/vsync_waiter_android.cc index defde4340e443..ccddfb69173ea 100644 --- a/shell/platform/android/vsync_waiter_android.cc +++ b/shell/platform/android/vsync_waiter_android.cc @@ -13,7 +13,7 @@ #include "flutter/fml/platform/android/scoped_java_ref.h" #include "flutter/fml/size.h" #include "flutter/fml/trace_event.h" -#include "flutter/shell/platform/android/android_choreographer.h" +#include "flutter/shell/platform/android/ndk_helpers.h" namespace flutter { @@ -22,31 +22,43 @@ static jmethodID g_async_wait_for_vsync_method_ = nullptr; static std::atomic_uint g_refresh_rate_ = 60; VsyncWaiterAndroid::VsyncWaiterAndroid(const flutter::TaskRunners& task_runners) - : VsyncWaiter(task_runners), - use_ndk_choreographer_( - AndroidChoreographer::ShouldUseNDKChoreographer()) {} + : VsyncWaiter(task_runners) {} VsyncWaiterAndroid::~VsyncWaiterAndroid() = default; // |VsyncWaiter| void VsyncWaiterAndroid::AwaitVSync() { - if (use_ndk_choreographer_) { - auto* weak_this = new std::weak_ptr(shared_from_this()); - fml::TaskRunner::RunNowOrPostTask( - task_runners_.GetUITaskRunner(), [weak_this]() { - AndroidChoreographer::PostFrameCallback(&OnVsyncFromNDK, weak_this); - }); - } else { - // TODO(99798): Remove it when we drop support for API level < 29. - auto* weak_this = new std::weak_ptr(shared_from_this()); - jlong java_baton = reinterpret_cast(weak_this); - task_runners_.GetPlatformTaskRunner()->PostTask([java_baton]() { - JNIEnv* env = fml::jni::AttachCurrentThread(); - env->CallStaticVoidMethod(g_vsync_waiter_class->obj(), // - g_async_wait_for_vsync_method_, // - java_baton // - ); - }); + switch (NDKHelpers::ChoreographerSupported()) { + case ChoreographerSupportStatus::kSupported32: { + auto* weak_this = new std::weak_ptr(shared_from_this()); + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetUITaskRunner(), [weak_this]() { + NDKHelpers::AChoreographer_postFrameCallback( + NDKHelpers::AChoreographer_getInstance(), &OnVsyncFromNDK, + weak_this); + }); + } break; + case ChoreographerSupportStatus::kSupported64: { + auto* weak_this = new std::weak_ptr(shared_from_this()); + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetUITaskRunner(), [weak_this]() { + NDKHelpers::AChoreographer_postFrameCallback64( + NDKHelpers::AChoreographer_getInstance(), &OnVsyncFromNDK, + weak_this); + }); + } break; + case ChoreographerSupportStatus::kUnsupported: { + // TODO(99798): Remove it when we drop support for API level < 29. + auto* weak_this = new std::weak_ptr(shared_from_this()); + jlong java_baton = reinterpret_cast(weak_this); + task_runners_.GetPlatformTaskRunner()->PostTask([java_baton]() { + JNIEnv* env = fml::jni::AttachCurrentThread(); + env->CallStaticVoidMethod(g_vsync_waiter_class->obj(), // + g_async_wait_for_vsync_method_, // + java_baton // + ); + }); + } break; } } diff --git a/shell/platform/android/vsync_waiter_android.h b/shell/platform/android/vsync_waiter_android.h index dcc1657175534..7129bb94305e2 100644 --- a/shell/platform/android/vsync_waiter_android.h +++ b/shell/platform/android/vsync_waiter_android.h @@ -44,7 +44,6 @@ class VsyncWaiterAndroid final : public VsyncWaiter { jclass jcaller, jfloat refresh_rate); - const bool use_ndk_choreographer_; FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterAndroid); }; From 992d0f3c252ddb13a2f63c1411da3b5bf8382b06 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 14:48:00 -0800 Subject: [PATCH 2/6] missing files --- .../platform/android/android_choreographer.cc | 61 ------------------- .../platform/android/android_choreographer.h | 30 --------- shell/platform/android/ndk_helpers.h | 2 +- 3 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 shell/platform/android/android_choreographer.cc delete mode 100644 shell/platform/android/android_choreographer.h diff --git a/shell/platform/android/android_choreographer.cc b/shell/platform/android/android_choreographer.cc deleted file mode 100644 index f72787f423920..0000000000000 --- a/shell/platform/android/android_choreographer.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/shell/platform/android/android_choreographer.h" - -#include "flutter/fml/native_library.h" - -// Only avialalbe on API 24+ -typedef void AChoreographer; -// Only available on API 29+ or API 24+ if the architecture is 64-bit. -typedef void (*AChoreographer_frameCallback)(int64_t frameTimeNanos, - void* data); -// Only avialalbe on API 24+ -typedef AChoreographer* (*AChoreographer_getInstance_FPN)(); -typedef void (*AChoreographer_postFrameCallback_FPN)( - AChoreographer* choreographer, - AChoreographer_frameCallback callback, - void* data); -static AChoreographer_getInstance_FPN AChoreographer_getInstance; -static AChoreographer_postFrameCallback_FPN AChoreographer_postFrameCallback; - -namespace flutter { - -bool AndroidChoreographer::ShouldUseNDKChoreographer() { - static std::optional use_ndk_choreographer; - if (use_ndk_choreographer) { - return use_ndk_choreographer.value(); - } - auto libandroid = fml::NativeLibrary::Create("libandroid.so"); - FML_DCHECK(libandroid); - auto get_instance_fn = - libandroid->ResolveFunction( - "AChoreographer_getInstance"); - auto post_frame_callback_fn = - libandroid->ResolveFunction( - "AChoreographer_postFrameCallback64"); -#if FML_ARCH_CPU_64_BITS - if (!post_frame_callback_fn) { - post_frame_callback_fn = - libandroid->ResolveFunction( - "AChoreographer_postFrameCallback"); - } -#endif - if (get_instance_fn && post_frame_callback_fn) { - AChoreographer_getInstance = get_instance_fn.value(); - AChoreographer_postFrameCallback = post_frame_callback_fn.value(); - use_ndk_choreographer = true; - } else { - use_ndk_choreographer = false; - } - return use_ndk_choreographer.value(); -} - -void AndroidChoreographer::PostFrameCallback(OnFrameCallback callback, - void* data) { - AChoreographer* choreographer = AChoreographer_getInstance(); - AChoreographer_postFrameCallback(choreographer, callback, data); -} - -} // namespace flutter diff --git a/shell/platform/android/android_choreographer.h b/shell/platform/android/android_choreographer.h deleted file mode 100644 index 632bc77479e48..0000000000000 --- a/shell/platform/android/android_choreographer.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CHOREOGRAPHER_H_ -#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CHOREOGRAPHER_H_ - -#include "flutter/fml/macros.h" - -#include - -namespace flutter { - -//------------------------------------------------------------------------------ -/// The Android Choreographer is used by `VsyncWaiterAndroid` to await vsync -/// signal. It's only available on API 29+ or API 24+ if the architecture is -/// 64-bit. -/// -class AndroidChoreographer { - public: - typedef void (*OnFrameCallback)(int64_t frame_time_nanos, void* data); - static bool ShouldUseNDKChoreographer(); - static void PostFrameCallback(OnFrameCallback callback, void* data); - - FML_DISALLOW_COPY_AND_ASSIGN(AndroidChoreographer); -}; - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CHOREOGRAPHER_H_ diff --git a/shell/platform/android/ndk_helpers.h b/shell/platform/android/ndk_helpers.h index 8fe5f3e665bee..5b7856aa6e241 100644 --- a/shell/platform/android/ndk_helpers.h +++ b/shell/platform/android/ndk_helpers.h @@ -40,7 +40,7 @@ class NDKHelpers { static bool ATrace_isEnabled(); // API Version 24 - static ChoreographerStatus ChoreographerSupported(); + static ChoreographerSupportStatus ChoreographerSupported(); static AChoreographer* AChoreographer_getInstance(); // Deprecated in 29, available since 24. static void AChoreographer_postFrameCallback( From 285828452c2bd1f8681721f54d8108f36205ab92 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 15:19:11 -0800 Subject: [PATCH 3/6] oops --- shell/platform/android/ndk_helpers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/android/ndk_helpers.cc b/shell/platform/android/ndk_helpers.cc index 6543133c5f231..5912ead4f3dc1 100644 --- a/shell/platform/android/ndk_helpers.cc +++ b/shell/platform/android/ndk_helpers.cc @@ -109,7 +109,7 @@ void InitOnceCallback() { "AChoreographer_getInstance") .value_or(nullptr); if (_AChoreographer_getInstance) { - _AChoreographer_postFrameCallback = + _AChoreographer_postFrameCallback64 = android->ResolveFunction( "AChoreographer_postFrameCallback64"); #if FML_ARCH_CPU_64_BITS From 0f97622015d6c391043546a906836e6d239b8d1a Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 15:25:35 -0800 Subject: [PATCH 4/6] oops --- shell/platform/android/ndk_helpers.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/ndk_helpers.cc b/shell/platform/android/ndk_helpers.cc index 5912ead4f3dc1..74101322a120e 100644 --- a/shell/platform/android/ndk_helpers.cc +++ b/shell/platform/android/ndk_helpers.cc @@ -110,13 +110,17 @@ void InitOnceCallback() { .value_or(nullptr); if (_AChoreographer_getInstance) { _AChoreographer_postFrameCallback64 = - android->ResolveFunction( - "AChoreographer_postFrameCallback64"); + android + ->ResolveFunction( + "AChoreographer_postFrameCallback64") + .value_or(nullptr); #if FML_ARCH_CPU_64_BITS if (!_AChoreographer_postFrameCallback64) { _AChoreographer_postFrameCallback = - android->ResolveFunction( - "AChoreographer_postFrameCallback"); + android + ->ResolveFunction( + "AChoreographer_postFrameCallback") + .value_or(nullptr); } #endif } From cba0bcd3b77fec6e04fd1185d5f83fbb51583a04 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 15:53:13 -0800 Subject: [PATCH 5/6] ...more --- shell/platform/android/vsync_waiter_android.cc | 9 ++++++++- shell/platform/android/vsync_waiter_android.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/vsync_waiter_android.cc b/shell/platform/android/vsync_waiter_android.cc index ccddfb69173ea..7b7f136257ce2 100644 --- a/shell/platform/android/vsync_waiter_android.cc +++ b/shell/platform/android/vsync_waiter_android.cc @@ -34,7 +34,7 @@ void VsyncWaiterAndroid::AwaitVSync() { fml::TaskRunner::RunNowOrPostTask( task_runners_.GetUITaskRunner(), [weak_this]() { NDKHelpers::AChoreographer_postFrameCallback( - NDKHelpers::AChoreographer_getInstance(), &OnVsyncFromNDK, + NDKHelpers::AChoreographer_getInstance(), &OnVsyncFromNDK32, weak_this); }); } break; @@ -62,6 +62,13 @@ void VsyncWaiterAndroid::AwaitVSync() { } } +// static +void VsyncWaiterAndroid::OnVsyncFromNDK32( + long frame_nanos, // NOLINT to match a deprecated NDK interface. + void* data) { + OnVsyncFromNDK(frame_nanos, data); +} + // static void VsyncWaiterAndroid::OnVsyncFromNDK(int64_t frame_nanos, void* data) { auto frame_time = fml::TimePoint::FromEpochDelta( diff --git a/shell/platform/android/vsync_waiter_android.h b/shell/platform/android/vsync_waiter_android.h index 7129bb94305e2..69c3ad912839c 100644 --- a/shell/platform/android/vsync_waiter_android.h +++ b/shell/platform/android/vsync_waiter_android.h @@ -29,6 +29,9 @@ class VsyncWaiterAndroid final : public VsyncWaiter { void AwaitVSync() override; static void OnVsyncFromNDK(int64_t frame_nanos, void* data); + // This needs to match a deprecated NDK interface. + static void OnVsyncFromNDK32(long frame_nanos, // NOLINT + void* data); static void OnVsyncFromJava(JNIEnv* env, jclass jcaller, From 79259ddd3d226cd0dffc4636ca97f474d9d8ab5d Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 9 Feb 2024 16:09:39 -0800 Subject: [PATCH 6/6] missing symbols --- shell/platform/android/ndk_helpers.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/shell/platform/android/ndk_helpers.cc b/shell/platform/android/ndk_helpers.cc index 74101322a120e..65fc9368c8ad3 100644 --- a/shell/platform/android/ndk_helpers.cc +++ b/shell/platform/android/ndk_helpers.cc @@ -149,6 +149,27 @@ ChoreographerSupportStatus NDKHelpers::ChoreographerSupported() { return ChoreographerSupportStatus::kUnsupported; } +AChoreographer* NDKHelpers::AChoreographer_getInstance() { + FML_CHECK(_AChoreographer_getInstance); + return _AChoreographer_getInstance(); +} + +void NDKHelpers::AChoreographer_postFrameCallback( + AChoreographer* choreographer, + AChoreographer_frameCallback callback, + void* data) { + FML_CHECK(_AChoreographer_postFrameCallback); + return _AChoreographer_postFrameCallback(choreographer, callback, data); +} + +void NDKHelpers::AChoreographer_postFrameCallback64( + AChoreographer* choreographer, + AChoreographer_frameCallback64 callback, + void* data) { + FML_CHECK(_AChoreographer_postFrameCallback64); + return _AChoreographer_postFrameCallback64(choreographer, callback, data); +} + bool NDKHelpers::HardwareBufferSupported() { const bool r = _AHardwareBuffer_fromHardwareBuffer != nullptr; return r;