react-native-windows 0.0.0-canary.782 → 0.0.0-canary.783

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@
14
14
  #include <ReactPropertyBag.h>
15
15
  #include <Utils/Helpers.h>
16
16
  #include <dispatchQueue/dispatchQueue.h>
17
+ #include <eventWaitHandle/eventWaitHandle.h>
17
18
  #include <react/renderer/core/LayoutConstraints.h>
18
19
  #include <react/renderer/core/LayoutContext.h>
19
20
  #include <winrt/Microsoft.ReactNative.Composition.h>
@@ -64,21 +65,24 @@ void CompositionReactViewInstance::InitRootView(
64
65
  .Get(winrt::Microsoft::ReactNative::ReactDispatcherHelper::UIDispatcherProperty())
65
66
  .try_as<IReactDispatcher>();
66
67
 
67
- PostInUIQueue([context{std::move(context)}, viewOptions{std::move(viewOptions)}](
68
- winrt::com_ptr<winrt::Microsoft::ReactNative::implementation::CompositionRootView>
69
- &rootControl) mutable noexcept {
68
+ assert(m_uiDispatcher.HasThreadAccess());
69
+ if (auto rootControl = m_weakRootControl.get()) {
70
70
  rootControl->InitRootView(std::move(context), std::move(viewOptions));
71
- });
71
+ }
72
72
  }
73
73
 
74
74
  void CompositionReactViewInstance::UpdateRootView() noexcept {
75
- PostInUIQueue([](winrt::com_ptr<winrt::Microsoft::ReactNative::implementation::CompositionRootView>
76
- &rootControl) mutable noexcept { rootControl->UpdateRootView(); });
75
+ assert(m_uiDispatcher.HasThreadAccess());
76
+ if (auto rootControl = m_weakRootControl.get()) {
77
+ rootControl->UpdateRootView();
78
+ }
77
79
  }
78
80
 
79
81
  void CompositionReactViewInstance::UninitRootView() noexcept {
80
- PostInUIQueue([](winrt::com_ptr<winrt::Microsoft::ReactNative::implementation::CompositionRootView>
81
- &rootControl) mutable noexcept { rootControl->UninitRootView(); });
82
+ assert(m_uiDispatcher.HasThreadAccess());
83
+ if (auto rootControl = m_weakRootControl.get()) {
84
+ rootControl->UninitRootView();
85
+ }
82
86
  }
83
87
 
84
88
  //===========================================================================
@@ -355,6 +359,13 @@ void CompositionRootView::UninitRootView() noexcept {
355
359
 
356
360
  m_context.CallJSFunction(L"ReactFabric", L"unmountComponentAtNode", GetTag());
357
361
 
362
+ // This is needed to ensure that the unmount JS logic is completed before the the instance is shutdown during
363
+ // instance destruction. Aligns with similar code in ReactInstanceWin::DetachRootView for paper Future: Instead this
364
+ // method should return a Promise, which should be resolved when the JS logic is complete.
365
+ Mso::ManualResetEvent mre;
366
+ m_context.JSDispatcher().Post([&]() { mre.Set(); });
367
+ mre.Wait();
368
+
358
369
  // Paper version gives the JS thread time to finish executing - Is this needed?
359
370
  // m_jsMessageThread.Load()->runOnQueueSync([]() {});
360
371
  }
@@ -4,6 +4,7 @@
4
4
  #include "pch.h"
5
5
  #include "CompositionUIService.h"
6
6
  #include "Composition.CompositionUIService.g.cpp"
7
+ #include <QuirkSettings.h>
7
8
 
8
9
  #include <ReactPropertyBag.h>
9
10
 
@@ -18,6 +19,11 @@ void CompositionUIService::SetCompositionContext(
18
19
  IReactPropertyBag const &properties,
19
20
  ICompositionContext const &compositionContext) noexcept {
20
21
  ReactPropertyBag(properties).Set(CompositionContextPropertyId(), compositionContext);
22
+ // Default to using Bridgeless mode when using fabric
23
+ /*
24
+ winrt::Microsoft::ReactNative::implementation::QuirkSettings::SetIsBridgeless(
25
+ ReactPropertyBag(properties), !!compositionContext);
26
+ */
21
27
  }
22
28
 
