Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix crash when reloading an instance with an active ReactNativeIsland",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
22 changes: 10 additions & 12 deletions packages/playground/Samples/simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
import React from 'react';
import {AppRegistry, View} from 'react-native';

export default class Bootstrap extends React.Component {
render() {
return (
<View
accessible={true}
accessibilityValue={{now: 10, min: 0, max: 20}}
style={{borderRadius: 30, width: 60, height: 60, margin: 10}}>
<View style={{backgroundColor: 'magenta', width: 60, height: 60}} />
</View>
);
}
}
const Bootstrap = () => {
return (
<View
accessible={true}
accessibilityValue={{now: 10, min: 0, max: 20}}
style={{borderRadius: 30, width: 60, height: 60, margin: 10}}>
<View style={{backgroundColor: 'magenta', width: 60, height: 60}} />
</View>
);
};

AppRegistry.registerComponent('Bootstrap', () => Bootstrap);
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,6 @@ void ReactNativeIsland::UpdateRootViewInternal() noexcept {
}
}

struct AutoMRE {
~AutoMRE() {
mre.Set();
}
Mso::ManualResetEvent mre;
};

void ReactNativeIsland::UninitRootView() noexcept {
if (!m_isInitialized) {
return;
Expand All @@ -539,17 +532,6 @@ void ReactNativeIsland::UninitRootView() noexcept {
auto uiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()));
uiManager->stopSurface(static_cast<facebook::react::SurfaceId>(RootTag()));

// This is needed to ensure that the unmount JS logic is completed before the the instance is shutdown during
// instance destruction. Aligns with similar code in ReactInstanceWin::DetachRootView for paper Future: Instead
// this method should return a Promise, which should be resolved when the JS logic is complete. The task will auto
// set the event on destruction to ensure that the event is set if the JS Queue has already been shutdown
Mso::ManualResetEvent mre;
m_context.JSDispatcher().Post([autoMRE = std::make_unique<AutoMRE>(AutoMRE{mre})]() {});
mre.Wait();

// Paper version gives the JS thread time to finish executing - Is this needed?
// m_jsMessageThread.Load()->runOnQueueSync([]() {});
}

m_rootTag = -1;
Expand Down