react-native-macos/React/Base
Saad Najmi 85ceff529f Port RCTDisplayLink fix from React Native macOS (#35359)
Summary:
Cherry pick e877ebfe08 from React Native macOS into React Native Core. We've had this bug fix in our fork for a while now, so it's probably safe.

=== Original change notes ===

First, misc straightforward deprecated API updates.

Second, defensive changes to potentially address RCTDisplayLink crash.
Real-world data suggests crashes with this stack:
CVDisplayLink::start()
-[RCTDisplayLink updateJSDisplayLinkState] (RCTDisplayLink.m:157)
-[RCTDisplayLink registerModuleForFrameUpdates:withModuleData:]_block_invoke (RCTDisplayLink.m:67)
-[RCTTiming timerDidFire] (RCTTiming.mm:324)
-[_RCTTimingProxy timerDidFire] (RCTTiming.mm:93)

Some symbols are missing in this stack, presumably due to compiler optimizations.
-updateJSDisplayLinkState is calling CVDisplayLinkStart as a result of a
call to "_jsDisplayLink.paused = NO".
-registerModuleForFrameUpdates block is presumably getting called via pauseCallback,
likely via [RCTTiming startTimers], presumably owned by RCTCxxBridge.

The most likely immediate explanation for the crash is that we are calling
CVDisplayLinkStart with a zombie _displayLink pointer.
However there is a lot of indirection here as well as thread-hopping, and
unfortunately no clearly incorrect code that would explain such a zombie pointer.

Some defensive changes:
-explicitly remove the association to pauseCallback when underlying display link object is invalidated.
-remove a prior attempt at additional check in updateJSDisplayLinkState itself as it is not relevant.
-make sure we explicitly set _displayLink to NULL when we release it, such that there is one less failure point.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - RCTDisplayLink fix plus bonus deprecated API cleanup

Pull Request resolved: https://github.com/facebook/react-native/pull/35359

Test Plan: CI should pass.

Reviewed By: cipolleschi

Differential Revision: D41335438

Pulled By: christophpurrer

fbshipit-source-id: 5e97d28eab7dd8e5c81d0a5386df6631e16405a2
2022-11-16 06:27:35 -08:00
..
Surface Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTAssert.h Enable -Wpedantic for targets inside ReactCommon 2022-08-11 04:37:35 -07:00
RCTAssert.m Minor: Rename RCTNotAllowedInAppWideFabric to RCTNotAllowedInFabricWithoutLegacy 2022-07-08 15:07:55 -07:00
RCTBridge+Private.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTBridge.h Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTBridge.m Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTBridgeConstants.h Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTBridgeConstants.m Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTBridgeDelegate.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTBridgeMethod.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTBridgeModule.h Modularlize RCTBridgeModule.h 3/n - Move RCTTurboModuleRegistry.h to its own file in ReactInternal target (#34514) 2022-09-09 15:10:14 -07:00
RCTBridgeModuleDecorator.h 1/5 Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach @synthesize ivars to RCTTurboModules, in Bridge mode 2022-02-25 08:50:34 -08:00
RCTBridgeModuleDecorator.m 1/5 Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach @synthesize ivars to RCTTurboModules, in Bridge mode 2022-02-25 08:50:34 -08:00
RCTBundleManager.h Modularlize RCTBridgeModule.h 2/n - Fix rn-tester CI breakage on RCTBundleManager.h (#34515) 2022-08-27 07:08:30 -07:00
RCTBundleManager.m Modularlize RCTBridgeModule.h 2/n - Fix rn-tester CI breakage on RCTBundleManager.h (#34515) 2022-08-27 07:08:30 -07:00
RCTBundleURLProvider.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTBundleURLProvider.mm Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTCallableJSModules.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTComponentEvent.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTComponentEvent.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTConstants.h 3/n Easy: Add MC to gate parsing unhandled JS errors in C++ 2022-10-18 15:09:23 -07:00
RCTConstants.m 3/n Easy: Add MC to gate parsing unhandled JS errors in C++ 2022-10-18 15:09:23 -07:00
RCTConvert.h feat(iOS): added lineBreakStrategy attribute to Text/TextInput (#31272) 2022-10-17 13:14:17 -07:00
RCTConvert.m Local filenames with colon should be parsed correctly (#35123) 2022-11-02 19:00:07 -07:00
RCTCxxConvert.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTCxxConvert.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTDefines.h Enable absolute bridgeless with REACT_NATIVE_FORCE_NEW_ARCHITECTURE flag on Wilde 2022-06-21 18:55:29 -07:00
RCTDisplayLink.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTDisplayLink.m Port RCTDisplayLink fix from React Native macOS (#35359) 2022-11-16 06:27:35 -08:00
RCTErrorCustomizer.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTErrorInfo.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTErrorInfo.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTEventDispatcher.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTEventDispatcherProtocol.h Make ScrollView sticky headers work w/o dispatching RCTEventEmitter.receiveEvent 2022-06-21 07:36:01 -07:00
RCTFrameUpdate.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTFrameUpdate.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTImageSource.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTImageSource.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTInitializing.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTInvalidating.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJSScriptLoaderModule.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJSStackFrame.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJSStackFrame.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJSThread.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJSThread.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJavaScriptExecutor.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTJavaScriptLoader.h Fix parseTypeFromHeader for Hermes bytecode 2022-03-15 05:58:52 -07:00
RCTJavaScriptLoader.mm Fix parseTypeFromHeader for Hermes bytecode 2022-03-15 05:58:52 -07:00
RCTKeyCommands.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTKeyCommands.m Remove usage of UIApplication.sharedApplication (#34787) 2022-09-26 07:13:52 -07:00
RCTLog.h Fix RCTLogError and RCTLogWarn to display RedBox or LogBox in Bridgeless 2022-02-14 19:42:07 -08:00
RCTLog.mm Fix RCTLogError and RCTLogWarn to display RedBox or LogBox in Bridgeless 2022-02-14 19:42:07 -08:00
RCTManagedPointer.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTManagedPointer.mm Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTMockDef.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTModuleData.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTModuleData.mm Modularlize RCTConstants.h - Move Bridge-only constants into a separate file 2022-09-08 19:56:22 -07:00
RCTModuleMethod.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTModuleMethod.mm Fix Make Unused Not Compiler Specific (#34357) 2022-08-08 03:50:58 -07:00
RCTModuleRegistry.m Modularlize RCTBridgeModule.h 3/n - Move RCTTurboModuleRegistry.h to its own file in ReactInternal target (#34514) 2022-09-09 15:10:14 -07:00
RCTMultipartDataTask.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTMultipartDataTask.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTMultipartStreamReader.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTMultipartStreamReader.m fixing more imports 2022-06-14 13:37:04 -07:00
RCTNullability.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTPLTag.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTParserUtils.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTParserUtils.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTPerformanceLogger.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTPerformanceLogger.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTPerformanceLoggerLabels.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTPerformanceLoggerLabels.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRedBoxSetEnabled.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRedBoxSetEnabled.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTReloadCommand.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTReloadCommand.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootContentView.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootContentView.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootView.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootView.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootViewDelegate.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTRootViewInternal.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTTouchEvent.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTTouchEvent.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTTouchHandler.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTTouchHandler.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTTurboModuleRegistry.h Modularlize RCTBridgeModule.h 3/n - Move RCTTurboModuleRegistry.h to its own file in ReactInternal target (#34514) 2022-09-09 15:10:14 -07:00
RCTURLRequestDelegate.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTURLRequestHandler.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTUtils.h prevent from publishing dimensions change event when app changes state (#34014) 2022-06-28 08:56:25 -07:00
RCTUtils.m prevent from publishing dimensions change event when app changes state (#34014) 2022-06-28 08:56:25 -07:00
RCTUtilsUIOverride.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTUtilsUIOverride.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTVersion.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTVersion.m chore: re-align version to be 1000.0.0 on main everywhere (#34817) 2022-10-04 08:36:21 -07:00
RCTViewRegistry.m 2/3 Make interop WebView component Bridgeless compatible, and make `uiManager addUIBlock` migration easier 2022-03-02 14:09:56 -08:00
RCTWeakProxy.h Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
RCTWeakProxy.m Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00