23
29
  ICompositionContext CompositionUIService::GetCompositionContext(const IReactPropertyBag &properties) noexcept {
@@ -87,6 +87,12 @@ winrt::Microsoft::ReactNative::ReactPropertyId<bool> IsBridgelessProperty() noex
87
87
  return properties.Get(IsBridgelessProperty()).value_or(false);
88
88
  }
89
89
 
90
+ /*static*/ void QuirkSettings::SetIsBridgeless(
91
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &properties,
92
+ bool value) noexcept {
93
+ properties.Set(IsBridgelessProperty(), value);
94
+ }
95
+
90
96
  #pragma region IDL interface
91
97
 
92
98
  /*static*/ void QuirkSettings::SetMatchAndroidAndIOSStretchBehavior(
@@ -40,6 +40,7 @@ struct QuirkSettings : QuirkSettingsT<QuirkSettings> {
40
40
  winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;
41
41
 
42
42
  static bool GetIsBridgeless(winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;
43
+ static void SetIsBridgeless(const winrt::Microsoft::ReactNative::ReactPropertyBag &properties, bool value) noexcept;
43
44
 
44
45
  #pragma region Public API - part of IDL interface
45
46
  static void SetMatchAndroidAndIOSStretchBehavior(
@@ -529,6 +529,28 @@ std::shared_ptr<facebook::react::DevSettings> ReactInstanceWin::CreateDevSetting
529
529
  return devSettings;
530
530
  }
531
531
 
532
+ Mso::DispatchQueueSettings CreateDispatchQueueSettings(
533
+ const winrt::Microsoft::ReactNative::IReactNotificationService &service) {
534
+ Mso::DispatchQueueSettings queueSettings{};
535
+ queueSettings.TaskStarting = [service](Mso::DispatchQueue const &) noexcept {
536
+ service.SendNotification(
537
+ winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherTaskStartingEventName(), nullptr, nullptr);
538
+ };
539
+ queueSettings.IdleWaitStarting = [service](Mso::DispatchQueue const &) noexcept {
540
+ service.SendNotification(
541
+ winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherIdleWaitStartingEventName(),
542
+ nullptr,
543
+ nullptr);
544
+ };
545
+ queueSettings.IdleWaitCompleted = [service](Mso::DispatchQueue const &) noexcept {
546
+ service.SendNotification(
547
+ winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherIdleWaitCompletedEventName(),
548
+ nullptr,
549
+ nullptr);
550
+ };
551
+ return queueSettings;
552
+ }
553
+
532
554
  #ifdef USE_FABRIC
533
555
  void ReactInstanceWin::InitializeBridgeless() noexcept {
534
556
  InitUIQueue();
@@ -550,12 +572,15 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
550
572
  // null moduleProvider since native modules are not supported in bridgeless
551
573
  LoadModules(devSettings, nullptr, m_options.TurboModuleProvider);
552
574
 
553
- auto jsDispatchQueue = Mso::DispatchQueue::MakeLooperQueue();
575
+ auto jsDispatchQueue =
576
+ Mso::DispatchQueue::MakeLooperQueue(CreateDispatchQueueSettings(m_reactContext->Notifications()));
554
577
  auto jsDispatcher =
555
578
  winrt::make<winrt::Microsoft::ReactNative::implementation::ReactDispatcher>(Mso::Copy(jsDispatchQueue));
556
579
  m_options.Properties.Set(ReactDispatcherHelper::JSDispatcherProperty(), jsDispatcher);
557
580
  m_jsMessageThread.Exchange(std::make_shared<Mso::React::MessageDispatchQueue>(
558
- jsDispatchQueue, nullptr /*errorHandler*/, nullptr /*whenQuitPromise*/));
581
+ jsDispatchQueue,
582
+ Mso::MakeWeakMemberFunctor(this, &ReactInstanceWin::OnError),
583
+ Mso::Copy(m_whenDestroyed)));
559
584
 
560
585
  auto timerRegistry = ::Microsoft::ReactNative::TimerRegistry::CreateTimerRegistry(
561
586
  m_options.Properties.Get(ReactDispatcherHelper::UIDispatcherProperty()).try_as<IReactDispatcher>());
@@ -911,14 +936,7 @@ void ReactInstanceWin::LoadJSBundlesBridgeless(std::shared_ptr<facebook::react::
911
936
  [weakThis = Mso::WeakPtr{this},
912
937
  loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this})]() noexcept {
913
938
  if (auto strongThis = weakThis.GetStrongPtr()) {
914
- auto instance = strongThis->m_instance.LoadWithLock();
915
- auto instanceWrapper = strongThis->m_instanceWrapper.LoadWithLock();
916
- if (!instance || !instanceWrapper) {
917
- return;
918
- }
919
-
920
939
  try {
921
- instanceWrapper->loadBundleSync(Mso::Copy(strongThis->JavaScriptBundleFile()));
922
940
  if (strongThis->State() != ReactInstanceState::HasError) {
923
941
  strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
924
942
  }
@@ -973,6 +991,25 @@ Mso::Future<void> ReactInstanceWin::Destroy() noexcept {
973
991
  m_jsDispatchQueue.Exchange(nullptr);
974
992
  }
975
993
 
994
+ #ifdef USE_FABRIC
995
+ if (m_bridgelessReactInstance) {
996
+ if (auto jsMessageThread = m_jsMessageThread.Exchange(nullptr)) {
997
+ jsMessageThread->runOnQueueSync([&]() noexcept {
998
+ {
999
+ // Release the JSI runtime
1000
+ std::scoped_lock lock{m_mutex};
1001
+
1002
+ this->m_jsiRuntimeHolder = nullptr;
1003
+ this->m_jsiRuntime = nullptr;
1004
+ }
1005
+ this->m_bridgelessReactInstance = nullptr;
1006
+ jsMessageThread->quitSynchronous();
1007
+ });
1008
+ }
1009
+ m_jsDispatchQueue.Exchange(nullptr);
1010
+ }
1011
+ #endif
1012
+
976
1013
  return m_whenDestroyedResult;
977
1014
  }
978
1015
 
@@ -987,26 +1024,8 @@ ReactInstanceState ReactInstanceWin::State() const noexcept {
987
1024
  void ReactInstanceWin::InitJSMessageThread() noexcept {
988
1025
  m_instance.Exchange(std::make_shared<facebook::react::Instance>());
989
1026
 
990
- winrt::Microsoft::ReactNative::IReactNotificationService service = m_reactContext->Notifications();
991
- Mso::DispatchQueueSettings queueSettings{};
992
- queueSettings.TaskStarting = [service](Mso::DispatchQueue const &) noexcept {
993
- service.SendNotification(
994
- winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherTaskStartingEventName(), nullptr, nullptr);
995
- };
996
- queueSettings.IdleWaitStarting = [service](Mso::DispatchQueue const &) noexcept {
997
- service.SendNotification(
998
- winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherIdleWaitStartingEventName(),
999
- nullptr,
1000
- nullptr);
1001
- };
1002
- queueSettings.IdleWaitCompleted = [service](Mso::DispatchQueue const &) noexcept {
1003
- service.SendNotification(
1004
- winrt::Microsoft::ReactNative::ReactDispatcherHelper::JSDispatcherIdleWaitCompletedEventName(),
1005
- nullptr,
1006
- nullptr);
1007
- };
1008
1027
  auto scheduler = Mso::MakeJSCallInvokerScheduler(
1009
- queueSettings,
1028
+ CreateDispatchQueueSettings(m_reactContext->Notifications()),
1010
1029
  m_instance.Load()->getJSCallInvoker(),
1011
1030
  Mso::MakeWeakMemberFunctor(this, &ReactInstanceWin::OnError),
1012
1031
  Mso::Copy(m_whenDestroyed));
@@ -1201,6 +1220,7 @@ void ReactInstanceWin::OnJSError(facebook::react::MapBuffer errorMap) noexcept {
1201
1220
  m_state = ReactInstanceState::HasError;
1202
1221
  AbandonJSCallQueue();
1203
1222
 
1223
+ OnReactInstanceLoaded(errorCode);
1204
1224
  if (m_redboxHandler && m_redboxHandler->isDevSupportEnabled()) {
1205
1225
  m_redboxHandler->showNewError(std::move(errorInfo), isFatal ? ErrorType::JSFatal : ErrorType::JSSoft);
1206
1226
  }
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.0.0-canary.782</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.0.0-canary.783</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
16
16
  <ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>true</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>e46a18f7b78290373e1d65c63bc2e02fbf6f639e</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>c3f4edf2ba3f926a04c9a7573e155dfc573bc792</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.0.0-canary.782",
3
+ "version": "0.0.0-canary.783",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",