Граф коммитов

4874 Коммитов

Автор SHA1 Сообщение Дата
Joshua Gross 014c6f9636 Make sure that NativeAnimatedModule is subscribed to LifecycleEventListener events, and unsubscribes in onCatalystInstanceDestroy
Summary:
If modules are *not* eagerly init'd and expect lifecycle events, make sure (1) onHostResume is called immediately it it's currently active and (2) that listeners are removed in onCatalystInstanceDestroy.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26859158

fbshipit-source-id: 4966d3c49d194c4cb4063edf3a035f6077b76cd9
2021-03-05 18:42:36 -08:00
Joshua Gross aa305b34e3 Make sure that DialogModule is subscribed to LifecycleEventListener events
Summary:
I'm not sure what broke this, but in some cases, DialogModule doesn't get subscribed to LifecycleEventListener events.

This seems to fix it.

Changelog: [Internal]

Reviewed By: mdvacca, RSNara

Differential Revision: D26856016

fbshipit-source-id: 868baf102b85b202180adcbb8bb181dfe603188f
2021-03-05 18:42:36 -08:00
Samuel Susla a206f4fc2e Back out "Don't retain State in StateWrapperImpl"
Summary:
Changelog: [internal]

Original commit changeset: 0703c6dccc62

Reviewed By: yungsters

Differential Revision: D26849056

fbshipit-source-id: 2c6fca3ef06ac4868979d0a93c04c0eabdd56eb0
2021-03-05 10:45:25 -08:00
Lulu Wu 772fbf0a7d Fix venice test failure
Summary:
Changelog:
[Android][Changed] - Remove duplicate dependency

Reviewed By: mdvacca

Differential Revision: D26835371

fbshipit-source-id: 2a32b80bc0bb834f92473d003b940f8ffd3495fb
2021-03-05 05:16:49 -08:00
Lulu Wu 2b708560fc Fix ReactEditText crash
Summary:
Found this crash when rendering ReactEditText under Venice, from comment it's supposed to be called only in Paper, so I adde a Venice check to avoid calling this method.

{F446844248}

Changelog:
[Android][Changed] - Add a new check to avoid calling this method

Reviewed By: mdvacca

Differential Revision: D26781457

fbshipit-source-id: f4c2e890156a37e35aa153c736b50924254e67bc
2021-03-05 04:24:11 -08:00
Joshua Gross a65cd683ae Align View creation flow between Fabric and non-Fabric
Summary:
Ship responsibility for most View creation logic to ViewManager, where it already largely lies, and simplify code in Fabric and non-Fabric mounting layers.

Notably, some of this work was *already* being duplicated so we can expect an extremely tiny perf gain here.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26742711

