Repository navigation
Description
Summary
We run react-native-macos in production across several macOS apps on the New Architecture (Fabric) and have been carrying four fixes as downstream patches. They were written against 0.81.9 and we've confirmed all four are still present in 0.83.0 (the current release). We'd like to upstream them and are happy to open PRs — filing as one issue for triage; glad to split into separate issues/PRs if you prefer.
Environment: react-native-macos 0.81.9 and 0.83.0 · New Architecture (Fabric) enabled · macOS.
1. Data race on ShadowNodeFamily::nativeProps_DEPRECATED → crash on window resize
Symptom. Intermittent crash while resizing a window, frequently inside folly::dynamic::type().
Root cause. nativeProps_DEPRECATED (a std::unique_ptr<folly::dynamic>) is replaced by setNativeProps on the JS thread while it is read/copied on the main thread by ShadowNode::clone and by the read-merge-write in UIManager. On macOS a window resize runs layout synchronously on the main thread, so the copy can read freed memory. Nothing guards the pointer.
Location. ReactCommon/react/renderer/core/ShadowNodeFamily.h, ReactCommon/react/renderer/core/ShadowNode.cpp, ReactCommon/react/renderer/uimanager/UIManager.cpp. In 0.83.0 the field is still mutable std::unique_ptr<folly::dynamic> nativeProps_DEPRECATED; with no lock.
Fix. Add mutable std::mutex nativePropsMutex_DEPRECATED; to the family and take it around every read/copy/replace of the pointer — copy the value into a local std::optional<folly::dynamic> under the lock and use the copy outside it.
2. <Modal> has no native presentation on macOS
Symptom. <Modal> renders nothing on macOS under Fabric.
Root cause. RCTModalHostViewComponentView.mm is almost entirely under #if !TARGET_OS_OSX, so the modal host is compiled out on macOS. Still #if !TARGET_OS_OSX in 0.83.0.
Location. React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm.
Fix. Present the modal as an NSWindow sheet attached to the host window. Escape asks JS to dismiss (mirroring the iOS swipe-to-dismiss) rather than closing on its own, so visible stays the source of truth.
3. Stale mouse-hover state after Fabric view recycling
Symptom. After a list scrolls or rebuilds, hover (mouseEntered:/mouseExited:) is reported on the wrong rows, apparently at random.
Root cause. A view taken off-screen while under the pointer never receives mouseExited:, so it returns to the recycle pool with _hasMouseOver == YES and its tracking area and NSViewBoundsDidChangeNotification observer still installed. When the view is reused, mouseEntered: early-returns and the new row never registers the pointer. -prepareForRecycle does not reset this state. (Observed on the 0.81.x line; -prepareForRecycle does not reset hover/tracking state.)
Location. React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm (-prepareForRecycle).
Fix. In -prepareForRecycle, remove the tracking area, set _hasMouseOver = NO, and remove the clip-view bounds observer.
4. Third-party Fabric components provider crashes at launch on macOS when a component has no macOS view
Symptom. Crash at startup during Fabric setup — surfaces to JS as a getEnforcing('PlatformConstants') failure — in any app that depends on a third-party Fabric component without a macOS component view.
Root cause. The generated +[RCTThirdPartyComponentsProvider thirdPartyFabricComponents] builds a dictionary literal:
thirdPartyComponents = @{
@"SomeComponent": NSClassFromString(@"SomeComponentComponentView"),
...
};On macOS NSClassFromString returns nil for any component that ships no macOS component view, and an NSDictionary literal with a nil value raises NSInvalidArgumentException. The set of nil components is app-specific, so there is no single component to blame. In 0.83.0 the generator still emits this literal.
Location. scripts/codegen/templates/RCTThirdPartyComponentsProviderMM.template and scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js.
Fix. Build the map dynamically and skip nil classes — e.g. emit an NSString -> NSString name/class mapping, then populate an NSMutableDictionary only for entries whose NSClassFromString is non-nil. (We currently work around this at runtime by swizzling the provider, but it is a codegen bug worth fixing at the source.)
Happy to send PRs for any of these.
Activity