From c9d16dcbe9c6de18c09b65e4426343b5082bc8b7 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Mon, 13 Jul 2026 19:30:36 -0700 Subject: [PATCH 1/3] Fix a crash calling CallInvoker during shutdown --- .../TurboModuleProvider.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp b/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp index bfeb719adaa..2f73ffac366 100644 --- a/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +++ b/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp @@ -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: From 748e6cbf4a03c8daccb671e5a66556e09430686f Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Mon, 13 Jul 2026 19:30:43 -0700 Subject: [PATCH 2/3] Change files --- ...ative-windows-4672fa37-ea7f-4ffd-82cd-40e7d8b41de5.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-4672fa37-ea7f-4ffd-82cd-40e7d8b41de5.json diff --git a/change/react-native-windows-4672fa37-ea7f-4ffd-82cd-40e7d8b41de5.json b/change/react-native-windows-4672fa37-ea7f-4ffd-82cd-40e7d8b41de5.json new file mode 100644 index 00000000000..3b1c6d61ae5 --- /dev/null +++ b/change/react-native-windows-4672fa37-ea7f-4ffd-82cd-40e7d8b41de5.json @@ -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" +} From 09a31f8a6fb1eaccffe4f3c07cd1bdbb90ec95b2 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 14 Jul 2026 11:11:28 -0700 Subject: [PATCH 3/3] build fix --- vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp b/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp index 2f73ffac366..7b15527ab45 100644 --- a/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +++ b/vnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp @@ -15,7 +15,7 @@ struct AbiCallInvoker final : facebook::react::CallInvoker { void invokeAsync(facebook::react::CallFunc &&func) noexcept override { auto callInvoker = m_context.CallInvoker(); if (callInvoker) { - callInvoker->InvokeAsync( + callInvoker.InvokeAsync( [context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) { func(GetOrCreateContextRuntime(context, runtimeHandle)); }); @@ -25,7 +25,7 @@ struct AbiCallInvoker final : facebook::react::CallInvoker { void invokeSync(facebook::react::CallFunc &&func) override { auto callInvoker = m_context.CallInvoker(); if (callInvoker) { - callInvoker->InvokeSync( + callInvoker.InvokeSync( [context = m_context, func = std::move(func)](const winrt::Windows::Foundation::IInspectable &runtimeHandle) { func(GetOrCreateContextRuntime(context, runtimeHandle)); });