react-native-macos/Libraries/ReactNative
Xin Chen 89ef5bd6f9 Add TraceUpdateOverlay to RN AppContainer
Summary:
This diff adds `TraceUpdateOverlay` native component to RN `AppContainer.js`. This will enable the overlay when the build is in DEV environment and the DevTools global hook exists. It also closed gap between the JS dev mode and native dev support flag, so that the native component will be available when used by JS.

## Update (2/13/2023)
Instead of the original approach where I put a default value to the devsupport manager flag, I did ui manager check from JS and make sure the native component exists before using it. This is cleaner.

## Problem
Since the `AppContainer` is being used by all RN apps, we need to make sure the native component is registered in UI Manager of the RN app when it's used. Currently, the native component lives in the `DebugCorePackage.java`, which is added to the RN app [when the `DevSupportManager` is used](https://fburl.com/code/muqmqbsa). However, there's no way to tell if an app is using dev support manager in JS, hence there are gaps when the JS code uses `TraceUpdateOverlay`, vs when the native code registered the native component. This issue caused test error in [ReactNativePerfTest](https://fburl.com/testinfra/j24wzh46) from the [previous diff](https://fburl.com/diff/bv9ckhm7), and it actually prevents Flipper from running this properly as shown in this video:

https://pxl.cl/2sqKf

The errors shown in Flipper indicates the RN surface from the plugin is also missing `TraceUpdateOverlay` in its UI Manager:

{F869168865}

## Solution
To fix this issue, we should find a way to expose if the app is using dev support manager in JS. Or we should set to use DevSupportManager whenever it's a dev build as claimed in JS. I will try to find some way to achieve either one of this. I am open to suggestions here for where I should add the native component to. Given that it's used in the AppContainer, and any app could be built in development mode, I don't want to make people to manually add this native component themselves.

## Alternatives
There are some other approaches that could mitigate the issue, but less ideal:

For the test issue
1) Add `setUseDeveloperSupport(true)` to [ReactNativeTestRule.java](https://fburl.com/code/7jaoamdp). That will make the related test pass by using the DevSupportPackages, which has the native component. However, it only fixes tests using that class.

2) Override the package for [ReactNativeTestRule.java](https://fburl.com/code/b4em32fa), or `addPackage` with more packages including the native component. Again this only fixes this test.

3) Add the native component to the [`MainReactPackage`](https://fburl.com/code/nlayho86), which is what I did here in this diff. This would fix more cases as this package is [recommended to be used](https://fburl.com/code/53eweuoh) for all RN app. However, it may not fix all the cases if the RN app didn't manually use it.

4) Add the native component in the [`CoreModulesPackage`](https://fburl.com/code/lfeklztl), which will make all RN apps work, but at the cost of increase package size when this feature is not needed. Or, we could argue that we want to have highlights on trace updates for production build as well?

Changelog:
[Internal] - Enable TraceUpdateOverlay to RN AppContainer

Reviewed By: rubennorte

Differential Revision: D43180893

fbshipit-source-id: a1530cc6e2a9d8c905bdfe5d622d85c4712266f8
2023-02-14 22:32:55 -08:00
..
AppContainer.js Add TraceUpdateOverlay to RN AppContainer 2023-02-14 22:32:55 -08:00
AppRegistry.d.ts Fix Errors with TypeScript Tests 2022-12-15 19:17:58 -08:00
AppRegistry.js Fix Errors with TypeScript Tests 2022-12-15 19:17:58 -08:00
BridgelessUIManager.js RN: Sort Imports via ESLint 2022-09-30 14:28:48 -07:00
DisplayMode.js Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
FabricUIManager.js Make UIManager.measure* compatible with Fabric 2022-12-13 11:43:05 -08:00
HeadlessJsTaskError.js Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
I18nManager.d.ts Place TypeScript Declarations Alongside Source Files 2022-09-26 12:09:45 -07:00
I18nManager.js Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
NativeHeadlessJsTaskSupport.js RN: Sort Imports via ESLint 2022-09-30 14:28:48 -07:00
NativeI18nManager.js RN: Sort Imports via ESLint 2022-09-30 14:28:48 -07:00
NativeUIManager.js Fix flow types in NativeUIManager 2022-12-07 08:37:35 -08:00
PaperUIManager.js Implicit instantiation codemod 2022-10-19 10:25:09 -07:00
ReactFabricInternals.js Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
ReactNativeFeatureFlags.js react-native | remove unused internal feature flag 2023-01-23 10:37:36 -08:00
ReactNativeRuntimeDiagnostics.js iOS: Introduced ReactNativeRuntimeDiagnostics for various runtime validation mechanism 2022-05-03 18:11:35 -07:00
RendererImplementation.js RN: Sort Imports via ESLint 2022-09-30 14:28:48 -07:00
RendererProxy.d.ts Place TypeScript Declarations Alongside Source Files 2022-09-26 12:09:45 -07:00
RendererProxy.js Extract use of renderer to its own module 2022-09-08 11:12:06 -07:00
RootTag.d.ts Add type for RootTagContext 2022-12-15 10:04:11 -08:00
RootTag.js Remove misleading comment about RootTag type not being opaque 2022-11-02 07:44:34 -07:00
UIManager.d.ts Fixup TS Organization (#35169) 2022-11-02 14:58:37 -07:00
UIManager.js Make UIManager.measure* compatible with Fabric 2022-12-13 11:43:05 -08:00
UIManagerProperties.js Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
getCachedComponentWithDebugName.js Remove $TEMPORARY$object types 2022-11-10 04:48:13 -08:00
getNativeComponentAttributes.js ESM processColor 2023-01-03 18:09:06 -08:00
renderApplication.js hook up offscreen api to runApplication 2022-10-07 18:13:04 -07:00
requireNativeComponent.d.ts Fixup TS Organization (#35169) 2022-11-02 14:58:37 -07:00
requireNativeComponent.js ESM requireNativeComponent 2023-01-03 18:09:06 -08:00