From 0a125579f8ce8465b68ba378a836d3c0df96d8b4 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Fri, 22 Mar 2024 03:44:04 -0700 Subject: [PATCH] Invalidate displaylink when invalidate instance in bridgeless mode (#43603) Summary: `RCTDisplayLink` retains itself because of `CADisplayLink`, let's call `invalidate` to break the retain cycle. cc philIip ## Changelog: [IOS] [FIXED] - [Fabric] Invalidate displaylink when invalidate instance in bridgeless mode Pull Request resolved: https://github.com/facebook/react-native/pull/43603 Test Plan: After instance invalidate, `RCTDisplayLink` deallocated . Reviewed By: fabriziocucci Differential Revision: D55239145 Pulled By: javache fbshipit-source-id: d9ceb9cd3a2cd91700e917c909d7097dacba240b --- .../react/runtime/platform/ios/ReactCommon/RCTInstance.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 639cb889fab0e8..4b80999f517898 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -170,6 +170,7 @@ - (void)invalidate self->_jsRuntimeFactory = nullptr; self->_appTMMDelegate = nil; self->_delegate = nil; + [self->_displayLink invalidate]; self->_displayLink = nil; self->_turboModuleManager = nil;