fbshipit-source-id: 4213766d4cd366bc69cd47d4654f7b269bb9e7f4
2021-03-04 22:22:34 -08:00
Gaurav Gupta ea3495399b Android - pass initial props to ViewManager createView in non-Fabric (#31053)
Summary:
https://github.com/facebook/react-native/issues/31051
When trying to create custom viewmanagers,  we don't have props, I have a use case where I want to create views on the basis of provided react prop from react native.
## 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] [Changed] - pass initial props to ViewManager createViewInstance method in non-Fabric

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

Test Plan:
Tested Manually.

(Facebook - see D26719538, which should land first)

Reviewed By: mdvacca

Differential Revision: D26719510

Pulled By: JoshuaGross

fbshipit-source-id: ced78aa919e6b433e22ddb7c9eccc3e3e91950e9
2021-03-04 22:22:34 -08:00
Samuel Susla e6931caca4 Don't retain State in StateWrapperImpl
Summary:
Changelog: [internal]

StateWrapperImpl shouldn't retain State strongly because cleanup of `StateWrapperImpl` is triggered from Java and isn't guaranteed to take happen before runtime is destroyed.

This should resolve crash where `StateWrapperImpl`'s destruction causes a `~Pointer` to be called after runtime is destroyed.

Chain of ownership that will be broken by storing State weakly inside `StateWrapperImpl`.
`StateWrapperImpl -> ParagraphState -> TextLayourManager's cache -> AttributedString -> ShadowView -> EventEmitter -> EventTarget -> Pointer`

{F451105831}

Reviewed By: JoshuaGross

Differential Revision: D26815275

fbshipit-source-id: 0703c6dccc62c1d152923b786a83273fa8a03694
2021-03-04 13:14:39 -08:00
Joshua Gross da8ed6b625 Disable setRemoveClippedSubviews in ReactHorizontalScrollContainerView.java in RTL mode
Summary:
setRemoveClippedSubviews in  ReactHorizontalScrollContainerView.java in RTL mode is overzealous and unexpectedly clips out views in a way that is not desirable.

It seems like what is actually happening is that the computed rect for the view is "0,0" and so contents are assumed to always be outside of this rect.

For now I've disabled this feature. We can investigate as a followup.

Changelog: [Android][Changed] Clipping subviews has been temporarily disabled in HorizontalScrollView in RTL mode. Minor/negligible perf impact.

Reviewed By: sammy-SC

Differential Revision: D26808937

fbshipit-source-id: 85af9c3fb542db9ca3aae03413a475695cd53391
2021-03-04 10:36:17 -08:00
David Vacca fca0442bc8 Extract ComponentNameRegistry out of Fabric modules
Summary:
This diff extracts ComponentNameRegistry out of Fabric modules

This is necessary to avoid depending on Fabric and regressing APK size for other RN apps (e.g. IG)

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26765328

fbshipit-source-id: 0a22c4279146f5243473c74a84e78fad7f08f956
2021-03-03 14:16:03 -08:00
David Vacca 056f1fd2cd Integrate ComponentNameResolver into ReactInstanceManager
Summary:
This diff integrates the ComponentNameResolver class into ReactInstanceManager

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26716900

fbshipit-source-id: e3a5f44485f659a32bf6094eee7985daf634f50f
2021-03-03 14:16:02 -08:00
David Vacca 2f5f6c40c2 Introduce ComponentNameResolverManager and ComponentNameResolver classes
Summary:
This diff introduces the ComponentNameResolverManager and ComponentNameResolver classes. The purpose of these classes is to integrate NativeComponentRegistryBinding into RN Android

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26716899

fbshipit-source-id: c62fb5c38ddce5325890d2506a6fb17d26043175
2021-03-03 14:16:02 -08:00
Samuel Susla 630ac87591 Report initial offset of horizontal scroll view to Fabric
Summary:
Changelog: [internal]

Calling `scrollTo` does not report offset change to Fabric core and measure infra can't compute correct values. This results in unresponsive buttons if horizontal scroll view on Android has initial offset set to anything besides default value 0.

Reviewed By: JoshuaGross

Differential Revision: D26778991

fbshipit-source-id: 5cad5cb9926c7923f6efcd56cb4e15c3b958c245
2021-03-03 13:05:22 -08:00
Héctor Ramos 6ccd0cdebb Bump Android compileSdkVersion and targetSdkVersion to 30 (#31078)
Summary:
## Summary

Bump Android compileSdkVersion and targetSdkVersion to 30

## Changelog

[Android][Changed] Bump Android compileSdkVersion and targetSdkVersion from 29 to 30

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

Test Plan: Circle CI and Sandcastle

Reviewed By: mdvacca

Differential Revision: D26765188

Pulled By: hramos

fbshipit-source-id: a971641cea4860df58ce6e9b0f14405bfc4e0979
2021-03-02 16:40:48 -08:00
Lulu Wu be7f057bac Try reduce flackiness of VeniceTest
Summary:
Simplify addLifecycleEventListener for the flaky test because we just want to test that listener is working.

Changelog:
[Android][Changed] - Add a spare implementation of addLifecycleEventListener for test purpose.

Reviewed By: PeteTheHeat

Differential Revision: D26749256

fbshipit-source-id: 5af216e6bfa37a15eb189aa24a3df35a7a7112de
2021-03-02 16:32:44 -08:00
Andrei Shikov cbe7c445f7 Add logging to ReactModalHostView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D26752344

fbshipit-source-id: 0cc7987e553896144fadcc8ede8f37f74b4b5bc5
2021-03-02 13:52:32 -08:00
David Vacca caa5abc819 Remove unnecessary dependency from react buck module
Summary:
This diff removes an unnecessary dependency from react buck module

This was causing a regression in apk size in IG

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26755329

fbshipit-source-id: bc45d9717bb0343cd26ed2ccbaa016b55f56b9bf
2021-03-02 11:07:05 -08:00
Lulu Wu dec1b6ba15 Test setting layout params to wrap_content for fix text layout bug
Summary:
Changelog:
[Android][Fixed] -  Fix layout bug in ReactTextView.

Reviewed By: mdvacca

Differential Revision: D26752392

fbshipit-source-id: eeb9c16a4165b4d9329534981925621ae51a7dcb
2021-03-02 10:43:55 -08:00
Joshua Gross 5772c4947d Fix failing CircleCI test for touch event timestamp
Summary:
Timestamp is computed differently now and uses system millis as the basis for a monotonic clock. Updating this fixes tests.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D26739611

fbshipit-source-id: 4908da68e1c126ea2b0772aaf408d892798549aa
2021-03-01 18:13:02 -08:00
David Vacca 71ccc61802 Refactor ReactInstanceManager.getViewManagerNames
Summary:
This diff refactors the ReactInstanceManager.getViewManagerNames method to cache viewManager names

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26716898

fbshipit-source-id: 93985fe248e7b364081e04dd2b2c6d9b46cb8727
2021-03-01 17:55:16 -08:00
David Vacca 05f687fa88 Extract getViewportOffset out RootView
Summary:
This diff moves the method getViewportOffset out of ReactRootView. This is necessary to avoid Fabric to depend from paper.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26716901

fbshipit-source-id: cec67c24860a776fb361d7cda08d3142e1214c8c
2021-03-01 17:55:16 -08:00
Joshua Gross 21a434ceec Fix crash associated with setJSResponderHandler
Summary:
In Fabric we're seeing setJSResponderHandler called during teardown of a surface, which causes a crash because the SurfaceId is no longer available at that point.

Guard against setJSResponderHandler being called on a dead surface.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26734786

fbshipit-source-id: 838d682ee0dd1d4de49993fa479dc2097cf33521
2021-03-01 15:48:38 -08:00
Joshua Gross 69feed518d Send UNIX timestamp along with JS touch events, instead of systemUptime
Summary:
We want to be able to instrument touch processing delays in JS, which does not have access to systemUptime; therefore we want a UNIX timestamp, which JS has access to and can compare to the touch time.

It only matters that there is relative consistency between multiple touch events in JS, which is still the case; so this should have no impact on product code.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D26705429

fbshipit-source-id: 0f2db726048fcab9a30e830970d7d8a8d2eae446
2021-02-28 15:18:51 -08:00
David Vacca 5194183037 Revert D26470604: Bump Android compileSdkVersion and targetSdkVersion to 30
Differential Revision:
D26470604 (55c8833817)

Original commit changeset: ffd490f6e547

fbshipit-source-id: 71926781696ab7b7fb2b109198a8d02c3286b05f
2021-02-26 21:44:45 -08:00
David Vacca 55c8833817 Bump Android compileSdkVersion and targetSdkVersion to 30
Summary:
Bump Android compileSdkVersion and targetSdkVersion to 30
changelog: [Android][Changed] Bump Android compileSdkVersion and targetSdkVersion from 29 to 30

Reviewed By: ShikaSD

Differential Revision: D26470604

fbshipit-source-id: ffd490f6e547d16f9832ec46cf7bd2c0689aba96
2021-02-26 21:12:54 -08:00
Joshua Gross f8261bbe51 Don't pass LayoutDirection from Cxx to IntBufferBatchMountItem<Replace this line with a title. Use 1 line only, 67 chars or less>
Summary:
I thought we'd need LayoutDirection on the platform at some point, but it turns out we never use it, and don't seem to need it since components just query via `I18nUtil` one time,
and it's expected that apps restart if language changes and we need to switch between LTR and RTL. So, it seems like we'll not have any need for this on the platform at any point.

And we can save a byte per layout instruction now. Huzzah!

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26660908

fbshipit-source-id: 54c7d132f5fa260a93fc7f09f7cf63059d52ed1f
2021-02-25 10:09:32 -08:00
Joshua Gross 4e243ca7a3 Fix RTL scrolling
Summary:
We recently fixed RTL scrolling in Fabric on iOS: D26608231 (e5921f7f38)

Turns out, the mechanism for RTL scrolling on Android is completely different. It requires that content be wrapped in a "directional content view", which is `View` in LTR and `AndroidHorizontalScrollContentView` in RTL, backed by `ReactHorizontalScrollContainerView.java`.

iOS doesn't require that and just uses View and some custom logic in ScrollView itself.

In the future it would be great to align the platforms, but for now, for backwards-compat with non-Fabric and so we don't have to tear apart ScrollView.js, we codegen the AndroidHorizontalScrollContentView so it exists in C++, register the component, and stop mapping it to View explicitly in C++.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26659686

fbshipit-source-id: 3b9c646dbdb7fe9527d24d42bdc6acb1aca00945
2021-02-25 10:09:32 -08:00
Andrei Shikov ac704690dc Update Android.mk to ensure the rn-tester compiles in debug mode
Summary:
Changelog: [Internal]

Adds react_debug dependency in Android.mk where it was missing

Reviewed By: mdvacca

Differential Revision: D26617400

fbshipit-source-id: 5ac799269b106eadd881d30490ac34bd2134a9b7
2021-02-24 12:29:00 -08:00
Lulu Wu 86321a35c0 Fix text in ReactTextView being vertically displayed
Summary:
## Issue:
Sometimes ReactTextView are vertically displayed as one column with bridgeless.

## Root cause:
After debugging, I found out this is caused by a workaround in 2016 to fix a crash caused by mLayout occasionally being non-null and triggers relayout during setText.

https://github.com/facebook/react-native/pull/7011

## Fix
Revert previous hack, if the crash happens again I'll try to fix it.

Changelog:
[Android][Fixed] -  Fix text in ReactTextView sometimes being vertically displayed

Reviewed By: mdvacca

Differential Revision: D26581756

fbshipit-source-id: a373d84dc1ab3d787bda7ec82f2d0865a354cf60
2021-02-24 12:19:07 -08:00
Lulu Wu abf079abb8 Make TTRC markers consistent between Bridge and Bridgeless
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
2021-02-22 12:42:44 -08:00
generatedunixname89002005325676 c498c055a2 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D26480949

fbshipit-source-id: 5a8f706daaea276865e6eb8602cc3b50c484bf6f
2021-02-17 04:24:39 -08:00
Joshua Gross e810291790 Subtle stopSurface lifecycle change
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
2021-02-16 14:48:28 -08:00
Joshua Gross 3357341347 When surface is stopped, reset View ID of ReactRootView
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
2021-02-16 14:48:28 -08:00
Aditya Sharat 6a9bb45e09 Adds InternalNode#freeze() API
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
2021-02-16 10:20:35 -08:00
Lulu Wu eaedb10755 Switch to using ViewManagerResolver for view managers
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
2021-02-16 10:12:24 -08:00
Valentin Shergin 4324ca8122 Fabric: Using SurfaceHandler API in Binding.cpp on Android
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
2021-02-15 23:19:55 -08:00
David Vacca d71a0be6fa Release fix for race condition on startSurface
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
2021-02-15 21:02:05 -08:00
David Vacca 2ecdb69b74 Revert D26445966: Bump Android compileSdkVersion and targetSdkVersion to 30
Differential Revision:
D26445966 (c7efd5b369)

Original commit changeset: 54c7b2dfff88

fbshipit-source-id: 91bf5564ed01f77d0837a090c941d65ad8d376a5
2021-02-15 20:47:34 -08:00
David Vacca c7efd5b369 Bump Android compileSdkVersion and targetSdkVersion to 30
Summary:
Bump Android compileSdkVersion and targetSdkVersion to 30

changelog: [Android][Changed] Bump Android compileSdkVersion and targetSdkVersion from 29 to 30

Reviewed By: JoshuaGross

Differential Revision: D26445966

fbshipit-source-id: 54c7b2dfff88cf2405fd66b3440a03f11de2304f
2021-02-15 20:24:06 -08:00
Ramanpreet Nara c76070412f Move TurboModuleManager init outside JSIModules guard
Summary:
TurboModuleManager used to be provided by a JSIModules package. In D26193053 (13f100f788), 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
2021-02-11 13:02:53 -08:00
Igor Klemenski c37d49492b Work around max path length during source build of RN Android (#30776)
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:
![image](https://user-images.githubusercontent.com/12816515/105435667-a1e15d00-5c12-11eb-9fcd-d0c278aaf477.png)
Now:
![image](https://user-images.githubusercontent.com/12816515/105435741-c2a9b280-5c12-11eb-88d5-a69ae56bbf50.png)

Differential Revision: D26194286

Pulled By: mdvacca

fbshipit-source-id: 778b5a0515148e2ace19e7902f74301831ebed94
2021-02-11 12:32:33 -08:00
Lulu Wu 9d1e8897e0 Load Logbox module for venice
Summary:
1, Add logbox module to BridgelessReactPackage for loading by TurboModleManager
2, Implement createRootView for creating venice's logbox
3, Move setting reactcontext and devsupportmanager for FbReactFragment into onReactContextInitialized()
4, Fix some nullability warnings

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26370269

fbshipit-source-id: 016f1dab8387d3766b2fd24d6e88f14538f443ea
2021-02-10 19:47:44 -08:00
Joshua Gross 81810f4c62 Add invariant to SurfaceMountingManager: when removing a view, the parent View must be a ViewGroup
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
2021-02-10 16:03:10 -08:00
Andrei Shikov 5ca832b4aa Fix Android tests for touch events
Summary:
Updates Android tests to pass the tests [failing on CircleCI](https://app.circleci.com/pipelines/github/facebook/react-native/8047/workflows/50c356d0-f9a4-4909-b4e7-cad3b4bb6c57/jobs/188224/steps).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26368501

fbshipit-source-id: 61d4fdbc22cec2e397e365e415a08dbbc01cef09
2021-02-10 09:22:48 -08:00
David Vacca ff3c1307ff Remove out of date TODO
Summary:
Remove out of data TODO

changelog: [internal] internal

Reviewed By: PeteTheHeat

Differential Revision: D26144400

fbshipit-source-id: c5a97ce98cd7251e40adc15c16fceed4b9c76f81
2021-02-09 23:19:28 -08:00
David Vacca 8b72941a0a Add debug logs to check for overflow
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
2021-02-09 23:19:27 -08:00
Joshua Gross e0f1101e7e Add invariant to SurfaceMountingManager: Views must not have parents when they are inserted
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
2021-02-09 22:43:43 -08:00
David Vacca 41f93679d0 Update C++ flags in Fabric Android
Summary:
Update C++ flags in Fabric Android

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26297398

fbshipit-source-id: d4603ee848abee98977ac9e21505547d9a867e21
2021-02-08 11:37:35 -08:00
David Vacca d79212120b Clean listeners during destroy of ReactContext
Summary:
This diff cleans listeners on the destruction of the ReactContext.

changelog: [inernal] internal

Reviewed By: JoshuaGross

Differential Revision: D26259929

fbshipit-source-id: 1843cabdac2fa3e67dcc890afd923b82472d8f66
2021-02-06 23:05:28 -08:00
David Vacca 98165a23f6 Clear internal maps of NativeModuleRegistry during turn down of the bridge
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
2021-02-06 23:05:28 -08:00
David Vacca 1e8c3e4ad8 Unregister UIManagerModule from LifecycleEventListener
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
2021-02-06 23:05:28 -08:00
David Vacca d7191f80e8 Configure MC before the JS Bundle is loaded
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
2021-02-06 23:05:27 -08:00
David Vacca 33c390a7da Deallocate EventDispatcher in FabricUIManager when StaticViewConfigs are enabled
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
2021-02-06 23:05:27 -08:00
Albert Sun b474be6cc8 Back out "Make NativeModules immediately initializable"
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
2021-02-05 10:16:25 -08:00
Andrei Shikov 6061b79283 Clear enable_android_surface_clear_after_crash_report and disable_view_operations_after_catalyst_destroy
Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26238985

fbshipit-source-id: 5aa1172e73dd6623e2af1acd909e1548e37e8f30
2021-02-05 07:01:10 -08:00
Sidharth Guglani 96bc33a1d7 instance of checks for YogaNodeJniBase
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
2021-02-05 03:42:50 -08:00
Joshua Gross 5ae8e84dc7 Fix IntBufferMountItem optimization + LayoutAnimation bug
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
2021-02-05 00:57:40 -08:00
Valentin Shergin fc24bb4af0 Fabric: Support for `setIsJSResponder`, all the native changes
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
2021-02-04 13:16:29 -08:00
Ramanpreet Nara 2bf866e401 Make NativeModules immediately initializable
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
2021-02-03 18:42:43 -08:00
Lulu Wu 5d8e75937d Rename "ReactInstanceManagerDevHelper" to "ReactInstanceDevHelper" so it doesn't look like Bridge-specific
Summary: Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26199747

fbshipit-source-id: c6fe7d07e15940d08cc726c6631dd387910b40a0
2021-02-03 14:39:40 -08:00
Ramanpreet Nara 77ba2ad2f2 Delete NewJavaNativeModule
Summary:
`xbgs NewJavaNativeModule` shows this isn't used anywhere.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26230382

fbshipit-source-id: daf9501115b1c094d22128144b5ebc29ae39c429
2021-02-03 13:50:05 -08:00
Ramanpreet Nara 13f100f788 Move TurboModuleManager creation into ReactInstanceManager
Summary:
See title.

Changelog: [Android][Changed] - Move TurboModuleManager creation into ReactInstanceManager

Reviewed By: mdvacca

Differential Revision: D26193053

fbshipit-source-id: fe92636f0cb3dca65fa919ac5df8931b693f76c5
2021-02-02 20:50:31 -08:00
Ramanpreet Nara eb7e89e286 Register TurboModuleManagerDelegate builders without JSIModules
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
2021-02-02 20:50:30 -08:00
Ramanpreet Nara 2a1b5193f7 Allow ReactInstanceManager to create TurboModuleManager
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
2021-02-02 20:50:30 -08:00
Joshua Gross b0ec350568 Detect startSurface race-conditions and warn silently
Summary:
Crash in debug, log a warning and continue in production.

Changelog: [Internal]

Differential Revision: D26133167

fbshipit-source-id: 60279363a3e90d592e7ddbde188c13cda89c28c6
2021-01-28 16:22:06 -08:00
Joshua Gross aad423d59e Support RCTModernEventEmitter+RCTEventEmitter in ReactSwitchEvent Event class
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
2021-01-28 14:07:31 -08:00
Joshua Gross 1dcb4cfe7f Support RCTModernEventEmitter+RCTEventEmitter in RefreshEvent Event class
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
2021-01-28 14:07:31 -08:00
Joshua Gross a8d7c2cd62 Support RCTModernEventEmitter+RCTEventEmitter in PickerItemSelectEvent Event class
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
2021-01-28 14:07:31 -08:00
Joshua Gross f6af7b2a58 Support RCTModernEventEmitter+RCTEventEmitter in ReactSlidingCompleteEvent Event class
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
2021-01-28 14:07:31 -08:00
Joshua Gross 6e62100297 Support RCTModernEventEmitter+RCTEventEmitter in ReactContentSizeChangedEvent Event class
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
2021-01-28 14:07:30 -08:00
Joshua Gross e253a6940d Support RCTModernEventEmitter+RCTEventEmitter in TouchEvent Event class
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
2021-01-28 14:07:30 -08:00
Joshua Gross db5bc2f766 Support RCTModernEventEmitter+RCTEventEmitter in ShowEvent Event class
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
2021-01-28 14:07:30 -08:00
Joshua Gross 1575e7ffe3 Support RCTModernEventEmitter+RCTEventEmitter in ScrollEvent Event class
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
2021-01-28 14:07:30 -08:00
Joshua Gross 583d6229c6 Support RCTModernEventEmitter+RCTEventEmitter in RequestCloseEvent Event class
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
2021-01-28 14:07:29 -08:00
Joshua Gross 42274b0ba8 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputSubmitEditingEvent Event class
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
2021-01-28 14:07:29 -08:00
Joshua Gross ae979a14d6 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputSelectionEvent Event class
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
2021-01-28 14:07:29 -08:00
Joshua Gross 2b0d69976f Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputKeyPressEvent Event class
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
2021-01-28 14:07:28 -08:00
Joshua Gross 8e2b45fe79 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputFocusEvent Event class
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
2021-01-28 14:07:28 -08:00
Joshua Gross a5a94ce786 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputEvent Event class
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
2021-01-28 14:07:28 -08:00
Joshua Gross 346b1f1df4 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputEndEditingEvent Event class
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
2021-01-28 14:07:28 -08:00
Joshua Gross a01cea10f6 Support RCTModernEventEmitter+RCTEventEmitter in ReactTextInputBlurEvent Event class
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
2021-01-28 14:07:27 -08:00
Joshua Gross 8569e9933f Support RCTModernEventEmitter+RCTEventEmitter in ReactTextChangedEvent Event class
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: D26055276

fbshipit-source-id: f38f9e94ab313fb842d1e3037ab667cd460f1043
2021-01-28 14:07:27 -08:00
Joshua Gross aa9c8abd1a Support RCTModernEventEmitter+RCTEventEmitter in ViewGroupClickEvent Event class
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: mdvacca

Differential Revision: D26054855

fbshipit-source-id: 9592d854962d53f64d836b8361256cac5c4325df
2021-01-28 14:07:27 -08:00
Joshua Gross 70073664ab Support RCTModernEventEmitter+RCTEventEmitter in OnLayoutEvent Event class
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: mdvacca

Differential Revision: D26054856

fbshipit-source-id: 228cc08a624e793aff4caf36e1df8285f3b3519d
2021-01-28 14:07:26 -08:00
Joshua Gross 5d2f77553c Support RCTModernEventEmitter+RCTEventEmitter in DrawerClosedEvent, DrawerOpenedEvent, DrawerSlideEvent, DrawerStateChangedEvent Event classes
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: mdvacca

Differential Revision: D26043861

fbshipit-source-id: 37757508c835cbd1181f0e0e774abc62fdbfee2b
2021-01-28 14:07:26 -08:00
Joshua Gross 46df827c7e Support RCTModernEventEmitter+RCTEventEmitter in ReactAccessibilityDelegate.Anonymous Event class
Summary:
Support RCTModernEventEmitter +RCTEventEmitter in an Event class. This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26043393

fbshipit-source-id: b126658d818a18b7ffb2794de8e59a49c0e3d258
2021-01-28 14:07:26 -08:00
Joshua Gross 72d0ddc16f Refactor Event to encourage and ease migration to `RCTModernEventEmitter` support
Summary:
The `Event` interface has been improved such that:

1. `getEventData` is now a default method on Event that returns null
2. `dispatch` has a default implementation that relies on getEventName() and getEventData()
3. `dispatchModern` can detect if surfaceId and event data are present; if not, it falls back to dispatch

This will dramatically ease future migrations: at some point in the (distant) future, we can simply delete RCTEventEmitter and
all use-cases will be supported by the current `Event` class without needing to introduce a 3rd transitional interface; and 99%
of all Event classes can be simplified, delet their `dispatch` implementation and need no further work.

At their core, all Events are simply: (1) a name, (2) data, (3) a target (surfaceId and tag). The interface now reflects that but still
allows for flexibility of the data and names being generated on-demand if necessary; but for the vast majority of Event classes, code
will be dramatically simplified.

I also migrate a single Event class, ContentSizeChangeEvent, to use this new method of dispatch.

Changelog: [Android][Changed] Added convenience methods to simplify native Event classes and ease migrations

Reviewed By: mdvacca

Differential Revision: D26043325

fbshipit-source-id: bc308105f7f6e654d45fd156dbf4a2bcbc45819c
2021-01-28 14:07:26 -08:00
Joshua Gross de8aa2c6b9 Try to call setSurfaceId and setId earlier on ReactRootViews
Summary:
We assume that startSurface is always called off the UI thread; see if we can synchronously call setId and setSurfaceId, and in general, call setSurfaceId sooner.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26053050

fbshipit-source-id: a657584502bb0018e9591fe610eac0fc9fab2ca9
2021-01-28 14:07:25 -08:00
Valentin Shergin a8fbe7269f Fabric: Setting mountingOverrideDelegate for MountingCoordinator directly
Summary:
Before this change, `mountingOverrideDelegate` was proxied via `Scheduler::startSurface` and `ShadowTree::ShadowTree` constructor down to `MountingCordinator`. Now we set it on the `MountingCoordinator` directly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26049076

fbshipit-source-id: 7f1ecf2c8b6f264a7e59d19881464fe529c53d30
2021-01-26 14:58:22 -08:00
Joshua Gross 4f3b174120 Guard against setId being called on the ReactRootView outside of RN core
Summary:
The RootView being managed by Fabric should have an id of View.NO_ID when it is "handed over" to RN. This is true for Fabric and non-Fabric
and setting a custom id on the ReactRootView has never been supported. I'm temporarily (?) adding an additional check earlier and into ReactRootView to hopefully
catch any of these issues early.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26077509

fbshipit-source-id: 59e1ec080504e50698acc654c29120f039238a96
2021-01-26 10:51:28 -08:00
Joshua Gross 335d9d88e1 Fix `sendAccessibilityEvent` in Fabric
Summary:
This logic got reversed.

Changelog: [internal]

Differential Revision: D26070642

fbshipit-source-id: 4c68e4af25d4907746a09e7a3afe175d88a25f95
2021-01-26 00:50:56 -08:00
Joshua Gross 5792c32e36 Fix race between stopSurface and PreAllocateMountItem
Summary:
There is a race between PreAllocateMountItems executing and killing off stale SurfaceMountingManagers.

For now I'm simplifying the "eviction" mechanism. We just keep up to 15 SurfaceMountingManagers around and start evicting them from the least-recently-referenced one.

Hopefully this logic can be simplified in the future.

I'm also sneaking in a small perf optimization for PreAllocateMountItem: don't queue them if the associated surface is already stopped, because chewing through a bunch of dead PreAllocateMountItems on the UI thread can be expensive.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26059378

fbshipit-source-id: 3b2503d7d8e5f045ae741d0d4a5880d1b37758d2
2021-01-25 20:30:38 -08:00
Joshua Gross 47cd7edf14 Fix race between initial updateRootLayoutSpecs and startSurface
Summary:
In some cases, onMeasure/onLayout are called on the RootView before `startSurface` in Fabric has been able to set surfaceId on the RootView.

With the new SurfaceMountingManager, this causes a crash because we need a valid surfaceId to perform an operation. Before the SurfaceMountingManager refactor, a surfaceId of 0 would be passed to `mBinding.setConstraints` in the FabricUIManager, and setConstraints in C++ noops if there's an invalid surfaceId.

For now, FabricUIManager will also fail silently if the surfaceId is invalid when updateRootLayoutSpecs is called, just to be conservative and to be consistent with previous behavior. This will be upgraded to a hard-crash in the future.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26051266

fbshipit-source-id: ca2d80f899cdba9b3962af68546bd83b77be0680
2021-01-25 12:53:08 -08:00
generatedunixname89002005325674 d368d11a0f Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D26043994

fbshipit-source-id: 7e49a747e07fb7dcb01c92bba7cb88d9e3266f69
2021-01-25 04:19:55 -08:00
David Vacca 164e133a98 Remove usage of FabricUIManager Module related to NativeDriverAnimations
Summary:
This diff removes references to FabricUIManager from UIManagerModule, these callsited were originally used for NativeAnimatedDriver, but they are not used anymore

changelog: [internal] internal

Reviewed By: JoshuaGross, shergin

Differential Revision: D26035388

fbshipit-source-id: d4825af17f6948d922c42670f2c7b02498c12039
2021-01-25 03:05:33 -08:00
Joshua Gross 5d62b4a19a Rename Event.dispatchV2 -> dispatchModern
Summary:
See title. dispatchV2 was just introduced yesterday, so nothing relies on it yet / it's safe to rename (there are no released versions of RN with `dispatchV2`).

And... dispatchModern is a better name.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26039008

fbshipit-source-id: 009ae721b8caef23a389c33b51f6f8952a6a73da
2021-01-24 22:13:11 -08:00
Joshua Gross 595b569ead Fix EventEmitter crash for events that are sent to a stopped surface
Summary:
In SurfaceMountingManager/MountingManager/FabricUIManager infra, we try to blackhole events that are sent to a stopped surface. In this case I just forgot to add a null check. Add here to protect against events sent to stopped surfaces - for example, if a TextInput is focused when the surface is stopped, a "blur" event will be sent and will crash here otherwise. Now it blackholes silently, as expected.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26031260

fbshipit-source-id: 9936466ca2d00267efaf7fa594c9bcd59f7aad2a
2021-01-22 19:32:15 -08:00
Joshua Gross ee10932e26 Support RCTModernEventEmitter in for ReactTextInput* Event classes
Summary:
Support RCTEventEmitterV2 in ReactTextInput*Event classes for optimal Fabric perf. Backwards-compatible with non-Fabric renderer.

Changelog: [Changed][Android] Old native ReactTextInput*Event creation APIs have changed, and will be removed in the (distant) future. The old methods will work for now with minor perf implications for Fabric.

Reviewed By: mdvacca

Differential Revision: D26031261

fbshipit-source-id: 7c972ecfd1e395104c4639995bb5ecc5f7c6baae
2021-01-22 19:32:15 -08:00
Joshua Gross ddabf3fd56 Support RCTModernEventEmitter in ImageLoadEvent
Summary:
Support RCTEventEmitterV2 in ImageLoadEvent for optimal Fabric perf. Backwards-compatible with non-Fabric renderer.

Changelog: [Changed][Android] Old native ImageLoadEvent creation APIs have changed, and will be removed in the (distant) future. The old methods will work for now with minor perf implications for Fabric.

Reviewed By: mdvacca

Differential Revision: D26029773

fbshipit-source-id: c8e00e06a2f9d6682367f9099bdf7f5fc12890e0
2021-01-22 19:32:15 -08:00
Joshua Gross 62f0dee235 Migrate ScrollEvent to RCTModernEventEmitter
Summary:
Motivation: perf, simplicity, adhering to new SurfaceMountingManager APIs available to us. Backwards-compatible with events sent through old system or Fabric, to Fabric or non-Fabric Views.

Changelog: [Changed][Android] Old Native method to create ScrollEvent has been deprecated and will be removed at some point in the (distant) future

Reviewed By: mdvacca

Differential Revision: D26027105

fbshipit-source-id: b9dba5b56c2bfed3b8fc4488c54b271b85ab5fa0
2021-01-22 19:32:14 -08:00
Joshua Gross 708038d80e Refactor EventEmitters to take optional surfaceId, migrate TouchEvent
Summary:
Refactor EventEmitters to take an optional SurfaceId that Fabric will use, and non-Fabric will not.

Migrating touches is a good proof-of-concept for how this could be used generally, and as it turns out, TouchEvent's API is more flexible than most other event APIs (because it uses a dictionary to pass data around, so we can just stuff SurfaceId into it - not efficient, but flexible).

All new APIs are backwards-compatible and designed to work with old-style events, with Fabric and non-Fabric. Native Views that migrate to the new API will be backwards-compatible and get an efficiency boost in Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26025135

fbshipit-source-id: 5b418951e9d0a3882f2d67398f2aaadac8a3a556
2021-01-22 19:32:14 -08:00
Joshua Gross 2fbbdbb2ce Create V2 EventEmitter (ModernEventEmitter) interface that surfaceId can be passed into
Summary:
Create V2 EventEmitter that surfaceId can be passed into, with a backwards-compat layer, and some debug-only logging to help assist with migration.

Changelog: [Changed][Android] RCTEventEmitter has been deprecated in favor of RCTModernEventEmitter for optimal Fabric support; RCTEventEmitter will continue to work in Fabric, but there are minor perf implications.

Reviewed By: mdvacca

Differential Revision: D26027104

fbshipit-source-id: 784ca092bbc88d19c82f6c42537c34460d96de86
2021-01-22 19:32:14 -08:00
Joshua Gross 8357b39908 Rename String surfaceID to surfaceName/moduleName, add int surfaceId to ThemedReactContext
Summary:
There's a field called `surfaceID` in a couple of classes that isn't the same as the integer `surfaceId` in Fabric.

For consistency, I've deprecated a couple of them, or renamed when appropriate.

In addition, now we're passing the actual integer surfaceId into the ThemedReactContext. This means that every single View created in Fabric gets annotated with the surfaceId it's in. Currently this isn't used, but the idea is that now each View has a mapping back to its surface, which could be used to simplify / optimize operations with SurfaceMountingManager. In particular, we might be able to use this in the future to optimize animations and/or event emitters.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26021571

fbshipit-source-id: b7db7de123db07fa928a6f815be86bdbb030e62c
2021-01-22 19:32:14 -08:00
Joshua Gross e7783ff9ad Rename addRootView -> startSurface in Fabric, and deprecate existing `addRootView` sites
Summary:
Deprecate addRootView, use startSurface consistently in Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26021147

fbshipit-source-id: e23b9294695609f766e382917ae1874fc8a1b27d
2021-01-22 19:32:13 -08:00
David Vacca 505f9fc749 Add logging to analyze Bug in BottomSheetRootViewGroup
Summary:
This diff adds logs and soft errors to analyze task T83470429

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26032513

fbshipit-source-id: e6ee3f8a6ac942e794439396e1a9f7d6157d20a5
2021-01-22 18:44:36 -08:00
Ron Edelstein aa65be8ef8 Make autoglob a required parameter of robolectric tests
Reviewed By: strulovich

Differential Revision: D26013246

fbshipit-source-id: fd7f014cc55c8640b96032d843aa2ce81ac9bfa8
2021-01-22 16:35:08 -08:00
Joshua Gross 29eb632f1c Refactor MountingManager into MountingManager + SurfaceMountingManager
Summary:
This refactors MountingManager into a minimal API that shims into a more fully-featured SurfaceMountingManager. The SurfaceMountingManager keeps track of surface start/stop, surface ID, and surface Context.

This solves a number of issues around (1) race conditions around StopSurface/StartSurface, (2) memory management of Views, (3)

Concrete improvements:

1. Simpler to reason about race conditions around StopSurface/StartSurface.
2. 1:1 relationship between SurfaceId and all Views/tags.
3. When surface is stopped, all descendent Views can be GC'd immediately.
4. Fixed separation of concerns and leaky abstractions: surfaceId/rootTag and Surface Context are now stored and manipulated *only* in SurfaceMountingManager.
5. Simpler StopSurface flow: we simply remove references to all Views, and the Fragment (outside of the scope of this code) removes the RootView. This will trigger GC and we do ~0 work. Previously, we ran a REMOVE and DELETE instruction and kept track of each View in a HashMap. Now we can simply delete the map and move on.

The caveat: NativeAnimated (or other native modules that go through UIManager). APIs like `updateProps` currently uses only the ReactTag and does not store SurfaceId. This is a good argument for moving away from ReactTag, at least in its current incarnation, but: for now this requires that you do a lookup of a ReactTag across N surfaces (worst-case) to determine which Surface a ReactTag is in.

So, to summarize, the "con" of this approach is that now `getSurfaceManagerForViewEnforced` could be slower. It is used in:
* NativeAnimatedModule calls `updateProps` through UIManager
* FabricEventEmitter calls `receiveEvent` on FabricUIManager directly
* On audit, I could find zero native callsites to `sendAccessibilityEvent` through UIManager

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26000781

fbshipit-source-id: 386ae40c4333f8c584e05818c404868dbee6ce73
2021-01-21 23:47:34 -08:00
Joshua Gross a715c5eba7 Addressing leaked Views in Fabric MountingManager
Summary:
MountingManager keeps a map of tags to Views, and attempts to clean it up by (1) deleting tags when they're explicitly deleted, (2) recursively deleting all Views when the View hierarchy is torn down.

However, there appear to be.... substantial gaps here. In tests, when navigating between screen X -> screen Y -> back to X (triggering a StopSurface), each "StopSurface" resulted in 200-600 Views being leaked (!).

What is causing these leaks? Well, for one, the "dropView" mechanism isn't perfect, so it might be missed Views. Second, Views don't always guarantee that `reactTag == getId()`, so that could result in leaks. Third, View preallocation on Android complicates things: Views can be preallocated and then never even inserted into the View hierarchy, so DELETE mutations could never be issued. Fourth, StopSurface is also complicated on Android (largely because of View preallocatioAndroid (largely because of View preallocation).

So, I introduce a new mechanism: keep a list of all tags for a surface, and remove all tags for a surface when the surface is torn down. This should be fool-proof: it handles preallocation and normal creation; it can handle deletes; and we're guaranteed that tags cannot be added after a surface is stopped.

Is this overly complicating things? Well, hopefully we can simplify all of this in the longterm. But until we get rid of View Preallocation, it seems like we need this mechanism - and View Preallocation might be around for a while, or forever.

Other thoughts: it's possible that using other data-structures could be more efficient, but I'm guessing the perf implications here are marginal (compared to the insane amount of memory leaks we're fixing). It could also simplify things to have a SurfaceMountingManager interface that implies all actions happen on a specific surface, including teardown.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25985409

fbshipit-source-id: f55b533770b1630c6c2a9b7a694d953aa3324428
2021-01-20 17:46:30 -08:00
Joshua Gross 9b1f3b16b0 Back out hacks to fix T83141606
Summary:
Original commit changeset: 3ed8e78e31b0

Backing-out D25938851 (69b3016171) and D25935785 (bdea479a1f). Based on analysis documented in T83141606, I believe this issue should be fixed in JS.

Additionally, this crash actually has nothing to do with (un)flattening or the differ; it is a side-effect of stale ShadowNodes being cloned, which I believe is either UB or a contract violation. Either way, it should probably be fixed either in JS, or in node cloning. So this isn't the right solution for this issue and should be reverted.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25949569

fbshipit-source-id: 8cf1094a767da98fff4430da60d223412e029545
2021-01-19 00:29:41 -08:00
David Vacca 65975dd28d Change type of SwipeRefreshLayoutManager.size prop from Int to String
Summary:
This diff changes the type of the SwipeRefreshLayoutManager.size prop from Int to String in Fabric.

The current implementation of this prop allows JS developers to use "int" type when fabric is enables and "int or string" types when using Fabric is disabled.
Since long term we want to only support "string" type for this prop, I'm changing the type of the prop to be String.

After my diff Fabric will start supporting only "string" types, non fabric screens will keep supporting "int or string" values.

**Will this break production?**
No, because there are no usages of RefreshControl.Size prop in fbsource

**What about if someone start using this prop next week?**
IMO It's very unlikely because of the nature of this prop, I will be monitoring next week and if there's an usage it will be detected by flow when trying to land D25933457.

Changelog: [Android][Changed] - RefreshControl.size prop changed its type to string, the valid values are: 'default' and 'large'

Reviewed By: JoshuaGross

Differential Revision: D25933458

fbshipit-source-id: 55067d7405b063f1e8d9bb7a5fd7731f5f168960
2021-01-17 02:57:02 -08:00
Joshua Gross bdea479a1f Fix Android crash: mark re-created nodes in Differ
Summary:
Android has some optimizations around view allocation and pre-allocation that, in the case of View Unflattening, can cause "Create" mutations to be skipped.

To make sure that doesn't happen, we add a flag to ShadowViewMutation (in the core) that any platform can consume, that indicates if the mutation is a "recreation" mutation.

It is still a bit unclear why this is needed, in the sense that I would expect props revision to increment if a view is unflattened. However, there is at least one documented reproduction where that is *not* the case. So for now, we'll have a hack pending further investigation.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25935785

fbshipit-source-id: 6fb4f0a6dedba0fe46ba3cd558ac1daa70f671f5
2021-01-16 11:05:54 -08:00
Joshua Gross a0403c0626 Fix MountItem logging
Summary:
MountItem logging was broken in D25841763 (4076293aa1), by adding a field that wasn't logged.

Fixed here.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25934390

fbshipit-source-id: 2db4a809b150ad33ddf886db1db6585889bd7013
2021-01-15 18:53:58 -08:00
generatedunixname89002005325676 aebccd3f92 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D25921551

fbshipit-source-id: df0445864751c18eaa240deff6a142dd791d32ff
2021-01-15 04:16:22 -08:00
generatedunixname89002005325674 0936e7fa9e Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D25921598

fbshipit-source-id: f82ab6a1a891dd6262bfa516f869850415ce3228
2021-01-15 04:12:28 -08:00
Ramanpreet Nara a156ee9b73 Delete JS TurboModule Codegen Gating
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25915171

fbshipit-source-id: b59e21f834a7172055e180eddb9bf15737a6cf0f
2021-01-14 19:14:23 -08:00
Ramanpreet Nara 8ed6659907 Stop forwarding TurboModule schema to TurboModule HostObjects
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25915170

fbshipit-source-id: 2b390428c1f582e55cf3ffe8e691f069bf2fd295
2021-01-14 19:14:23 -08:00
David Vacca 34351fd0b1 Refactor initialization of Fabric to avoid loading UIManagerModule
Summary:
This diff refactors the intialization of Fabric in order to avoid loading UIManagerModule as part of the creation of FabricJSIModuleProvider.
One caveat is that now we are not taking into consideration the flag mLazyViewManagersEnabled
master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java177

if (mLazyViewManagersEnabled) {
As a side effect of this diff view managers will be initialized twice if the user has fabric and paper enabled
This diff was originally backed out in D25739854 (4984c1e525) because it produced a couple of bugs:
https://fb.workplace.com/groups/rn.support/permalink/4917641074951135/
https://fb.workplace.com/groups/rn.support/permalink/4918163014898941/
These bugs are fixed by D25667987 (2e63147109).

This diff was reverted a couple of times because of the change in the registration of eventDispatcher. That's why I'm gating that behavior change as part of the "StaticViewConfig" QE.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D25858934

fbshipit-source-id: a632799ccac728d4efca44ee685519713b4a7cbb
2021-01-14 17:27:50 -08:00
Dulmandakh 280f524b49 bump fresco to 2.3.0 (#30061)
Summary:
Bump Fresco to 2.3.0.

## Changelog

[Android] [Changed] - Bump Fresco to 2.3.0

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

Reviewed By: mdvacca

Differential Revision: D24074218

Pulled By: fkgozali

fbshipit-source-id: 9f42a24927e560da2ac64857ac8cd6b4f0211849
2021-01-14 15:50:59 -08:00
Joshua Gross 6fd684150f NativeAnimatedModule: make exceptions thrown into JS thread more verbose
Summary:
These methods can all throw exceptions that get caught and reported by JS. The logviews aren't currently very helpful; hopefully adding additional information will make batch debugging a little easier.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25870788

fbshipit-source-id: a1cab225b11a3d2868f098d4575e475ee4064e65
2021-01-12 12:13:30 -08:00
David Vacca 5348a98207 Migrate lookup of EventDispatcher to not depend on UIManagerModule
Summary:
This diff migrates all the lookups of EventDispatcher to not depend on UIManagerModule anymore.
This refactor is necessary because:
- Users running in Fabric / Venice should not load on the UIManagerModule class
- D25858934 will introduce a change that will break all of these callsites

In the migration I'm relying on the method UIManagerHelper.getEventDispatcherFromReactTag() that returns the correct EventDispatcher for a reactTag.

I'm planning to land this change early in the week (to catch potential errors in alpha / beta versions)

As a followup we need to deprecate and prevent developers to continue using getNativeModule(UIManagerModule.class) moving forward. That will be part of another diff

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D25858933

fbshipit-source-id: e26c99759307517b5bef483274fe0e0d71bb4c6c
2021-01-11 15:43:58 -08:00
Riley Dulin 291cc95cc9 Add a fatal error handler for Hermes
Summary:
Hermes has a way to set up a callback that is invoked when a fatal error
such as Out of Memory occurs. It is a static API that should be called at
most once, so it uses `std::call_once` to achieve that.

The fatal error handler is simple, it just uses glog to log an error message
to logcat, then aborts (using `__android_log_assert`).
The reason is typically very helpful for understanding why `hermes_fatal` was called.

Changelog:
[Android][Internal] - Print a logcat message when Hermes has a fatal error

Reviewed By: mhorowitz

Differential Revision: D25792805

fbshipit-source-id: 45de70d71e9bd8eaa880526d8835b4e32aab8fe3
2021-01-11 11:33:24 -08:00
David Vacca 5803c72982 Log SoftError when there is not EventDispatcher associated to UIManager
Summary:
This diff logs a SoftError when there is not EventDispatcher associated to UIManager

The app will crash in Debug mode, this will not affect production users
changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25859546

fbshipit-source-id: 8045bcd67f613ea6286f30fe6f3c66113c700b0b
2021-01-10 19:46:40 -08:00
David Vacca 4076293aa1 Fix changes of View visibilities
Summary:
The purpose of this diff is to ensure that visibility changes are handled correctly when the value of "display" for a View changes from 'flex' to 'none'.

RNTester is nesting several Views with different kind of visibilities. When the user tap on an item there's a state update that changes the visibility styles for some of these views. Fabric does not reflect the right changes of visibility on the screen.

changelog: internal

Reviewed By: shergin

Differential Revision: D25841763

fbshipit-source-id: 769b97afb72939d346a4c6f2669ff938b35596bc
2021-01-10 19:46:40 -08:00
Valentin Shergin e37e56b042 Back out "Add onFocus and onBlur to Pressable."
Summary:
I suspect it's causing T82781515.

Changelog:
[Category][Type] - Backout of "[react-native][PR] Add onFocus and onBlur to Pressable."

Reviewed By: p-sun

Differential Revision: D25864414

fbshipit-source-id: efba9136edba97d5bd2a0de15f9ddae7dfd24e51
2021-01-10 13:56:27 -08:00
Andres Suarez 0f4f917663 Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25861683

fbshipit-source-id: 616afca13ae64c76421053ce49286035e0687e36
2021-01-09 22:11:00 -08:00
Joshua Gross 055d029bc0 Android implementation of sendAccessibilityEvent
Summary:
This is the Android native implementation of sendAccessibilityEvent for Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25852418

fbshipit-source-id: cb51e667a7f673da6b9c9e539770225b02bdc902
2021-01-08 18:10:59 -08:00
Igor Klemenski cab4da7288 Add onFocus and onBlur to Pressable. (#30405)
Summary:
Starting to upstream keyboard-related features from React Native Windows - this is the Android implementation.
Exposing onFocus and onBlur callbacks on Pressable; they're already declared for View in ViewPropTypes.js, which Pressable wraps.

Registering event listeners in ReactViewManager to listen for native focus events.
## 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] [Added] - Add onFocus/onBlur for Pressable on Android.

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

Test Plan:
Tested on v63-stable, since building master on Windows is now broken. Screenshots from RNTester running on the emulator:
![image](https://user-images.githubusercontent.com/12816515/99320373-59777e80-2820-11eb-91a8-704fff4aa13d.png)
![image](https://user-images.githubusercontent.com/12816515/99320412-6f853f00-2820-11eb-98f2-f9cd29e8aa0d.png)

Reviewed By: mdvacca

Differential Revision: D25444566

Pulled By: appden

fbshipit-source-id: ce0efd3e3b199a508df0ba1ce484b4de17471432
2021-01-08 13:59:48 -08:00
Lukas Müller 6bfd89d277 Update OkHttp to 3.14.9 to improve security (#30609)
Summary:
Okhttp 3.12.X allows Connections using TLS 1.0 and TLS1.1.
TLS 1.0 and TLS 1.1 are no longer secure.
Google, Mozilla, Microsoft, and Apple announced that their browsers will require TLSv1.2 or better starting in early 2020.

https://square.github.io/okhttp/changelog_3x/#version-310
https://github.com/facebook/react-native/wiki/Changelog

Starting from 3.13.0 TLSv1 and TLSv1.1 are no longer enabled by default.
3.13.0 requires JAVA 8 and Android SDK 21 (which was blocking the Upgrade in the Past).

## Changelog

[Android] [Changed] - Update Okhttp to version 3.14.19

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

Test Plan:
Current tests should pass.
Connections using TLS 1.0 and TLS 1.1 should not be possible.

Reviewed By: mdvacca

Differential Revision: D25843511

Pulled By: fkgozali

fbshipit-source-id: f0b648c8037f945130c6f9983404ee7f75b178cb
2021-01-07 20:30:26 -08:00
David Vacca 2027d6236a Revert D25746024: Refactor initialization of Fabric to avoid loading UIManagerModule
Differential Revision:
D25746024 (d3a3ce857e)

Original commit changeset: 3d12d29973a1

fbshipit-source-id: 67a7f045e5c6b1bc0201ad58b569fc870c3a89f9
2021-01-06 21:37:24 -08:00
David Vacca d3a3ce857e Refactor initialization of Fabric to avoid loading UIManagerModule
Summary:
This diff refactors the intialization of Fabric in order to avoid loading UIManagerModule as part of the creation of FabricJSIModuleProvider.

One caveat is that now we are not taking into consideration the flag mLazyViewManagersEnabled
```
master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java177

if (mLazyViewManagersEnabled) {
```
As a side effect of this diff view managers will be initialized twice if the user has fabric and paper enabled

This diff was originally backed out in D25739854 (4984c1e525) because it produced a couple of bugs:
- https://fb.workplace.com/groups/rn.support/permalink/4917641074951135/
- https://fb.workplace.com/groups/rn.support/permalink/4918163014898941/

These bugs are fixed by D25667987 (2e63147109).

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D25746024

fbshipit-source-id: 3d12d29973a12b1edfea75f4dd954790f835e9bd
2021-01-06 00:49:50 -08:00
David Vacca 2e63147109 Refactor creation of views in Fabric Android
Summary:
This diff refactors the createViewInstance method in order to ensure that viewID is set before props are updated in the view.
This is necessary because there are components that deliver events at the same time their props are set. This means that some components might not have their viewId set correctly when events are delivered.
Since viewId is used to determine if a view belongs to Fabric or Paper, there are cases when the events are not delivered to the right renderer

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25667987

fbshipit-source-id: 4acfa8f80d66e9e59514354481957d7d3b571248
2021-01-05 23:28:28 -08:00
Jayme Deffenbaugh 381fb395ad Expose the testID to black-box testing frameworks on Android (#29610)
Summary:
There has been a long-standing issue where black-box testing frameworks like Appium and Xamarin UITest have not been able to access the `testID` view prop for Android (see https://github.com/facebook/react-native/issues/7135). A natural place for this to be exposed is via a view's `resource-id`. The `resource-id` is what I have used when working on UIAutomator-based tests for native Android apps and is a non-localized, development-only identifier. As mentioned in the linked ticket, you can dynamically set the resource-id using the view's AccessibilityNodeInfo. This change simply checks to see if a testID is provided for a view and then exposes it through the view's accessibility node delegate.

## 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] - Fixes https://github.com/facebook/react-native/issues/7135,  https://github.com/facebook/react-native/issues/9942, and https://github.com/facebook/react-native/issues/16137. Display the `testID` as the `resource-id` for black-box testing frameworks

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

Test Plan:
I used the `uiautomatorviewer` tool to verify that the resource-id is populated with the `testID` of a few different views of the RNTester app.
<img width="912" alt="Screen Shot 2020-08-10 at 3 38 27 PM" src="https://user-images.githubusercontent.com/875498/89838534-55044100-db20-11ea-9be2-ba507a81f6fb.png">
<img width="1096" alt="Screen Shot 2020-08-10 at 3 40 41 PM" src="https://user-images.githubusercontent.com/875498/89838542-5897c800-db20-11ea-9895-462c6fea1130.png">

Reviewed By: JoshuaGross

Differential Revision: D25799550

Pulled By: fkgozali

fbshipit-source-id: e64ff1b90fb66b427fce7af533aa94792cfbcad3
2021-01-05 23:22:57 -08:00
David Vacca 08eacf8acd Ship optimization of ReadableNativeMaps
Summary:
Ship optimization of ReadableNativeMaps - see D25361169 (503a6f4463)

QE showed neutral metrics

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25776019

fbshipit-source-id: 7fd32087bf2ca81236fe0aebe082be01330de2fa
2021-01-05 11:49:44 -08:00
Joshua Gross 0db56f1888 Ship IntBufferBatchMountItem experiment
Summary:
This experiment has been successfully running for several weeks and show small but statsig perf improvements. Delete the old code and ship this 100% in code to simplify Fabric code.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25775668

fbshipit-source-id: d2b41dfe691775e52b1e89c2fb6790a6500e560e
2021-01-05 10:44:44 -08:00
Joshua Gross a2164f429a Ship lockfree mountitems
Summary:
Ship lockfree mountitems experiment.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25775521

fbshipit-source-id: 15811b15a9dc7d463a6d46d7fefd0d433ba86280
2021-01-05 10:44:44 -08:00
Agastya Darma 5b34c98fa2 WIP: Add an explicit NDK version to RNTester and ReactAndroid (#29987)
Summary:
When I try to run RNTester with Gradle the RNTester Required me to use **NDK 20.0.5594570**. I can't seem to find an explicit NDK version anywhere in ReactAndroid and RNTester. This PR Aims to add an explicit NDK version to RNTester and ReactAndroid.

![Screenshot from 2020-09-19 21-13-17](https://user-images.githubusercontent.com/8868908/93669563-444fcf00-fabf-11ea-8822-93264c5bb736.png)

## Changelog
[Android] [Added] - Add an explicit NDK version to RNTester and ReactAndroid.

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

Test Plan: Build manually from RNTester

Reviewed By: fkgozali

Differential Revision: D23911371

Pulled By: ShikaSD

fbshipit-source-id: 2f297c73890c0eb0bfec0e2ba7ec5755b4d84243
2021-01-04 09:15:08 -08:00
David Vacca b9ad5a706d Micro-optimization in ReadableNativeMaps
Summary:
This is just a micro-optimization in ReadableNativeMaps. It wont change much in perf..

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25733948

fbshipit-source-id: b01109acdf5b2eb532801469ef5cb845010c6ed0
2021-01-01 15:45:06 -08:00
Kacie Bawiec 4984c1e525 Back out "Refactor initialization of Fabric to avoid loading UIManagerModule"
Summary:
This diff D25468183 (c776f09e5f) is causing TetraFormTextInput's onChange not to fire.

See https://fb.workplace.com/groups/rn.support/permalink/4918163014898941/

I confirmed this was the bad diff via mobile bisect.

changelog: [internal] internal

Reviewed By: rickhanlonii, mdvacca, nadiia

Differential Revision: D25739854

fbshipit-source-id: efdfb1e464dd5d990d5c9ea291dde9895736817a
2020-12-30 19:34:22 -08:00
Joshua Gross ee5a27b759 Remove temporary Litho-interop feature flag
Summary:
Remove temporary Litho-interop feature flag.

Changelog: [Internal]

Differential Revision: D25445364

fbshipit-source-id: c0fa3e6e5e55c0997e4a5ddd6c1cc5695878c7d2
2020-12-29 15:54:45 -08:00
Joshua Gross 249b341a41 Don't redraw images when props don't change
Summary:
Right now we assume in the Image component that any prop changes requires a redraw of the image, even if the props set are identical.

Noop prop updates can be caused in Fabric by LayoutAnimations. This may go away in the future, but only when we have a new animations system.

I don't think most other components need to be concerned with this, and many other components already guard against unnecessary redraws. Since the image "flashes"
when it is loaded, unlike most other native components, this issue is more noticeable for images.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25727482

fbshipit-source-id: 75ffa456bddc1208900733140ce4ff19f7e2c11e
2020-12-29 15:54:44 -08:00
David Vacca b3defc8872 Refactor preComputeConstantsForViewManager to avoid loading UIManagerModule in Fabric
Summary:
This method refactors the preComputeConstantsForViewManager to avoid loading UIManagerModule when using  Fabric + Static View configs

changelog: [internal] internal

Reviewed By: shergin

Differential Revision: D25468182

fbshipit-source-id: e95b0e7d013e832792fb77fc0b6e5705d7f04868
2020-12-29 15:09:05 -08:00
David Vacca c776f09e5f Refactor initialization of Fabric to avoid loading UIManagerModule
Summary:
This diff refactors the intialization of Fabric in order to avoid loading UIManagerModule as part of the creation of FabricJSIModuleProvider.

One caveat is that now we are not taking into consideration the flag mLazyViewManagersEnabled

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java?commit=4fb6c5ae79bb8e78e852a811128f03cf6fbed9aa&lines=177

As a side effect of this diff view managers will be initialized twice if the user has fabric and paper enabled

changelog: [internal] internal

Reviewed By: shergin

Differential Revision: D25468183

fbshipit-source-id: 78d8069007c5a98f9a6825eaa0c174603c8b9b4f
2020-12-29 10:42:18 -08:00
David Vacca 72ddd69222 Remove deleted parameter from javadoc
Summary:
ez javadoc

changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D25468185

fbshipit-source-id: bba614df552b3c8431e77aaa51a29e08fae5ea7f
2020-12-29 01:00:11 -08:00
Ramanpreet Nara fb34fba01c Use native_module_spec_name to name codegen targets
Summary:
## Description
Suppose this was the codegen declaration before:

```
rn_library(
  name = "FooModule",
  native_module_spec_name = "FBReactNativeSpec",
  codegen_modules = True,
  # ...
)
```

Previously, this would generate the following BUCK targets:
- generated_objcpp_modules-FooModuleApple
- generated_java_modules-FooModuleAndroid
- generated_java_modules-FooModule-jniAndroid

## Changes
We will now generate:
- FBReactNativeSpecApple
- FBReactNativeSpecAndroid
- FBReactNativeSpec-jniAndroid

This matches the naming scheme of the old codegen.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25680224

fbshipit-source-id: 617ac18fd915f3277f6bd98072d147f20fb193e5
2020-12-24 00:50:01 -08:00
Valentin Shergin f379b1e583 Fabric: Shipping `updateStateWithAutorepeat` as the only way to update a state
Summary:
This replaces the internal core implementation of `setState` with the new `updateStateWithAutorepeat` which is now the only option.
In short, `updateStateWithAutorepeat` works as `setState` with the following features:
* The state update might be performed several times until it succeeds.
* The callback is being called on every retry with actual previous data provided (can be different on every call).
* In case of a static value is provided (simple case, not lambda, the only case on Android for now), the same *new*/provided value will be used for all state updates. In this case, the state update cannot fail.
* If a callback is provided, the update operation can be canceled via returning `nullptr` from the callback.

This diff removes all mentions of the previous state update approach from the core; some other leftovers will be removed separatly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25695600

fbshipit-source-id: 14b3d4bad7ee69e024a9b0b9fc018f7d58bf060c
2020-12-23 21:49:44 -08:00
Kevin Gozali 86ffbd0a27 RNTester Android: always compile Fabric files
Summary:
This commit makes both `:ReactAndroid` and `:rn-tester:android:app` always compile in Fabric codegen outputs. However, one may still enable/disable Fabric at runtime by setting `USE_FABRIC` env var (set to 1 or 0, default is 0).

Note that we can't register custom components specific to the app, yet, so only the components in react-native github repo is covered by this commit.

RNTester doesn't enable Fabric by default yet due to known UI bugs that haven't been addressed yet.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25674311

fbshipit-source-id: 8db660c959319250ebc683c84076677cf6489e94
2020-12-21 22:43:36 -08:00
Kevin Gozali 8db181abfc RNTester Android: generate Fabric JNI files during build time
Summary:
Generate Fabric C++ files along side TM spec files for RNTester. The combined .so then has both TM and Fabric files.

This commit also removed the checked-in JNI files.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25674313

fbshipit-source-id: 8091d5a00f42849a74cab50e8d24f4010d500e5b
2020-12-21 22:43:35 -08:00
Kevin Gozali 1ce53e86ed Codegen Android: rename "ReactAndroidSpec" to "rncore" for parity with Fabric
Summary:
The TM specs and Fabric files should be combined into the same .so. For short term parity with Fabric components and iOS, let's rename ReactAndroidSpec (default name based on project path) to "rncore".

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25674312

fbshipit-source-id: 3d71aa0cc945affecb06dcfc15e807dd48c76468
2020-12-21 22:43:35 -08:00
Kevin Gozali 15a3a01082 Android: use Fabric component codegen output instead of checked in files
Summary:
For core components, we can start using the codegen output during build time instead of the checked in files in: https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/react/viewmanagers

Note: Some files seemed to be handwritten, so this only removed those that use codegen.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D25453157

fbshipit-source-id: f7eabddfd3fd668bef0c4aef3fddcb38c8b046a0
2020-12-21 22:43:35 -08:00
David Vacca f7c209cd54 Fix racecondition in registration of event listeners
Summary:
This diff fixes a racecondition in registration of event listeners.

mPostEventDispatchListeners is accessed from different threads, most of the times this variable is used to executed the listeners. It is only written during initialization and turn down of the renderer.

changelog: [internal]

Reviewed By: PeteTheHeat

Differential Revision: D25667988

fbshipit-source-id: 1bf95f5193d55a737bad9403206cc3320185b8cb
2020-12-21 15:08:18 -08:00
Ron Edelstein 8b4e2ac8e5 Explicitly set autoglob (long tail)
Reviewed By: fbanurag, strulovich

Differential Revision: D25620908

fbshipit-source-id: 1dd737d451ddfd07baa427902bdf1c96d7e67e64
2020-12-17 19:35:29 -08:00
Ramanpreet Nara 5c4f145e33 Roll out TurboModule Promise Async Dispatch
Summary:
## Context
The legacy NativeModule infra implements promise methods using [async NativeModule method calls](https://fburl.com/diffusion/tpkff6vg). In the TurboModule infra, promise methods [treat as sync methods](https://fburl.com/diffusion/yde7xw71), and executed directly on the JavaScript thread. This experiment makes TurboModule promise methods async, and dispatches them to the NativeModules thread, when they're executed from JavaScript.

Reviewed By: fkgozali

Differential Revision: D25623192

fbshipit-source-id: 2b50d771c5272af3b6edf150054bb3e80cab0040
2020-12-17 17:27:09 -08:00
Ramanpreet Nara 40115d87d4 Roll out package info validation
Summary:
## Context
Every time we require a NativeModule in Java, we [first try to create it with the TurboModuleManager](https://fburl.com/diffusion/3nkjwea2). In the TurboModule infra, when a NativeModule is requested, [we first create it](https://fburl.com/diffusion/d2c6iout), then [if it's not a TurboModule, we discard the newly created object](https://fburl.com/diffusion/44gjlo6y). This is extremely wasteful, especially when a NativeModule is requested frequently and periodically, like UIManagerModule.

Therefore, in D24811838 (803a26cb00) fkgozali launched a fix to the infra that would avoid creating the non-TurboModule object in the first place. Today, we're launching this optimization.

Reviewed By: fkgozali

Differential Revision: D25621570

fbshipit-source-id: dedba4d5ac6fcf2ec3c31e7163a6a226065c708b
2020-12-17 17:27:09 -08:00
David Vacca 5a37773e53 Fix race condition in FabricUIManager.StartSurface method
Summary:
This diff fixes a race condition in the execution of FabricUIManager.StartSurface method.
The rootcause is that startSurface is executing getViewportOffset from a background thread.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D25617154

fbshipit-source-id: 9351201088164e74bb0b9454e30651e1de0da912
2020-12-17 16:18:13 -08:00
doniwinata0309 b4c9f13fe7 Remove Okhttp3 Android Proguard Rules (#30514)
Summary:
Remove proguard keep rules on okhttp3. The library already contains its own consumer proguard --> see https://square.github.io/okhttp/r8_proguard/

The keep rules will increase the final apk size of android app. Currently, there is no way to disable proguard rules from transitive dependencies ( https://issuetracker.google.com/issues/37073777). So any android app that use react native will also contains this proguard rules.

## Changelog

[Android] [Removed] - Remove okhttp3 proguard rules

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

Test Plan: n/a

Reviewed By: mdvacca

Differential Revision: D25616704

Pulled By: fkgozali

fbshipit-source-id: eb0bcbc4ace398a55ce6902e34c17b030bb87130
2020-12-17 09:41:17 -08:00
Keion Anvaripour 4537131878 Bytecode client for Android (#30595)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30595

Changelog: [Internal]

Add support for loading HBC bundles from Metro in Twilight.
* adds `runtimeBytecodeVersion` to the bundleURL
* adds logic to check chunk hermes bytecode bundles
* adds support for running the bytecode bundles

Reviewed By: cpojer

Differential Revision: D24966992

fbshipit-source-id: acdd03a2e9e2b3e4c29c99c35a7c9136a3a7ef01
2020-12-16 16:03:57 -08:00
Joshua Gross 47a9d18912 Delete LayoutAnimations gating code and related dead code
Summary:
Ship LayoutAnimations to 100% of users by removing feature-flag gating.

The `collapseDeleteCreateMountingInstructions_` stuff is always disabled for LayoutAnimations, so we can get rid of that too.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25510740

fbshipit-source-id: 71bac44f829530458e4906ecd1e7e68e766de2ec
2020-12-12 03:40:30 -08:00
Ron Edelstein 933cef6d9a More explicit marking of autoglob as False
Summary:
In preparation for flipping the default, marking autoglob as False in places where it isn't explicitly specified.

Changelog: [Internal]

Reviewed By: strulovich

Differential Revision: D25497305

fbshipit-source-id: 142e5caca2d67efcb3c25067a36934f7f6dd4b21
2020-12-11 16:45:55 -08:00
Ramanpreet Nara d8c84d3a65 Make Metro work with Venice
Summary:
Now, Metro should work with Venice. This piggybacks on Lulu's fix here: D22477500 (9b8ffeee4c).

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D25323041

fbshipit-source-id: 859958185c5be52a4bfdc12a82ecd7719042ae5f
2020-12-11 10:51:35 -08:00
Kevin Gozali 072896e3b7 Android: introduced uimanager/interfaces target for base symbols used by codegen output
Summary:
Some of the existing files under uimanager/ are self contained and used by the component codegen output. This commit split out those files into a dedicated uimanager/interfaces/ dir/target so that more targets can depend on it without causing dep cycle.

Also, the component codegen output doesn't need LayoutShadowNode at all, so this removed the import.

This will allow us to combine the Java codegen output for TM spec and Fabric components, simplifying build and dependency management (not in this commit yet).

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D25451409

fbshipit-source-id: 827545a3d78ebed1815cf9e52da2fa896b012aa1
2020-12-10 00:06:21 -08:00
Joshua Gross c1f9a4562c Remove `clipChildRectsIfOverflowIsHidden` feature flag and associated code
Summary:
The flag `clipChildRectsIfOverflowIsHidden` has been set to false for a little over a year. Delete it and associated callsites.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25451696

fbshipit-source-id: a6067b2e25124f6bdef336c2ddead719dd44cca9
2020-12-09 21:17:25 -08:00
Joshua Gross 7f0373d4ff Remove `enableExperimentalStateUpdateRetry` feature flag
Summary:
In practice this has been enabled in production for months and is fine. Remove feature-flag and gating.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25451697

fbshipit-source-id: 9e70db3ed4e00de7b8295d9225d43ba09e4e68e9
2020-12-09 21:17:25 -08:00
Joshua Gross 4690effc5c Remove `enableSpannableCacheByReadableNativeMapEquality` flag
Summary:
This has been true for 100% of users for months; clean up the old code.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25451470

fbshipit-source-id: feae59ce746869b9d84d6aaa69be10e91181f03a
2020-12-09 21:17:25 -08:00
Joshua Gross 4bc40bf8e6 Remove code no longer needed for debugging T78035906
Summary:
This code was useful for debugging T78035906 but is no longer needed.

I'm a bit conflicted about removing it, since such issues could crop up again in the future - but they're very rare, and hopefully now we know how to avoid them.

tl;dr: Make sure that mount instructions are not executed *during* a draw or measure.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25450846

fbshipit-source-id: e261f13db252d22773e373a5de744ecc8c380a43
2020-12-09 21:17:24 -08:00
Joshua Gross e020c6c0a7 Removing gating code for Fabric; don't initialize ViewGroupDrawingOrderHelper for RVG in Fabric
Summary:
This code and this class isn't needed in Fabric, so don't create it during construction. Lazy-load it when it's needed outside of Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25450724

fbshipit-source-id: d14d8f03c194716f2aba0e499f3282ad2d1c1d29
2020-12-09 21:17:24 -08:00
David Vacca 8c013173f8 Remove double lookup of UIManager
Summary:
Remove double lookup of UIManager, cast of null returns null.

changelog: [internal]

Reviewed By: ejanzer

Differential Revision: D25453878

fbshipit-source-id: c727c15fa787981eb5bf02006184e14cfab319c6
2020-12-09 20:59:31 -08:00
David Vacca 3ac7a4d6ba Prevent ReactRootView to load UIManagerModule when running with Fabric Enabled
Summary:
Prevent ReactRootView to load UIManagerModule when running with Fabric Enabled

changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D25453879

fbshipit-source-id: 98e88db17a86ae60e14efb070df9b2da082ae127
2020-12-09 20:59:31 -08:00
David Vacca 9c827f6201 Prevent initialization of constants for view managers for users with static view config enabled
Summary:
This diff prevents the pre-calculation of ViewManager's constants for users with static view config enabled.
We still load viewManager classes and create viewManger objects for perf reasons

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25414068

fbshipit-source-id: a91f6113e35b42625c03d13bd67b63e3f9f75098
2020-12-08 22:03:13 -08:00
Dulmandakh a4d8632890 cleanup release.gradle (#30468)
Summary:
Cleanup release.gradle and remove code used to upload RN to maven repository, which is not longer used. Also removed configuration to include Javadoc, Sources in maven repo, thus reduce NPM package size.

## Changelog

[Internal] [Changed] - cleanup and remove maven upload from release.gradle

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

Test Plan: you will no longer see *uploadArchives* in ./gradlew tasks. Also you can run **./gradlew :ReactAndroid:installArchives**

Reviewed By: mdvacca

Differential Revision: D25408128

Pulled By: fkgozali

fbshipit-source-id: b3ced1b466b9f11e3970136a116af4e29dbd33a1
2020-12-08 15:56:51 -08:00
Joshua Gross 99f2f5ffdd `deleteRootView`: use concurrent pattern with `mTagToViewState`
Summary:
Instead of doing a "containsKey then get", just get the rootViewTag and see if it's non-null. Theoretically, since it's a
concurrent data-structure, it could be removed from the ConcurrentHashMap between "containsKey" returning true and the "get".

This does not fix any known, existing problems.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25378703

fbshipit-source-id: 62a44e68e4443dac5a557263cc4bb33de9eea993
2020-12-07 17:59:09 -08:00
Joshua Gross 3cdef265ae Remove premature optimization in FabricUIManager; could be causing stopSurface inconsistencies
Summary:
There is an optimization in FabricUIManager.surfaceActiveForExecution that ensures it returns the same value (true or false)
for a given SurfaceId for a single frame (the value is cached until the next frame).

It seems like this can be causing a few different crashes, in a couple different ways:

1) If StopSurface is called off the UI thread, in the middle of a batch of operations (probably less likely to cause problems)
2) If StopSurface is called on the UI thread, in between different operations; the latter operations will still execute because the `true` value of `surfaceActiveForExecution` was cached.

I don't think that this optimization was providing much for us, and could be causing crashes. Remove it for now and we'll analyze impact on crashes and perf.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25379970

fbshipit-source-id: 2c15c971bd0c828e1d38a34662d93293271041b2
2020-12-07 17:10:00 -08:00
Riley Dulin 72d29ee7d7 Destroy jni::global_ref while inside a ThreadScope
Summary:
The `BlobCollector` native module stored a `jni::global_ref` as a member,
and its destructor automatically destroys it.
However, as noted in JSI documentation, there is no guarantee that the destructor
is run on a JVM-registered thread. The destructor knew this and used a `jni::ThreadScope`
to do some other JNI behavior, but the global_ref needs to be destroyed during
that ThreadScope as well.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D25372698

fbshipit-source-id: f4eba0b2da154c6eac54d7faeb9ea5bb9260bec9
2020-12-07 15:42:57 -08:00
David Vacca 5fb82e7425 Ensure ReactRootView.getId() is accessed on the UIThread
Summary:
Ensure ReactRootView.getId() is accessed on the UIThread

changelog: [internal] intenral

Reviewed By: JoshuaGross

Differential Revision: D25321379

fbshipit-source-id: 889e59c655324352a7b9ac5bed769750786b8190
2020-12-07 13:41:42 -08:00
David Vacca 503a6f4463 Optimize iteration of ReadableNativeMaps
Summary:
Props are transferred from C++ to Java using ReadableNativeMaps. The current implementation of ReadableNativeMaps creates an internal HashMap the first time one of its methods is executed.
During the update of props ReadableNativeMaps are consumed only once and they are accessed through an Iterator. That's why there is no reason to create the internal HashMap, which is inefficient from performance and memory point of view.

This diff creates an experiment that avoids the creation of the internal HashMap during prop updates, additionally it removes a lock that was being used in the creation of the internal HashMap. I expect this change to have a positive impact in TTRC and memory (in particular for ME devices)

This diff reduces the amount of ReadableNativeMaps's internal HashMaps created during initial render of MP Home by ~35%.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D25361169

fbshipit-source-id: 7b6efda11922d56127131494ca39b5cec75f1703
2020-12-06 11:28:11 -08:00
David Vacca b636397a0d Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager
Summary:
Add annotations and thread safety checks in the initialization / teardown methods of ReactInstanceManager

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D25321380

fbshipit-source-id: 113a7c224ae04009cda9e15676208abcef6af211
2020-12-04 19:58:10 -08:00
David Vacca 74a756846f Fix race condition on startSurface
Summary:
The root cause of this bug is a race condition between the onMeasure method and setupReactContext.

ReactInstanceManager.attachRootView() method is responsible of the initialization of ReactRootViews and it is invoked by ReactRootView.onMeasure() method in the UIThread

Important initialization steps:
1. Clear the Id of the ReactRootView
2. Add the ReactRootView to the mAttachedReactRoots
3. Call StartSurface (if the bridge has been initialized)

Sometimes, when this method is invoked for the first time, the bridge is not initialized, in those cases we delay the start of the surface.

Once the bridge is initialized, StartSurface is called by the setupReactContext() running in the NativeModuleThread.

Since onMeasure can be called multiple times, it is possible that we call "StartSurface" twice for the same ReactRootView, causing the bug reported on T78832286.

This diff adds an extra check to prevent calling "StartSurface" twice. The fix is done using an AtomicInteger comparison and it is gated by the flag "enableStartSurfaceRaceConditionFix". Once we verify this works fine in production we will clean up the code, remove the flags and maybe revisit the API of ReactRoot.

changelog: [Android] Fix race-condition on the initialization of ReactRootViews

Reviewed By: JoshuaGross

Differential Revision: D25255877

fbshipit-source-id: ca8fb00f50e86891fb4c5a06240177cc1a0186d9
2020-12-04 19:58:10 -08:00
Ramanpreet Nara 374808f307 Delete redundant dependency in turbomodules/core:coreAndroid
Reviewed By: ejanzer

Differential Revision: D25274090

fbshipit-source-id: 6f18ebee410b0866d5c5f96cc80631116f4251ff
2020-12-04 12:00:01 -08:00
Andrei Shikov fbf37092a8 Disable non-Fabric view operations after catalyst instance is destroyed
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D25248836

fbshipit-source-id: 9afb0c18e7825d32857f746b038268758afaaaa8
2020-12-04 11:03:34 -08:00
Joshua Gross bd2b459561 Non-Fabric: ensure every requestLayout is followed by a performLayout
Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25319526

fbshipit-source-id: 5527d90d84ef53847b1a478bfa16c27e3ca4720b
2020-12-04 00:29:42 -08:00
David Vacca 0d3aa35a03 remove unnecessary check
Summary:
EZ check to remove unnecessary check

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25315988

fbshipit-source-id: a635ce9fd7ad50109bee55f82ccf3556cc7a4b0d
2020-12-03 20:50:01 -08:00
Xiaoyu Yin 7008ffb663 Protect methods from proguard
Summary:
These methods were being striped from proguard, which causes release builds to instacrash

Changelog: [Internal] Protect methods from Proguard

Reviewed By: RSNara

Differential Revision: D25314933

fbshipit-source-id: 173160eab953b7c24e02f5e6ef3bf335c1f85526
2020-12-03 16:42:55 -08:00
Joshua Gross 2e6eea8390 Remove enableStopSurfaceOnRootViewUnmount feature flag
Summary:
This feature flag (enableStopSurfaceOnRootViewUnmount) was used to gate usage of the "stopSurface" API, which is now fully supported, and has been used
in the FB app for several months. This is safe to ship in code.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25275192

fbshipit-source-id: fa22bfd00aa023297bc19c83c138f133e9ff1645
2020-12-02 20:10:00 -08:00
Joshua Gross 067d2eee03 Remove `enableDrawMutationFix` feature flag and ship it
Summary:
This was added to prevent mutating the UI during draw or measure, and appears to have been effective. Keep the comments, ship the feature, remove flags.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25258409

fbshipit-source-id: 36ad8a03d1eb82bc9dcd769372c03f1ebe8b8da8
2020-12-01 19:52:45 -08:00
Xiaoyu Yin b9b2215174 Add DoNotStrip annotations to TurboModulePerfLogger
Summary:
Prevent proguard from stripping these methods

Changelog: [Internal] Add DoNotStrip annotations to TurboModulePerfLogger

Reviewed By: RSNara

Differential Revision: D25101027

fbshipit-source-id: 673e97446a36fe0e8c10916aa7eb4c39c2187ba8
2020-11-30 14:15:24 -08:00
Emily Janzer c0a2998387 Move TurboModuleManager to use RuntimeExecutor instead of jsContext (#30416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30416

This diff changes the constructor param for TurboModuleManager from jsContext (a long representing the `jsi::Runtime` pointer) to a RuntimeExecutor. It also updates callsites to use the new RuntimeExecutor created by CatalystInstance. This is only used for installing the TurboModule JSI binding; it's not currently used for JS invocation in TurboModules, which is handled separately by JSCallInvoker. Ultimately we may be able to implement JSCallInvoker *with* the provided RuntimeExecutor, but there's some additional logic in JSCallInvoker that we don't have here yet.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D21338930

fbshipit-source-id: 1480c328f1a1776ddf22752510c0f3b35168a489
2020-11-20 14:32:59 -08:00
Tim Yung f6b8736b09 RN: Update ViewConfig for ScrollView
Summary:
Updates `ReactScrollViewManager` and the `ViewConfig` for `ScrollView` so that they are equivalent.

- `inverted` was missing.
- `contentOffset` was missing differ on Android. (However, there does not seem to be any perceivable behavior difference besides the native `ViewConfig` being different.)

Changelog:
[Internal]

Reviewed By: JoshuaGross

Differential Revision: D25084470

fbshipit-source-id: 8bea3b7a692c1038819a4147b174583a4faa71e9
2020-11-19 02:52:00 -08:00
Kevin Gozali 9eb23e741f Android OSS: Solve some Javadoc warning due to missing dependencies
Summary:
A bunch of deps were missing when generating Javadoc, producing warnings. One issue was:

```
project.getConfigurations().getByName("compile").asList()
```

Seems to be deprecated (?), so this list is always empty. The mitigation is to create a new configuration that just inherits from `api()` dependencies, so that we can add them in Javadoc task.

The other problem (not solved in this commit), is that some deps are .aar files, which require some manual unpacking before they can be processed: https://stackoverflow.com/questions/35853906/how-to-generate-javadoc-for-android-library-when-it-has-dependencies-which-are-a

Note that this is separate fix from https://github.com/facebook/react-native/pull/30417

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D25041164

fbshipit-source-id: 2ee8b268c2d38e3ecbf622c05c3c56123b7a15a6
2020-11-17 18:27:35 -08:00
Nick Gerleman b841ee6fb8 Fix :ReactAndroid:androidJavadoc task (#30417)
Summary:
Fixes https://github.com/facebook/react-native/issues/30415

This is a quick and dirty fix to unblock publish, of excluding a class from Javadoc generation that is importing a class current build logic cannot handle. This is not a long-term fix for the issue.

## 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
-->

[Internal] [Fixed] - Fix :ReactAndroid:androidJavadoc task

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

Test Plan: Tested that the task now completes locally.

Reviewed By: lunaleaps

Differential Revision: D25041282

Pulled By: fkgozali

fbshipit-source-id: f774ab30a09db473178e2a51c77860e4985dd8e3
2020-11-17 18:27:35 -08:00
Joshua Gross bbd0f03481 Removing pre-API 21 code
Summary:
We don't support pre-API 21/Android <5/pre-Lollipop anymore; delete related code or checks.

No need for this to make it to the changelog, this announcement was already made.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24965249

fbshipit-source-id: e537e62e8eb18878c29afe17b8c7861d095a37b7
2020-11-16 12:43:14 -08:00
Joshua Gross 752e7ab1f9 Experiment to replace Fabric MountItem lists with concurrent queues (re-land)
Summary:
Currently, queuing any sort of MountItem or getting the list of MountItems requires synchronization. Since these can be queued up at any point from the JS thread, there will, in theory, be constant contention between JS and UI thread.

To see if this is true, I'm creating an experiment instead of just switching over to concurrent structures. After seeing results, we can hopefully make a decision and delete the non-concurrent stuff or improve on it somehow.

The original was unlanded in D24973616 (26787e2260) due to a typo, which has been fixed now. The typo was that in Blocking Mode, we queued up all PreMountItems to the concurrent PreMountItems queue.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D24974851

fbshipit-source-id: d081c081bbd0de445bb92408f0ec822056b905a5
2020-11-14 12:19:56 -08:00
Andrei Shikov 26787e2260 Back out "Experiment to replace Fabric MountItem lists with concurrent queues"
Summary:
Changelog: [Internal]

Original commit changeset: fcbdeda51f91

Reviewed By: rubennorte

Differential Revision: D24973616

fbshipit-source-id: 4d21211d329c77dba50972a26b1daeccfffad912
2020-11-14 08:59:02 -08:00
Koichi Nagaoka d85d5d2e19 Fix cannot working Modal's onDismiss. (#29882)
Summary:
Fixes: https://github.com/facebook/react-native/issues/29455

Modal's onDismiss is not called on iOS.
This issue occurred the commit bd2b7d6c03 and was fixed the commit 27a3248a3b.
However, the master and stable-0.63 branches do not have this modified commit applied to 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
-->

[iOS] [Fixed] - Modal's onDismiss prop will now be called successfully.

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

Test Plan:
Tested on iOS with this change:

1. Set function Modal's onDismiss prop.
1. Set Modal's visible props is true. (show Modal)
1. Set Modal's visible props is false. (close Modal)
1. The set function in onDismiss is called.

Reviewed By: shergin

Differential Revision: D24648412

Pulled By: hramos

fbshipit-source-id: acf28fef21420117c845d3aed97e47b5dd4e9390
2020-11-13 23:56:09 -08:00
Joshua Gross 47000756fe Add more systrace sections to FabricJSIModuleProvider
Summary:
Adding more Systrace sections to get perf information during critical paths.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24960195

fbshipit-source-id: 099e9cfac8ac87287e48e9915e6b28fe7a448783
2020-11-13 21:53:37 -08:00
Joshua Gross c609952ddb Add Systrace sections to UIImplementationProvider
Summary:
Add Systrace sections to initialization of non-Fabric UIImplementationProvider. This path is sometimes invoked during startup of Fabric so I'd like to gather more information about its impact.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24959965

fbshipit-source-id: a8555b8db284d00f97c71ca859cb2020409cb110
2020-11-13 21:53:36 -08:00
Joshua Gross 66e536739e Add additional debug logging for startSurface crashes
Summary:
There are a very, very small number of crashes in production that are hitting this line. I would like to understand what the existing tag ID is (perhaps it's eqal to the ID being set, which would indicate "double-start"). If not, it indicates that fragments are being reused somewhere, or something else odd is going on with lifecycles.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24953785

fbshipit-source-id: 079c86cdb571749662cca46feeaebdd6cb1281f4
2020-11-13 21:53:36 -08:00
Joshua Gross 23def0f8f0 Experiment to replace Fabric MountItem lists with concurrent queues
Summary:
Currently, queuing any sort of MountItem or getting the list of MountItems requires synchronization. Since these can be queued up at any point from the JS thread, there will, in theory, be constant contention between JS and UI thread.

To see if this is true, I'm creating an experiment instead of just switching over to concurrent structures. After seeing results, we can hopefully make a decision and delete the non-concurrent stuff or improve on it somehow.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24942110

fbshipit-source-id: fcbdeda51f91f4bd430a20d7484854fb1e94a832
2020-11-13 21:53:36 -08:00
Dulmandakh 2798e7172b remove ReactFragmentActivity (#30331)
Summary:
Remove ReactFragmentActivity class, which was deprecated at least since 0.58.

## Changelog

[Android] [Changed] - remove ReactFragmentActivity class.

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

Reviewed By: makovkastar

Differential Revision: D24914082

Pulled By: fkgozali

fbshipit-source-id: 6833b76552a1fc19680f96501d4b8e2ff03c2c39
2020-11-13 09:55:40 -08:00
Joshua Gross f1fbfebccb Add ReactRootView perf markers
Summary:
Add three markers for ReactRootView perf logging: onMeasure, attachToReactInstanceManager, and updateLayoutSpecs.

It is suspected that one or all of these have regressed under Fabric in some cases.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24909635

fbshipit-source-id: 6b6c0cc792c4b2d72f2360d6cffc02ef00e8a88b
2020-11-12 15:54:58 -08:00
Joshua Gross 68126ed470 Skip execution of IntBufferBatchMountItem if surface has stopped
Summary:
Fixes crashes in surface teardown / navigating away from a surface.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24907216

fbshipit-source-id: 7bd7578c81687c7e64e8f70fecf8446bb333a1ed
2020-11-12 15:54:58 -08:00
Dulmandakh 96ace87791 remove android support library (#30347)
Summary:
This PR removes remains of Android Support Library, now replaced with AndroidX.

## Changelog

[Internal] [Changed] - remove Android Support Library from Buck

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

Test Plan: CI is green

Reviewed By: JoshuaGross

Differential Revision: D24914088

Pulled By: fkgozali

fbshipit-source-id: 0ff18dfd7c684642a5c27308112b6fddc27608a7
2020-11-12 09:14:29 -08:00