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 a crash calling CallInvoker during shutdown",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
22 changes: 14 additions & 8 deletions vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ struct AbiCallInvoker final : facebook::react::CallInvoker {
AbiCallInvoker(IReactContext const &context) : m_context(context) {}

void invokeAsync(facebook::react::CallFunc &&func) noexcept override {
m_context.CallInvoker().InvokeAsync(
[context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) {
func(GetOrCreateContextRuntime(context, runtimeHandle));
});
auto callInvoker = m_context.CallInvoker();
if (callInvoker) {
callInvoker.InvokeAsync(
[context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) {
func(GetOrCreateContextRuntime(context, runtimeHandle));
});
}
}

void invokeSync(facebook::react::CallFunc &&func) override {
m_context.CallInvoker().InvokeSync(
[context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) {
func(GetOrCreateContextRuntime(context, runtimeHandle));
});
auto callInvoker = m_context.CallInvoker();
if (callInvoker) {
callInvoker.InvokeSync(
[context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) {
func(GetOrCreateContextRuntime(context, runtimeHandle));
});
}
}

private:
Expand Down
Loading