From 0db887fb65f84ea4bcbd229b670a378f58da640f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9E=BF=E6=AC=A3?= Date: Sat, 22 Feb 2025 14:33:15 +0800 Subject: [PATCH] fix preallocation queue clean up timing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 瞿欣 --- .../src/main/cpp/RNOH/MountingManager.h | 1 + .../main/cpp/RNOH/MountingManagerArkTS.cpp | 5 +++++ .../src/main/cpp/RNOH/MountingManagerArkTS.h | 3 ++- .../src/main/cpp/RNOH/MountingManagerCAPI.cpp | 21 ++++++++++++------- .../src/main/cpp/RNOH/MountingManagerCAPI.h | 3 ++- .../src/main/cpp/RNOH/SchedulerDelegate.cpp | 9 +++++++- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManager.h b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManager.h index 18c5c9d7..73af0dc2 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManager.h +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManager.h @@ -58,5 +58,6 @@ class MountingManager { facebook::react::ComponentDescriptor const& componentDescriptor) = 0; virtual void clearPreallocatedViews() = 0; + virtual void clearPreallocationRequestQueue() = 0; }; } // namespace rnoh diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.cpp index 1e3e88a7..884e9eb2 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.cpp @@ -85,4 +85,9 @@ void MountingManagerArkTS::updateView( void MountingManagerArkTS::clearPreallocatedViews() { throw RNOHError("Preallocation is not implemented in ArkTS architecture."); } + +void MountingManagerArkTS::clearPreallocationRequestQueue() +{ + throw RNOHError("Preallocation is not implemented in ArkTS architecture."); +} } // namespace rnoh \ No newline at end of file diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.h b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.h index 2f4ed0f0..4b83f510 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.h +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerArkTS.h @@ -73,7 +73,8 @@ class MountingManagerArkTS final : public MountingManager { folly::dynamic props, facebook::react::ComponentDescriptor const& componentDescriptor) override; - void clearPreallocatedViews(); + void clearPreallocatedViews(); + void clearPreallocationRequestQueue(); private: ShadowViewRegistry::Shared shadowViewRegistry; diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.cpp index a191a35f..b09ba707 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.cpp @@ -66,15 +66,15 @@ void MountingManagerCAPI::didMount(MutationList const& mutations) { HarmonyReactMarker::logMarker( HarmonyReactMarker::HarmonyReactMarkerId::FABRIC_BATCH_EXECUTION_START); - m_componentInstanceProvider->clearPreallocationRequestQueue(); - for (auto const& mutation : mutations) { - try { - this->handleMutation(mutation); - } catch (std::exception const& e) { - LOG(ERROR) << "Mutation " << getMutationNameFromType(mutation.type) - << " failed: " << e.what(); + + for (auto const& mutation : mutations) { + try { + this->handleMutation(mutation); + } catch (std::exception const& e) { + LOG(ERROR) << "Mutation " << getMutationNameFromType(mutation.type) + << " failed: " << e.what(); + } } - } HarmonyReactMarker::logMarker( HarmonyReactMarker::HarmonyReactMarkerId::FABRIC_BATCH_EXECUTION_END); } @@ -374,4 +374,9 @@ void MountingManagerCAPI::schedulerDidSendAccessibilityEvent( void MountingManagerCAPI::clearPreallocatedViews() { m_componentInstanceProvider->clearPreallocatedViews(); } + +void MountingManagerCAPI::clearPreallocationRequestQueue() +{ + m_componentInstanceProvider->clearPreallocationRequestQueue(); +} } // namespace rnoh diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.h b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.h index 840fd076..3676b205 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.h +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/MountingManagerCAPI.h @@ -89,7 +89,8 @@ class MountingManagerCAPI final : public MountingManager { const facebook::react::ShadowView& shadowView, std::string const& eventType) override; - void clearPreallocatedViews(); + void clearPreallocatedViews(); + void clearPreallocationRequestQueue(); private: void updateComponentWithShadowView( diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/SchedulerDelegate.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/SchedulerDelegate.cpp index 3d047fc9..94001884 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/SchedulerDelegate.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/SchedulerDelegate.cpp @@ -65,11 +65,18 @@ void SchedulerDelegate::schedulerDidFinishTransaction( [otherMutation, mutationVecs, this]( MountingManager::Shared const& mountingManager) { mountingManager->didMount(otherMutation); - mountingManager->clearPreallocatedViews(); mountingManager->finalizeMutationUpdates(mutationVecs); }); + performOnMainThread( + [otherMutation, mutationVecs, this]( + MountingManager::Shared const& mountingManager) { + mountingManager->clearPreallocatedViews(); + }); logTransactionTelemetryMarkers(transaction); }); + if (auto mountingManager = m_mountingManager.lock()) { + mountingManager->clearPreallocationRequestQueue(); + } } void SchedulerDelegate::logTransactionTelemetryMarkers( -- Gitee