Skip to content

Commit e2b661c

Browse files
acoates-msrnbot
andcommitted
Fix RootComponentView leak (microsoft#13959)
* Fix RootComponentView leak * Change files * format --------- Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com>
1 parent 249b51c commit e2b661c

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix RootComponentView leak",
4+
"packageName": "react-native-windows",
5+
"email": "53619745+rnbot@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ void ReactNativeIsland::ReactViewHost(winrt::Microsoft::ReactNative::IReactViewH
157157
}
158158

159159
if (m_reactViewHost) {
160+
UninitRootView();
160161
m_reactViewHost.DetachViewInstance();
161162
}
162163

vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ void FabricUIManager::startSurface(
176176

177177
void FabricUIManager::stopSurface(facebook::react::SurfaceId surfaceId) noexcept {
178178
m_surfaceManager->stopSurface(surfaceId);
179+
auto &rootDescriptor = m_registry.componentViewDescriptorWithTag(surfaceId);
180+
m_registry.enqueueComponentViewWithComponentHandle(
181+
facebook::react::RootShadowNode::Handle(), surfaceId, rootDescriptor);
179182
}
180183

181184
winrt::Microsoft::ReactNative::ReactNativeIsland FabricUIManager::GetReactNativeIsland(

0 commit comments

Comments
 (0)