Skip to content

Commit 935e5a7

Browse files
authored
Fix crash when reloading an instance with an active ReactNativeIsland (#14676)
* Fix crash when reloading an instance with an active ReactNativeIsland * Change files * Update simple sample to use function component rather than component class * More cleanup * Fix warnings
1 parent 9a999fe commit 935e5a7

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
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 crash when reloading an instance with an active ReactNativeIsland",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/playground/Samples/simple.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
import React from 'react';
77
import {AppRegistry, View} from 'react-native';
88

9-
export default class Bootstrap extends React.Component {
10-
render() {
11-
return (
12-
<View
13-
accessible={true}
14-
accessibilityValue={{now: 10, min: 0, max: 20}}
15-
style={{borderRadius: 30, width: 60, height: 60, margin: 10}}>
16-
<View style={{backgroundColor: 'magenta', width: 60, height: 60}} />
17-
</View>
18-
);
19-
}
20-
}
9+
const Bootstrap = () => {
10+
return (
11+
<View
12+
accessible={true}
13+
accessibilityValue={{now: 10, min: 0, max: 20}}
14+
style={{borderRadius: 30, width: 60, height: 60, margin: 10}}>
15+
<View style={{backgroundColor: 'magenta', width: 60, height: 60}} />
16+
</View>
17+
);
18+
};
2119

2220
AppRegistry.registerComponent('Bootstrap', () => Bootstrap);

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,6 @@ void ReactNativeIsland::UpdateRootViewInternal() noexcept {
521521
}
522522
}
523523

524-
struct AutoMRE {
525-
~AutoMRE() {
526-
mre.Set();
527-
}
528-
Mso::ManualResetEvent mre;
529-
};
530-
531524
void ReactNativeIsland::UninitRootView() noexcept {
532525
if (!m_isInitialized) {
533526
return;
@@ -540,17 +533,6 @@ void ReactNativeIsland::UninitRootView() noexcept {
540533
auto uiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
541534
winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()));
542535
uiManager->stopSurface(static_cast<facebook::react::SurfaceId>(RootTag()));
543-
544-
// This is needed to ensure that the unmount JS logic is completed before the the instance is shutdown during
545-
// instance destruction. Aligns with similar code in ReactInstanceWin::DetachRootView for paper Future: Instead
546-
// this method should return a Promise, which should be resolved when the JS logic is complete. The task will auto
547-
// set the event on destruction to ensure that the event is set if the JS Queue has already been shutdown
548-
Mso::ManualResetEvent mre;
549-
m_context.JSDispatcher().Post([autoMRE = std::make_unique<AutoMRE>(AutoMRE{mre})]() {});
550-
mre.Wait();
551-
552-
// Paper version gives the JS thread time to finish executing - Is this needed?
553-
// m_jsMessageThread.Load()->runOnQueueSync([]() {});
554536
}
555537

556538
m_rootTag = -1;

0 commit comments

Comments
 (0)