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 18c5c9d7dd1452d70def81b9d78afd4623edbd9a..73af0dc2af18b487130703a12ee8ff98e11ae99a 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 1e3e88a788a1376b0a77a88d91641f84ca837e97..884e9eb2702970b43ac772fa8d3916ea440444f7 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 2f4ed0f034153b4297b694bdbfba4b51d40dcce5..4b83f510ea85e173dcbb6a1e1689e69d235ac3aa 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 a191a35ff7040e5da255b4962555c5947b82ab1a..b09ba7078a230ebb9916eccc4c35b8bdf4605dcf 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 840fd0768b35bf410fab749f5b79fe5b3b4a7c2d..3676b205c55cb572363d3567c5d64fdd468c442f 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 3d047fc92527203ee053588680cf929a31407a8a..94001884ba0518baae572a4ae52ed64cf2f55b68 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(