From 56ad8e2ce07f699e92540ee559d79234eabf8765 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Mon, 23 Dec 2024 19:15:21 +0800 Subject: [PATCH 1/4] Signed-off-by: csc --- shell/common/animator.cc | 2 +- shell/common/vsync_waiter.cc | 3 +- shell/common/vsync_waiter.h | 4 +- .../src/main/cpp/types/libflutter/index.d.ets | 4 +- .../ets/embedding/engine/FlutterEngine.ets | 3 ++ .../main/ets/embedding/engine/FlutterNapi.ets | 3 ++ .../systemchannels/NativeVsyncChannel.ets | 50 +++++++++++++++++++ shell/platform/ohos/library_loader.cpp | 3 ++ .../ohos/napi/platform_view_ohos_napi.cpp | 44 ++++++++++++++++ .../ohos/napi/platform_view_ohos_napi.h | 4 ++ shell/platform/ohos/ohos_shell_holder.h | 4 ++ shell/platform/ohos/vsync_waiter_ohos.cpp | 17 +++++-- shell/platform/ohos/vsync_waiter_ohos.h | 5 ++ 13 files changed, 138 insertions(+), 8 deletions(-) create mode 100644 shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets diff --git a/shell/common/animator.cc b/shell/common/animator.cc index a0704c7b8d..e5914f1a62 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -38,7 +38,7 @@ Animator::Animator(Delegate& delegate, task_runners.GetPlatformTaskRunner() == task_runners.GetRasterTaskRunner() ? 1 - : 2)), + : 4)), #endif // SHELL_ENABLE_METAL pending_frame_semaphore_(1), weak_factory_(this) { diff --git a/shell/common/vsync_waiter.cc b/shell/common/vsync_waiter.cc index a23904f2d4..1fc436ca3c 100644 --- a/shell/common/vsync_waiter.cc +++ b/shell/common/vsync_waiter.cc @@ -87,8 +87,9 @@ void VsyncWaiter::ScheduleSecondaryCallback(uintptr_t id, void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks) { +#if !defined(FML_OS_OHOS) FML_DCHECK(fml::TimePoint::Now() >= frame_start_time); - +#endif Callback callback; std::vector secondary_callbacks; diff --git a/shell/common/vsync_waiter.h b/shell/common/vsync_waiter.h index cfce4524df..1d4a193adb 100644 --- a/shell/common/vsync_waiter.h +++ b/shell/common/vsync_waiter.h @@ -31,7 +31,9 @@ class VsyncWaiter : public std::enable_shared_from_this { /// See also |PointerDataDispatcher::ScheduleSecondaryVsyncCallback| and /// |Animator::ScheduleMaybeClearTraceFlowIds|. void ScheduleSecondaryCallback(uintptr_t id, const fml::closure& callback); - + // For DVsync control + virtual void DisableDVsync() {} + virtual void EnableDVsync() {} protected: // On some backends, the |FireCallback| needs to be made from a static C // method. diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets index 629988a893..bdd123b129 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets @@ -169,4 +169,6 @@ export const nativeUnicodeIsEmojiModifierBase: (code: number) => number; export const nativeUnicodeIsVariationSelector: (code: number) => number; -export const nativeUnicodeIsRegionalIndicatorSymbol: (code: number) => number; \ No newline at end of file +export const nativeUnicodeIsRegionalIndicatorSymbol: (code: number) => number; + +export const nativeSetDVsyncSwitch: (nativeShellHolderId: number, isEnable: boolean) => void; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index cd3cd81923..bb6b692fe6 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -39,6 +39,7 @@ import LocalizationPlugin from '../../plugin/localization/LocalizationPlugin' import SettingsChannel from './systemchannels/SettingsChannel'; import PlatformViewsController from '../../plugin/platform/PlatformViewsController'; import { FlutterRenderer } from './renderer/FlutterRenderer'; +import NativeVsyncChannel from './systemchannels/NativeVsyncChannel'; const TAG = "FlutterEngine"; @@ -70,6 +71,7 @@ export default class FlutterEngine implements EngineLifecycleListener{ private localizationPlugin: LocalizationPlugin | null = null; private settingsChannel: SettingsChannel | null = null; private platformViewsController: PlatformViewsController; + private nativeVsyncChannel: NativeVsyncChannel | null = null; /** * 需要初始化的工作: @@ -125,6 +127,7 @@ export default class FlutterEngine implements EngineLifecycleListener{ this.accessibilityChannel = new AccessibilityChannel(this.dartExecutor, this.flutterNapi); this.flutterNapi.addEngineLifecycleListener(this); this.localizationPlugin = new LocalizationPlugin(context, this.localeChannel); + this.nativeVsyncChannel = new NativeVsyncChannel(this.dartExecutor, this.flutterNapi); // It should typically be a fresh, unattached NAPI. But on a spawned engine, the NAPI instance // is already attached to a native shell. In that case, the Java FlutterEngine is created around diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets index e36a566682..eca96c8496 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets @@ -570,6 +570,9 @@ export default class FlutterNapi { return Boolean(flutter.nativeUnicodeIsRegionalIndicatorSymbol(code)); } + SetDVsyncSwitch(isEnable: boolean): void { + flutter.nativeSetDVsyncSwitch(this.nativeShellHolderId!, isEnable); + } } export interface AccessibilityDelegate { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets new file mode 100644 index 0000000000..0afc63c245 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Log from '../../../util/Log'; +import DartExecutor from '../dart/DartExecutor'; +import BasicMessageChannel, { MessageHandler, Reply} from '../../../plugin/common/BasicMessageChannel'; +import HashMap from '@ohos.util.HashMap'; +import StandardMessageCodec from '../../../plugin/common/StandardMessageCodec'; +import StringUtils from '../../../util/StringUtils'; +import Any from '../../../plugin/common/Any'; +import FlutterNapi from '../FlutterNapi'; + +/** +* nativeVsync功能channel +*/ +export default class NativeVsyncChannel implements MessageHandler { + private static TAG = "NativeVsyncChannel"; + private static CHANNEL_NAME = "flutter/nativevsync"; + private channel: BasicMessageChannel; + private flutterNapi: FlutterNapi; + + onMessage(message: object, reply: Reply): void { + let data: HashMap = message as HashMap; + let isEnable: boolean = data.get("isEnable"); + this.flutterNapi.setDVsyncSwitch(isEnable); + + Log.d(NativeVsyncChannel.TAG, `Received message: isEnable:$isEnable`); + reply.reply(StringUtils.stringToArrayBuffer("")); + } + + constructor(dartExecutor: DartExecutor, flutterNapi: FlutterNapi) { + Log.i(NativeVsyncChannel.TAG, "Channel entered"); + this.channel = new BasicMessageChannel( + dartExecutor, NativeVsyncChannel.CHANNEL_NAME, StandardMessageCodec.INSTANCE); + this.channel.setMessageHandler(this); + this.flutterNapi = flutterNapi; + } +} \ No newline at end of file diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 4f7216d73e..dcd31d1bdb 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -181,6 +181,9 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeUnicodeIsRegionalIndicatorSymbol", flutter::PlatformViewOHOSNapi::nativeUnicodeIsRegionalIndicatorSymbol), + DECLARE_NAPI_FUNCTION( + "nativeSetDVsyncSwitch", + flutter::PlatformViewOHOSNapi::nativeSetDVsyncSwitch), }; FML_DLOG(INFO) << "Init NAPI size=" << sizeof(desc) / sizeof(desc[0]); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 431ff15b31..2ed795f5f3 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -31,6 +31,7 @@ #include "flutter/shell/platform/ohos/ohos_xcomponent_adapter.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "flutter/shell/platform/ohos/types.h" +#include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" #include "flutter/lib/ui/plugins/callback_cache.h" #include "unicode/uchar.h" @@ -2224,4 +2225,47 @@ napi_value PlatformViewOHOSNapi::nativeUnicodeIsRegionalIndicatorSymbol(napi_env napi_create_int32(env, (int)is_emoji, &result); return result; } + +napi_value PlatformViewOHOSNapi::nativeSetDVsyncSwitch(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value result; + napi_value args[2] = {nullptr}; + napi_status ret = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (ret != napi_ok) { + LOGE("nativeSetDVsyncSwitch napi_get_cb_info error"); + napi_create_int32(env, -1, &result); + return result; + } + + int64_t shell_holder; + ret = napi_get_value_int64(env, args[0], &shell_holder); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeSetDVsyncSwitch shell_holder " + "napi_get_value_int64 error"; + return nullptr; + } + + bool isEnable; + ret = napi_get_value_bool(env, args[1], &isEnable); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeSetDVsyncSwitch isEnable " + "napi_get_value_bool error"; + return nullptr; + } + + auto vsyncWaiter = std::shared_ptr(OHOS_SHELL_HOLDER->GetVsyncWaiter().lock()); + auto vsync_waiter_ohos = std::static_pointer_cast(vsyncWaiter); + + if (isEnable) { + LOGD("EnableDVsync"); + vsync_waiter_ohos->EnableDVsync(); + } else { + LOGD("DisableDVsync"); + vsync_waiter_ohos->DisableDVsync(); + } + + napi_create_int32(env, 0, &result); + return result; +} } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index b246ad75c0..7e23296ac9 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -260,6 +260,10 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); + static napi_value nativeSetDVsyncSwitch( + napi_env env, + napi_callback_info info); + private: static napi_env env_; napi_ref ref_napi_obj_; diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 4a87730862..6fba882739 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -68,6 +68,10 @@ class OHOSShellHolder { return shell_->GetPlatformMessageHandler(); } + const std::weak_ptr& GetVsyncWaiter() const { + return shell_->GetVsyncWaiter(); + } + private: std::optional BuildRunConfiguration( const std::string& entrypoint, diff --git a/shell/platform/ohos/vsync_waiter_ohos.cpp b/shell/platform/ohos/vsync_waiter_ohos.cpp index 1330506a8a..0d40e43418 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.cpp +++ b/shell/platform/ohos/vsync_waiter_ohos.cpp @@ -69,10 +69,6 @@ void VsyncWaiterOHOS::OnVsyncFromOHOS(long long timestamp, void* data) { int64_t frame_nanos = static_cast(timestamp); auto frame_time = fml::TimePoint::FromEpochDelta( fml::TimeDelta::FromNanoseconds(frame_nanos)); - auto now = fml::TimePoint::Now(); - if (frame_time > now) { - frame_time = now; - } auto target_time = frame_time + fml::TimeDelta::FromNanoseconds( 1000000000.0 / g_refresh_rate_); auto* weak_this = reinterpret_cast*>(data); @@ -96,4 +92,17 @@ void VsyncWaiterOHOS::OnUpdateRefreshRate(long long refresh_rate) { g_refresh_rate_ = static_cast(refresh_rate); } +void VsyncWaiterOHOS::DisableDVsync() { + if (dvsyncEnabled.load()) { + OH_NativeVSync_DVSyncSwitch(vsyncHandle, false); + dvsyncEnabled.store(false); + } +} + +void VsyncWaiterOHOS::EnableDVsync() { + if (!dvsyncEnabled.load()) { + OH_NativeVSync_DVSyncSwitch(vsyncHandle, true); + dvsyncEnabled.store(true); + } +} } // namespace flutter diff --git a/shell/platform/ohos/vsync_waiter_ohos.h b/shell/platform/ohos/vsync_waiter_ohos.h index e9aac66c85..b178455404 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.h +++ b/shell/platform/ohos/vsync_waiter_ohos.h @@ -16,6 +16,7 @@ #ifndef VSYNC_WAITER_OHOS_H #define VSYNC_WAITER_OHOS_H #include +#include #include #include "flutter/fml/macros.h" @@ -30,7 +31,11 @@ class VsyncWaiterOHOS final : public VsyncWaiter { ~VsyncWaiterOHOS() override; + void DisableDVsync() override; + void EnableDVsync() override; + private: + std::atomic dvsyncEnabled{false}; thread_local static bool firstCall; // |VsyncWaiter| void AwaitVSync() override; -- Gitee From 7b39f456bae2e43b3d59bc5f2aa5f903fbd3fd43 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Mon, 23 Dec 2024 19:37:47 +0800 Subject: [PATCH 2/4] Signed-off-by: csc --- shell/platform/ohos/vsync_waiter_ohos.cpp | 4 ++-- shell/platform/ohos/vsync_waiter_ohos.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/vsync_waiter_ohos.cpp b/shell/platform/ohos/vsync_waiter_ohos.cpp index 0d40e43418..6c4c9d3ace 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.cpp +++ b/shell/platform/ohos/vsync_waiter_ohos.cpp @@ -93,14 +93,14 @@ void VsyncWaiterOHOS::OnUpdateRefreshRate(long long refresh_rate) { } void VsyncWaiterOHOS::DisableDVsync() { - if (dvsyncEnabled.load()) { + if (dvsyncEnabled.load() && OH_GetSdkApiVersion() > 13) { OH_NativeVSync_DVSyncSwitch(vsyncHandle, false); dvsyncEnabled.store(false); } } void VsyncWaiterOHOS::EnableDVsync() { - if (!dvsyncEnabled.load()) { + if (!dvsyncEnabled.load() && OH_GetSdkApiVersion() > 13) { OH_NativeVSync_DVSyncSwitch(vsyncHandle, true); dvsyncEnabled.store(true); } diff --git a/shell/platform/ohos/vsync_waiter_ohos.h b/shell/platform/ohos/vsync_waiter_ohos.h index b178455404..1ee34c5dd7 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.h +++ b/shell/platform/ohos/vsync_waiter_ohos.h @@ -15,9 +15,10 @@ #ifndef VSYNC_WAITER_OHOS_H #define VSYNC_WAITER_OHOS_H -#include #include +#include +#include #include #include "flutter/fml/macros.h" #include "flutter/shell/common/vsync_waiter.h" -- Gitee From 5ea4077983dc1b829933ca881799fa9a88cb15d7 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Thu, 26 Dec 2024 16:33:47 +0800 Subject: [PATCH 3/4] Signed-off-by: csc --- shell/platform/ohos/vsync_waiter_ohos.cpp | 44 ++++++++++++++++++++--- shell/platform/ohos/vsync_waiter_ohos.h | 5 +++ 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/vsync_waiter_ohos.cpp b/shell/platform/ohos/vsync_waiter_ohos.cpp index 6c4c9d3ace..8c044090fc 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.cpp +++ b/shell/platform/ohos/vsync_waiter_ohos.cpp @@ -16,6 +16,7 @@ #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" #include "napi_common.h" #include "ohos_logging.h" +#include #include namespace flutter { @@ -23,6 +24,7 @@ namespace flutter { static std::atomic_uint g_refresh_rate_ = 60; const char* flutterSyncName = "flutter_connect"; +const char* NATIVE_DVSYNC_SO = "libnative_vsync.so" thread_local bool VsyncWaiterOHOS::firstCall = true; @@ -35,6 +37,11 @@ VsyncWaiterOHOS::VsyncWaiterOHOS(const flutter::TaskRunners& task_runners) VsyncWaiterOHOS::~VsyncWaiterOHOS() { OH_NativeVSync_Destroy(vsyncHandle); vsyncHandle = nullptr; + nativeDvsyncFunc_ = nullptr; + if (handle_) { + dlclose(handle_); + handle_ = nullptr; + } } void VsyncWaiterOHOS::AwaitVSync() { @@ -93,16 +100,45 @@ void VsyncWaiterOHOS::OnUpdateRefreshRate(long long refresh_rate) { } void VsyncWaiterOHOS::DisableDVsync() { - if (dvsyncEnabled.load() && OH_GetSdkApiVersion() > 13) { - OH_NativeVSync_DVSyncSwitch(vsyncHandle, false); + if (dvsyncEnabled.load()) { + SetDvsyncSwitch(false); dvsyncEnabled.store(false); } } void VsyncWaiterOHOS::EnableDVsync() { - if (!dvsyncEnabled.load() && OH_GetSdkApiVersion() > 13) { - OH_NativeVSync_DVSyncSwitch(vsyncHandle, true); + if (!dvsyncEnabled.load()) { + SetDvsyncSwitch(true); dvsyncEnabled.store(true); } } + +void VsyncWaiterOHOS::SetDvsyncSwitch(bool enableDvsync) { + if (apiVersion_ == 0) { + apiVersion_ = OH_GetSdkApiVersion(); + } + if (apiVersion_ < 14) { + LOGI("current api version not support native dvsync!") + return; + } + if (!handle_) { + handle_ = dlopen(NATIVE_DVSYNC_SO, RTLD_NOW); + } + if (!handle_) { + LOGE("SetDvsyncSwitch load %{public}s failed!", NATIVE_DVSYNC_SO); + return; + } + + if (!nativeDvsyncFunc_) { + nativeDvsyncFunc_ = reinterpret_cast(dlsm(handle_, "OH_NativeVSync_DVSyncSwitch")); + } + if (!nativeDvsyncFunc_) { + LOGE("SetDvsyncSwitch load OH_NativeVSync_DVSyncSwitch failed!"); + dlclose(handle_); + handle_ = nullptr; + return; + } + nativeDvsyncFunc_(vsyncHandle, enableDvsync); +} + } // namespace flutter diff --git a/shell/platform/ohos/vsync_waiter_ohos.h b/shell/platform/ohos/vsync_waiter_ohos.h index 1ee34c5dd7..28fbff2d58 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.h +++ b/shell/platform/ohos/vsync_waiter_ohos.h @@ -24,6 +24,7 @@ #include "flutter/shell/common/vsync_waiter.h" namespace flutter { +using NativeDvsyncFunc = int (*)(OH_NativeVSync* nativeVSync, bool enable); class VsyncWaiterOHOS final : public VsyncWaiter { public: @@ -45,8 +46,12 @@ class VsyncWaiterOHOS final : public VsyncWaiter { static void ConsumePendingCallback(std::weak_ptr* weak_this, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time); + void SetDvsyncSwitch(bool enableDvsync); OH_NativeVSync* vsyncHandle; + NativeDvsyncFunc nativeDvsyncFunc_ = nullptr; + void *handle_ = nullptr; + int32_t apiVersion_ = 0; FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterOHOS); }; } // namespace flutter -- Gitee From cd9463dbd03e263dd2d44cb78b1101dc7feb2768 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Thu, 26 Dec 2024 17:04:48 +0800 Subject: [PATCH 4/4] Signed-off-by: csc --- shell/common/animator.cc | 3 ++- shell/platform/ohos/vsync_waiter_ohos.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/common/animator.cc b/shell/common/animator.cc index e5914f1a62..b26f1e3458 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -19,6 +19,7 @@ namespace { // for further discussion on why this is necessary. constexpr fml::TimeDelta kNotifyIdleTaskWaitTime = fml::TimeDelta::FromMilliseconds(51); +constexpr uint32_t DVSYNC_BUFFER_COUNT = 4; } // namespace @@ -38,7 +39,7 @@ Animator::Animator(Delegate& delegate, task_runners.GetPlatformTaskRunner() == task_runners.GetRasterTaskRunner() ? 1 - : 4)), + : DVSYNC_BUFFER_COUNT)), #endif // SHELL_ENABLE_METAL pending_frame_semaphore_(1), weak_factory_(this) { diff --git a/shell/platform/ohos/vsync_waiter_ohos.cpp b/shell/platform/ohos/vsync_waiter_ohos.cpp index 8c044090fc..88d1208f5e 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.cpp +++ b/shell/platform/ohos/vsync_waiter_ohos.cpp @@ -22,6 +22,7 @@ namespace flutter { static std::atomic_uint g_refresh_rate_ = 60; +static constexpr uint32_t SUPPORT_API_VERSION = 14; const char* flutterSyncName = "flutter_connect"; const char* NATIVE_DVSYNC_SO = "libnative_vsync.so" @@ -117,7 +118,7 @@ void VsyncWaiterOHOS::SetDvsyncSwitch(bool enableDvsync) { if (apiVersion_ == 0) { apiVersion_ = OH_GetSdkApiVersion(); } - if (apiVersion_ < 14) { + if (apiVersion_ < SUPPORT_API_VERSION) { LOGI("current api version not support native dvsync!") return; } -- Gitee