Summary:
The purpose of this change is to make TTRC markers work similarly for bridge loading and bridgeless loading so we could compare performance between them.
There are mainly four cases involved:
```REACT_BRIDGE_LOADING_START,
REACT_BRIDGE_LOADING_END,
REACT_BRIDGELESS_LOADING_START,
REACT_BRIDGELESS_LOADING_END
```
First 2 are for beginning/ending of bridge loading which includes creating fragment, loading JS bundle, running JS bundle and creating react instance. Last 2 are for similar purpose with bridgeless.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D26514499
fbshipit-source-id: 65d6f3cc7de9e07a7a3a802dd77138e74c23aa5b
Summary:
Change lifecycle of stopSurface in a subtle way: mark the surface as stopped in Java first, then in Cxx (currently it happens in Cxx, then Java).
This will cause us / allow us to ignore the final mounting instructions for the Surface, which are all irrelevant since they just have to do with View removal.
We can rely on GC and `unmountReactApplication` to do all of this for us, and save some CPU cycles on stopSurface.
Changelog: [Internal]
Reviewed By: shergin
Differential Revision: D26469741
fbshipit-source-id: a7f81d44c3cb2138f0ab31feb38852910410c638
Summary:
If there's a JS/native crash and the surface is stopped, the ReactRootView could be reused when the surface is restarted (or potentially to show the errors in a logbox; I'm don't think that's possible, but not 100% sure).
Regardless, now it will crash in those cases because of T83802049. There's no reason to do that, so just mark the ReactRootView as explicitly unused once the surface is stopped.
Changelog: [Internal]
Reviewed By: ShikaSD
Differential Revision: D26469742
fbshipit-source-id: ee79c094393a8ae8b5c53f04c14b90bc8e1a5a17
Summary:
Litho needs a new API which is called immediately before yoga begins layout calculations so that the InternalNode gets the opportunity to finalise itself; i.e. perform the last mutations and in effect avoid any more mutations to the hierarchy.
See D26373731 where the mutations from `Layout#collectResults` is moved back into the InternalNode.
Changelog: [Internal] Adds new API to YogaNodeJNIBase
Reviewed By: SidharthGuglani
Differential Revision: D26373730
fbshipit-source-id: 471346d3444986ada91e86c95f5f9fb98bcd2fa6
Summary:
Right now the FbReactInstanceDelegate provides a list of view managers to the instance during initialization, this means that we're basically eagerly loading all of the view manager classes.
In this change we use ViewManagerResolver instead.
Changelog:
[Android][Changed] - Move ViewManagerResolver into a seperate file
Reviewed By: mdvacca
Differential Revision: D26424214
fbshipit-source-id: 550ade31c256a56d6e32c463f112ea16dd55a218
Summary:
Now we use SurfaceHandler-based APIs to control surfaces in `Binding.cpp` on Android instead of using Scheduler-based APIs.
This is a transitional change; eventually, we will need to wrap C++ SurfaceHandler's into JNI wrappers. For now, it will allow to clean up the C++ part.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: JoshuaGross
Differential Revision: D26375641
fbshipit-source-id: 6f293e79cecf50de72294e90d5243ebb02d71236
Summary:
This bug doesn't reproduce anymore in v301+. MC has been enabled since december
https://www.internalfb.com/intern/logview/details/facebook_android_javascripterrors/419f8892e7b1a02f205810219ddfc299/trends?selected-logview-tab=All%20Traces&drillstate={%22start%22:%22Thu,%2028%20Jan%202021%2000:59:54%20-0800%22,%22end%22:%22Thu,%2011%20Feb%202021%2000:59:54%20-0800%22,%22constraints%22:[{%22col%22:%22mid%22,%22op%22:%22==%22,%22vals%22:[%22419f8892e7b1a02f205810219ddfc299%22]}],%22context%22:%22facebook_android_javascripterrors%22,%22metric%22:%22count%22}
changelog: [internal] internal
Reviewed By: ShikaSD
Differential Revision: D26398484
fbshipit-source-id: ca85ca211f1a38aa2691f150956a27c878d243bc
Summary:
TurboModuleManager used to be provided by a JSIModules package. In D26193053 (https://github.com/facebook/react-native/commit/13f100f788063be2a30109c3f7fee386cb766ec4), we moved TurboModuleManager creation off JSIModules. However, we didn't move the creation outside the JSIModules guard. So, when there were no JSIModules registered, we simply wouldn't create the TurboModuleManager. This diff fixes that mistake.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D26380674
fbshipit-source-id: 66939d11205b1d2eccd8c3b59ca4782e90645cd9
Summary:
Building ReactAndroid from source on Windows has recently hit the limitation of maximum path lengths.
At build time, during the `:ReactAndroid:buildReactNdkLib` task, the linker tries to access several of the intermediate binaries located deep in the tmp folder hierarchy, eg.
```
D:\r\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/react_render_components_progressbar/D_/r/ReactAndroid/__/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.o
```
**Suggested fix:** for modules such as `react_render_components_progressbar` and `react_render_components_picker`, rename them to `rrc_progressbar` etc.
**NOTE**: this assumes that the fix from https://github.com/facebook/react-native/issues/30535 is in place. This regression happened while https://github.com/facebook/react-native/issues/30535 has been pending checkin.
**Other mitigations I've tried:**
- setting [`LOCAL_SHORT_COMMANDS`](https://developer.android.com/ndk/guides/android_mk#local_short_commands) for the problematic modules or `APP_SHORT_COMMANDS` for the root project. Turns out those commands don't work on the NDK version RN requires, but even after manually applying a [patch ](https://android-review.googlesource.com/c/platform/ndk/+/1126440) to my local copy of the NDK, these flags had no effect.
- moving the repo directory higher in the file system tree, and using short directory names `D:\r\...` was not enough
- creating virtual drive letters for specific long paths with the [`sust`](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst#examples) command is not workable, since they depend on the source folder structure, and get partly generated by the build system, which I can't plug into
- just enabling long path support on Windows is not enough, since the compiler toolchain doesn't support them.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Fix source build on Windows machines vol. 2
Pull Request resolved: https://github.com/facebook/react-native/pull/30776
Test Plan:
Run `.\gradlew installArchives`
Before:

Now:

Differential Revision: D26194286
Pulled By: mdvacca
fbshipit-source-id: 778b5a0515148e2ace19e7902f74301831ebed94
Summary:
In addViewAt, we have this check. Add this same check to removeViewAt.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D26381475
fbshipit-source-id: 1050377aa4e528668446fd561ff09c61f27c700f
Summary:
Remove out of data TODO
changelog: [internal] internal
Reviewed By: PeteTheHeat
Differential Revision: D26144400
fbshipit-source-id: c5a97ce98cd7251e40adc15c16fceed4b9c76f81
Summary:
In this diff I'm adding debug assertions to verify that there are no overflows when muptiplying layout metrics by the pointScaleFactor
Ideally these should crash the app, but I'm trying to be conservative.
changelog: [internal] internal
Reviewed By: JoshuaGross
Differential Revision: D26297396
fbshipit-source-id: 068c60f4d89ea9cfd04a2e2174da2043ae150928
Summary:
We have no evidence of this happening on Android, but we are hitting a similar invariant on iOS. Adding this to Android for debugging purposes.
For now it's a SoftException to catch in debug and capture information; if we don't hit this prod at all, we'll elevate to a hard crash.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D26281585
fbshipit-source-id: 8ea9cf3ac555b13bf311f24c81bbbbc2845521d5
Summary:
This diff cleans listeners on the destruction of the ReactContext.
changelog: [inernal] internal
Reviewed By: JoshuaGross
Differential Revision: D26259929
fbshipit-source-id: 1843cabdac2fa3e67dcc890afd923b82472d8f66
Summary:
This diff clears the internal maps of NativeModuleRegistry during turn down of the bridge.
This is necessary for a proper cleanup of these modules.
changelog: [internal] internal
Reviewed By: ShikaSD
Differential Revision: D26239303
fbshipit-source-id: 6e98e5db60a4f54d02e99b03339b03c17ecc183d
Summary:
This diff unregisters the UIManagerModule from LifecycleEventListener during turn down of the bridge.
changelog: [internal] internal
Reviewed By: JoshuaGross
Differential Revision: D26239156
fbshipit-source-id: b230949228c6e580cca088c395b970a3cff94839
Summary:
This diff setup a global variable to control the staticViewConfig experiment before the bundle is loaded.
This global variable only has a meaning when RN uses a Bridge
changelog: [internal]
Reviewed By: JoshuaGross
Differential Revision: D26237670
fbshipit-source-id: 25ae63f36fba9c1e640ab2e70de88b71452ad8e6
Summary:
This diff refactor the initialization and deallocation of EventDispatcher in FabricUIManager when StaticViewConfigs are enabled.
The goal of this diff is to make sure that the EventDispatcher is deallocated correctly when using StaticViewConfigs
changelog: [internal]
Reviewed By: JoshuaGross
Differential Revision: D26166413
fbshipit-source-id: e5bdad7ba923edc677c6b73f3a4d1271941f41cc
Summary:
This caused a few apps to crash on launch.
Changelog: [Android][Fixed] - Crashes due to "Make NativeModules immediately initializable"
Reviewed By: olegbl
Differential Revision: D26278594
fbshipit-source-id: 969a3dc49a843366c4ae6ed19a9233d1e6f39b13
Summary:
Changelog:
[Internal][Yoga] - Added instance of checks in `YogaNodeJNIBase` class to prevent `ClassCastException`s. This was happening for some NT android tests - Mocked Yoga Node object was being passed in the `addChildAt` api
Stack Trace of exception
java.lang.ClassCastException: com.facebook.yoga.YogaNode$MockitoMock$1408896622 cannot be cast to com.facebook.yoga.YogaNodeJNIBase
at com.facebook.yoga.YogaNodeJNIBase.addChildAt(YogaNodeJNIBase.java:86)
at com.facebook.litho.DefaultInternalNode.addChildAt(DefaultInternalNode.java:220)
at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:377)
at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:360)
at com.facebook.litho.Column.resolve(Column.java:118)
at com.facebook.litho.Layout.create(Layout.java:172)
Reviewed By: Andrey-Mishanin
Differential Revision: D26114992
fbshipit-source-id: 774a689609e67f9244b81c6788b62cd61cd96d14
Summary:
The new IntBufferMountItem queueing actually enforces a global ordering of mutation types: CREATEs, then INSERT, then REMOVE, then UPDATE, then DELETE.
See comments for more details. In general this ordering is fine, but if a DELETE animation is in progress and (due to view unflattening) the same view is recreated, the CREATE will be executed and then the in-process DELETE (since conflicting animations get flushed).
To mitigate this, in Binding we detect this and simply remove DELETE operations queued when we detect that we want to CREATE the node. `DELETE...CREATE` is valid but `CREATE...DELETE` in a single frame is not, so this is safe.
This does complicate and add more assumptions to Binding than I would like, but it should unblock us for now.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D26271299
fbshipit-source-id: 9453fe17b8b541e484a047dc9637674dbdcc8e9a
Summary:
This is a Fabric-compliant implementation of `JSResponder` feature. To make it work e2e we also need to update FabricRenderer in React repository. But before we can do this, we need to ship the native changes.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: mdvacca
Differential Revision: D24630027
fbshipit-source-id: 70c30e1250b554d83862956b536714704093072f
Summary:
## Problem:
NativeModules can only be initialized after we mark them initializable on the NativeModules thread. This work is scheduled in ReactInstanceManager.setupReactContext(), after we schedule the execution of the JS bundle on the JavaScript thread in ReactInstanceManager.createReactContext():
https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java?commit=9b58f58b8eb12281567b8d24d6d000e868e61a1f&lines=1256-1257%2C1331%2C1334-1335%2C1333-1334
So, if the timings don't work out, the JavaScript thread could start executing the JS bundle before the NativeModule thread makes all NativeModules initializable. In this case, those NativeModule will just appear to be null in C++/JavaScript.
## Fix
This diff makes all NativeModules initializable immediately after their ModuleHolder is created. ModuleHolder.markInitializable() simply initializes initializes modules that were eagerly created.
Changelog: [Android][Fixed] - Make NativeModules immediately initializable
Reviewed By: JoshuaGross
Differential Revision: D26233372
fbshipit-source-id: a9223ff093da5b80781169be88e6ec9516c7a29b
Summary:
How does an application register a TurboModuleManagerDelegate with ReactInstanceManager?
1. Call ReactInstanceManagerBuilder.setReactPackageTurboModuleManagerDelegateBuilder(ReactPackageTurboModuleManagerDelegate.Builder)
2. Override ReactNativeHost.getReactPackageTurboModuleManagerDelegateBuilder()
Changelog: [Android][Added] - Introduce API to allow applications to register TurboModuleManagerDelegates with ReactInstanceManager
Reviewed By: mdvacca
Differential Revision: D26193055
fbshipit-source-id: bf82e63e6ab1c0c8f12bada92ac6852c992ec9cb
Summary:
Previously, owner(TurboModuleManager) used to depend on owner(ReactInstanceManager). Now, owner(ReactInstanceManager) depends on owner(TurboModuleManager).
**Rationale:** This allows ReactInstanceManager to create TurboModuleManager.
## Changes
We moved ReactPackageTurboModuleManagerDelegate to com.facebook.react.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D26163661
fbshipit-source-id: 3ebff16ef2aa77e20bb55500ed44c9214acb91dd
Summary:
Crash in debug, log a warning and continue in production.
Changelog: [Internal]
Differential Revision: D26133167
fbshipit-source-id: 60279363a3e90d592e7ddbde188c13cda89c28c6
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056823
fbshipit-source-id: 1d25afb2d4cfd7e539214d4592e361260f98fc56
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056815
fbshipit-source-id: d0e03a69f84de47385e064c74f0a79c52c61022d
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056813
fbshipit-source-id: e3b0132fac6335e83ff5b1992424edcb98703803
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056808
fbshipit-source-id: aa7ff9520a6a2470c642f06797757e1c0362abe9
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056802
fbshipit-source-id: 72eb498673aecce48145c785a4c2a48e0432059d
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056725
fbshipit-source-id: 771e5dd4cd1aeca3d2afd1a67ee58b9ac21eda79
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056723
fbshipit-source-id: c20183a4a1189f13b15a138968937080888a200b
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056720
fbshipit-source-id: f36a6caf4e748c915b66f66fd9b4cad6826ecacf
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056714
fbshipit-source-id: 215d8e44d7909f30f4a45f57e5d22a32a635d0ba
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056700
fbshipit-source-id: b3452125678ec8770dec9587106b8bf0f2490027
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056696
fbshipit-source-id: 50c0f01164e078b0ad32f66dda80c965f731f1fb
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056690
fbshipit-source-id: 208982ca5b53985bd8079c4b206a7eb4bb883494
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056685
fbshipit-source-id: a9abb451e62c9e378b0a5667fa4c5f82952bd02b
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056680
fbshipit-source-id: 2a57f15c01a585af9ddbe08cf6dd60922d4f64b3
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056676
fbshipit-source-id: 6baa5d9ba0ef15218ce02cbb51862f18d98b465c
Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.
Changelog: [Internal]
Reviewed By: PeteTheHeat, mdvacca
Differential Revision: D26056672
fbshipit-source-id: 2f3e4b9bbed339f15b22fe87e27d81af083fd481