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

21756 Коммитов

Автор SHA1 Сообщение Дата
Samuel Susla 1bafd0086f Remove v1 event coalescing
Summary:
Changelog: [internal]

Old event coalescing isn't used anymore and there haven't been any problems with the new one.

Reviewed By: shergin

Differential Revision: D25701311

fbshipit-source-id: 359f0361edffa22130cfa8322038acdbe26fd599
2021-01-04 04:12:30 -08:00
Rubén Norte e2033c5b7b Add FlowFixMes for future violations of typed EventEmitter
Summary:
This prevents having to modify too many files when we add the proper typing for that module

Changelog: [Internal]

Reviewed By: nadiia

Differential Revision: D25586848

fbshipit-source-id: 16001ada4a37a58f83b6e5a4400daebf9257be72
2021-01-04 03:56:57 -08:00
Rubén Norte c7463f0059 Add FlowFixMes for future violations of typed NativeEventEmitter
Summary:
Migrates all usages of `NativeEventEmitter` to `NativeEventEmitter<$FlowFixMe>`.

This prevents having to modify a very large number of files in the same change that adds support for typed events. It adds an unused typed parameter to `NativeEventEmitter` so we can change all usages to add `$FlowFixMe`.

Changelog: [Internal]

Reviewed By: nadiia

Differential Revision: D25575774

fbshipit-source-id: c7979e1502e980401d9c03456282eba333c1606d
2021-01-04 03:56:57 -08:00
Rubén Norte 1e7536a070 Migrate CodegenTypes and dependencies to Flow strict
Summary:
Migrates `CodegenTypes` and its transitive dependencies to Flow strict to unblock this mode in Native Modules and Native Components.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D25540629

fbshipit-source-id: 7bed2ee58af7a789b50932734c7a86cf1719e2c5
2021-01-04 03:56:57 -08:00
Rubén Norte e088a4fe9c Add support for UnsafeObject to allow using Flow strict in native modules
Summary:
This new type will be valid in Flow strict mode and can be used by native modules and components to replace `Object`, with the same semantics.

This unblocks the migration of the most modules in the React Native package to Flow strict.

Changelog: [Internal] Add UnsafeObject type compatible with Flow strict mode to use in native modules and components

Reviewed By: RSNara

Differential Revision: D25540631

fbshipit-source-id: 60b80bbc84a53aecc747e3a1799cdf551e1859cd
2021-01-04 03:56:57 -08:00
David Vacca 89beefaefb Setup test infra into mapBuffer project
Summary:
Setup test infra into mapBuffer project

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25733949

fbshipit-source-id: bcfc89d87e28dc5a6ed28bc6b56893aa6f191e71
2021-01-01 15:45:06 -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 053b8f6c93 Fix typo in ReactNativeTypes
Summary:
Faric -> Fabric

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25734126

fbshipit-source-id: 5d0bb02482fd713601de0a22477c5b5c39daf522
2020-12-30 12:23:20 -08:00
Héctor Ramos 811ccec74e Add use_react_native_codegen!
Summary:
Consolidate CocoaPods codegen scripts under a single `use_react_native_codegen!` method in `react_native_pods.rb`.

This is the first step towards making the codegen scripts library-agnostic. There are still a handful of hardcoded assumptions in place (e.g. the output directory structure, the use of a separate directory for components), but with some work one would be able to add codegen support to arbitrary CocoaPods podspecs.

The codegen script no longer takes a CODEGEN_PATH argument, and will instead attempt to use the local react-native-codegen package if available, and fallback to using the node_modules/react-native-codegen package if not.

## Usage

The `use_react_native_codegen!` method has two arguments:

- `spec`, a pod [Specification](https://www.rubydoc.info/github/CocoaPods/Core/Pod/Specification) object.
- `options`, an optional object. Supported keys:
  - `:srcs_dir`, the path to your JavaScript sources. Your native module or component specs should be located somewhere in this directory.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25728053

fbshipit-source-id: feec587b656d5b220598ce6196ea6bb34a9580a9
2020-12-29 16:10:34 -08:00
Valentin Shergin 00e038689d TextInput measuring error in ScrollResponder downgraded to a warning
Summary:
Even though replacing an error with a warning does not look like a future-proof solution here are the reasons for this:
* The measuring operation might just fail because of the async nature of React Native. And here, from my understanding, we don't even have a good reason for measuring. Auto-scrolling to selected textinput (which is the reason for this code, AFAIK) is a standard feature that OS does for all text input. I suspect that this (very old) feature was built in a timeframe where this system feature was originally broken (sometime before 2016).
* This product-facing API does not have an error-callback, so just loggin an error here is as (not) actionable as logging a warning.
* The error callback was never implemented in the pre-Fabric world, so it *never* got called for years, and now when Fabric is starting calling in some cases, it is being "punished" for this. In the next diff, I will try to retrofit this feature back to Paper to reach parity with Paper.

Changelog: [Internal]

Differential Revision: D25700156

fbshipit-source-id: 319a146b17cc2130848148ad11adbde16e86c5d5
2020-12-29 15:58:56 -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 266108d7d8 LayoutAnimations: use the final view as the baseline for animations, instead of the initial view
Summary:
To ensure that we're not sending old eventEmitters or State objects to the mounting layer, or potentially out-of-date Props objects, base
animated interpolations on the final ShadowNode instead of the initial.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25727481

fbshipit-source-id: 560ae8d25c7cec4c2137e70b4571b762f461edff
2020-12-29 15:54:45 -08:00
Joshua Gross 907b574cf6 LayoutAnimations: change default prop interpolation on Android: set new non-interpolated prop values at beginning of animation, not end
Summary:
In Android, only changed prop values are sent to the mounting layer via folly::dynamic maps. In the LayoutAnimation system, before this, we only sent that
map at the /end/ of the animation for any non-interpolated values (for example, image source is not interpolated so it was not updated until the end of the animation).

However, what we probably expect is that all non-interpolated values change immediately, and interpolated values smoothly transition. This diff makes that change on Android
by using the final RawProps as the /initial/ value that interpolations are stacked on.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25727483

fbshipit-source-id: e692d37b9965fedcdf429a81d60b7cb7f0c6abe1
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
Ramanpreet Nara 4c734d1e8d Support custom android_package_name in module codegen
Summary:
## Changes
All `rn_library(codegen_modules = True)` must now also specify native_module_android_package_name, like so:

```
rn_library(
  name = "FBAuth"
  codegen_modules = True,
  native_module_spec_name = "Foo",
  native_module_android_package_name = "com.facebook.fbreact.specs",
)
```

This will generate the FBAuth Java spec files under the appropriate directory: "com/facebook/fbreact/specs". It will also make the code-generated specs have the appropriate package name: "com.facebook.fbreact.specs".

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25723176

fbshipit-source-id: 6efec1cbee43d70110c0ef23e2422e08609b61d4
2020-12-29 13:04:36 -08:00
Ramanpreet Nara 6740b22ab0 Add @DoNotStrip to exported methods in NativeModule specs
Summary:
NativeModule methods are meant to be called from JavaScript. As such, they may not necessarily have call-sites in Java. This means that they're succeptible to being stripped by proguard.

This diff annotates all exported NativeModule methods with DoNotStrip, so that proguard doesn't strip them. We already do this in the legacy codegen.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25723801

fbshipit-source-id: a7c8701e0a5d03a970f5f19cc6ae6b320a2e99a1
2020-12-29 13:04:36 -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
David Vacca 59f8b6adbb Extract measure() Android function into an utility method
Summary:
This diff extracts the measure() Android function into an utility method.
As part of this diff I'm also refactoring one of the usages of this method (Text)

Additional refactors will be done as part of other diffs

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D25721046

fbshipit-source-id: 76cc6a8088607aaae5055c675076a0c18fc322ec
2020-12-28 23:25:03 -08:00
Joshua Gross b8ca59cd74 Reduce re-rendering of Animated components in Fabric
Summary:
The `isFabric` method used in createAnimatedComponent is unreliable (another reason in a long list of reasons why you should not duplicate this code elsewhere, and why we want to delete it ASAP).
In particular, during the first render, the ref component has not been set yet, so we /cannot/ detect if the component is Fabric or non-Fabric and assume it's non-Fabric.

In Fabric, this causes `collapsable` and `nativeID` values to change after the first render.

To reduce this re-rendering, but not eliminate it for all components, I've introduced a flag that indicates if a component will /never/ be flattened. In particular, Image components, ScrollViews, Text cannot ever be flattened,
so we should always pass `collapsable:false` and the same nativeID prop for those components. For Animated <View>s and other components, the re-rendering issue is still a problem in Fabric for now.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25720322

fbshipit-source-id: fe3234d8ae974911a2b5f82e4f6a093216f43d4b
2020-12-28 22:35:15 -08:00
Héctor Ramos f002a5710f Disable tests with USE_FRAMEWORKS=1 (#30655)
Summary:
Tests that set USE_FRAMEWORKS=1 will fail because Flipper does not currently support the use of frameworks. These tests should be re-enabled once this issue is addressed.

## 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] - Disable USE_FRAMEWORKS=1 tests

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

Test Plan: CI

Reviewed By: fkgozali

Differential Revision: D25718040

Pulled By: hramos

fbshipit-source-id: 1db1fc59b2d47922c3329e9f438e571bde370ecc
2020-12-28 14:28:55 -08:00
Dulmandakh 5a3e13ad8f fix Android CI - autoglob (#30652)
Summary:
This PR is fixing Android CI by ignoring autoglob configuration.

## Changelog

[Internal] [Changed] - fix Android CI

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

Test Plan: Android CI is green again

Reviewed By: d16r

Differential Revision: D25715153

Pulled By: fkgozali

fbshipit-source-id: 6fb44bb4078735ea83132fcff2559ef6b27405da
2020-12-28 13:49:51 -08:00
Samuel Susla a9bc3853f0 Cancel touches if surface touch handler can be prevented | second try
Summary:
Changelog: [internal]

Previous implementation, (D25684453 (eba31d2858)) which was backed out, had a bug that caused assert to fail. It was restarting internal state `RCTSurfaceTouchHandler` and lead to inconsistency.
This is because touch event is a state machine and before "moved" is called, touch event had to "began". With internal state being restarted, that wasn't the case.

In the previous implementation the internal state was incorrectly restarted because I thought touches would not longer receive touch events after declaring that UIGestureRecogniser shouldn't be recognised simultaneously.

In this diff I take a different approach. Instead of restarting the internal state, the recogniser is first disabled and then enabled again. This cancels any ongoing touches instead of manual cleanup.

### Other approaches

In the UIViewController, we could listen to `viewWillDisappear` message and cancel any ongoing touches on the surface. This would work as well (it would prevent Pressable components from being highlighted during interactive view controller dismissal) however we would need to expose existence of `RCTTouchHandler` to the view controller. This approach is also discouraged in D15734129 (36307d87e1).

Reviewed By: shergin

Differential Revision: D25685536

fbshipit-source-id: ad226c82e73f841c1ebd9b92738847cc5cdc21d1
2020-12-27 03:26:03 -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
Ramanpreet Nara a68415270c Delete codegen_rn_modules_tests
Summary:
This test was used to compare the old codegen output with the new codegen output. It was written predominately to test the ObjC++ generator. A few reasons why we should delete this:
1. We do not want the old and the new codegen targets co-existing because it will slow down buck query.
2. The new ObjC++ codegen output is different from the old. In the new ObjC++ generator, we aren't generating dead structs. Therefore, this test simply won't work on the most sophisticated generator (i.e: the generator it was designed to run on). The other generators are really simple. We've also been running the ObjC++ and the Java generators in production for over a month for react-native-github specs. These are arguably the most complicated specs we maintain, so generator correctness isn't too much of a concern.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25683069

fbshipit-source-id: b2175f34f50a078d80ef738e59024f546628219a
2020-12-24 00:50:01 -08:00
Héctor Ramos f45cb60e56 Use Fabric builds in iOS tests (#30639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30639

# Changelog:
[Internal] Enable Fabric builds in iOS tests on Circle CI and Sandcastle.

Reviewed By: fkgozali

Differential Revision: D25700257

fbshipit-source-id: a250dbc9904efec9ded130912a993638f0992373
2020-12-23 22:26:11 -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
Luna Wei 3ade096f02 Add cachebreaker to remote assets
Summary:
Changelog:
[Internal][Added] - Create a general utils for assets and add a cache breaker utility to set/get a urlparam for remote assets.

Reviewed By: motiz88

Differential Revision: D25521331

fbshipit-source-id: 042e52a27e826bc9993e80bc68cc6fc68abaf224
2020-12-23 19:49:27 -08:00
Valentin Shergin fba0631ba7 Fabric: Farewell ConcreteStateTeller
Summary:
ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687692

fbshipit-source-id: a89d0a4d63b9c97775a312afa3df43f26b5ecc08
2020-12-23 10:09:25 -08:00
Valentin Shergin e7c41ec5fb Back out "Use ConcreteStateTeller in RCTInputAccessoryComponentView"
Summary:
Original commit changeset: a3324b5df6e6
ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687697

fbshipit-source-id: 849bb8b6c244b17a49b5fe140346d90a9a7e52ff
2020-12-23 10:09:25 -08:00
Valentin Shergin 6675b61404 Back out "Use ConcreteStateTeller in RCTLegacyViewManagerInteropComponentView"
Summary:
Original commit changeset: 4c0d7b249175

ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687698

fbshipit-source-id: b7eac808db1acdc7ef3297313ac352162bdccd5b
2020-12-23 10:09:25 -08:00
Valentin Shergin a0beb3a437 Back out "Use ConcreteStateTeller in RCTModalHostViewComponentView"
Summary:
Original commit changeset: b82301e5db48

ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687694

fbshipit-source-id: 17a737d394cb7f460b239be421466981bc46f995
2020-12-23 10:09:24 -08:00
Valentin Shergin b426cbccb4 Back out "Use ConcreteStateTeller in RCTTextInputComponentView"
Summary:
Original commit changeset: 2b82e2d43cc6
ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687699

fbshipit-source-id: d318155509b00064e29fc32efe893151a9723fd5
2020-12-23 10:09:24 -08:00
Valentin Shergin 016905333a Back out "Use ConcreteStateTeller in RCTScrollViewComponentView"
Summary:
ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism.

Original commit changeset: 8c777ae1264c

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25687695

fbshipit-source-id: 334cb6c7497270c040e4aec262a30441bc7529ce
2020-12-23 10:09:24 -08:00
Samuel Susla da10179238 Pass x and y to measure callback
Summary:
Changelog: [internal]

Previous implementation of "measure" in UIManagerBinding returned 0, 0 for x and y coordinates.

Reviewed By: shergin

Differential Revision: D25681586

fbshipit-source-id: fa69b6d4803f083a8299e00cae8bb59932c8bf78
2020-12-23 04:45:55 -08:00
Samuel Susla a1e9a2d81e Avoid for loop in UIManager::getNewestCloneOfShadowNode
Summary:
Changelog: [internal]

The loop inside `UIManager::getNewestCloneOfShadowNode` is unnecessary as ancestorList already has index of the children.

Reviewed By: shergin

Differential Revision: D25681296

fbshipit-source-id: e8fab6c6d945064b0a7e63b6fd22697054fb7ea2
2020-12-23 04:45:54 -08:00
Samuel Susla 369b3d2983 Remove unused methods from LayoutableShadowNode
Summary:
Changelog: [internal]

These methods were not used, removing them.

Reviewed By: shergin

Differential Revision: D25680765

fbshipit-source-id: 7e44aa5b9c4ffa9d0264b573dcb7edc2ad2a74c3
2020-12-23 04:45:54 -08:00
Luna Wei 1c895678cf Separate out pickScale
Summary:
Changelog:
[Internal][Changed] - Separate `pickScale` implementation from AssetSourceResolver

Reviewed By: motiz88

Differential Revision: D25520686

fbshipit-source-id: 7c5845d5e6f130e719cf8725224589031037a61d
2020-12-23 01:12:58 -08:00
Samuel Susla eba31d2858 Back out "Cancel touches if surface touch handler can be prevented"
Summary:
Changelog: [internal]

Causes assert in `_updateTouches` to be fired.
Original commit changeset: 9e3cd4135138

Reviewed By: motiz88

Differential Revision: D25684453

fbshipit-source-id: a5394c622712e7b1c1c57cd663c2bba9161da333
2020-12-22 13:58:49 -08:00
Samuel Susla e5ecca39a8 Prevent crash when blurring an image
Summary:
Changelog: [internal]

Return original image instead of calling `abort()` when malloc fails.
Should we show a redbox? I don't think so, the redbox wouldn't be actionable for product engineer.

Reviewed By: PeteTheHeat

Differential Revision: D25678532

fbshipit-source-id: dd44d5e87198a0f76767ea40fe111ed347a7669a
2020-12-22 12:18:46 -08:00
Ramanpreet Nara bc0c5c98bb Move react-native-codegen/e2e/__tests__/modules/BUCK
Reviewed By: PeteTheHeat

Differential Revision: D25675408

fbshipit-source-id: 97f8070611f7f7707af9bd7dd9c9a59e8ad96125
2020-12-22 09:06:31 -08:00
empyrical f312e5ba84 Update iOS Fabric-related files to compile on OSS (#29810)
Summary:
Original PR contents:

This pull request updates the Podspecs and associated build scripts, and some source files so they build on OSS. RNTester now compiles with `fabric_enabled` again.

The following changes have been made:

 * Various spots that were pointing to the old `ReactCommon/fabric` location have now been updated to `ReactCommon/react/renderer`
 * Files that were attempting to use internal FB header `FBRCTFabricComponentsPlugins.h` were changed to use `RCTFabricComponentsPlugins.h`
 * `RCTFabricComponentsPlugins` in OSS was updated to include the `Image` fabric component (thanks tsapeta)
 * Replaced old `generate-rncore.sh` build script with new `generate-rncore.js` script which does not require `flow-node` and uses the `react-native-codegen` API directly, so there is no longer any need for an interim `schema-rncore.json` file.
 * Updated Yoga podspec which wasn't fully synced with changes from the main Yoga repo
 * Updated Fabric podspec with additional needed subspecs

Additions to PR by hramos:
* Replaced use of generate-rncore scripts with the original generate-native-modules-specs.sh script, which is now generate-specs.sh and supports both codegen for Native Modules and Components now (TurboModules/Fabric).
* Codegen now runs at build time as part of the Xcode build pipeline instead of as part of `pod install`. The build script is injected by the FBReactNativeSpec pod, as the pod is part of both Fabric and non-Fabric builds.

## Changelog

[General] [Fixed] - RNTester compiles with `fabric_enabled` again

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

Test Plan:
RNTester now compiles and runs in the simulator again when `fabric_enabled` is set to `true`.

```
cd xplat/js/react-native-github/packages/rn-tester
USE_FABRIC=1 pod install
open RNTesterPods.xcworkspace
# Build and run
```

Reviewed By: fkgozali

Differential Revision: D24058507

Pulled By: hramos

fbshipit-source-id: 8b2ea3694e6cb9aa23f83f087e2995fd4320e2bb
2020-12-22 08:36:22 -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
Ramanpreet Nara 331dc2a998 Default initialize RCTNetworking with observation disabled
Summary:
## Context
When you add/remove listeners from event emitters in JavaScript on iOS, we [call the NativeModule's addListener/removeListener methods](https://fburl.com/diffusion/4878jv6p). These addListener() and removeListener() methods [are implemented on the RCTEventEmitter class](https://fburl.com/diffusion/y913pqhy). All event emitters on iOS are subclasses of RCTEventEmitter.

The only purpose of calling RCTEventEmitter's addListener() and removeListener() methods is to call the [subclasses' startObservation, and stopObservation methods](https://fburl.com/diffusion/rpzyfppk), and [increment/decrement a listenerCount member variable](https://fburl.com/diffusion/ktl8if26) in RCTEventEmitter, which helps catch memory leaks.

RCTNetworking is a subclass of RCTEventEmitter, but it doesn't implement these startObserving/stopObserving methods. Since the [listenerCount is only used to show warnings](https://fburl.com/diffusion/i45lobil), in D24272560 (82187bfb6b), I disabled observation in RCTNetworking on the native side. Then in D24272663 (dabca52f77), I disabled RCTNetworking.addListener/removeListener NativeModule calls in JavaScript. This was gated via a QE/MC.

## Problem
The default initializer of RCTNetworking doesn't initialize with observation disabled. This broke antwerp when we shipped the experiment in D24272663 (dabca52f77). This diff fixes that problem.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25671343

fbshipit-source-id: d9a8ba5324a23ade8f4b0bf2ec093f3e4fb494dc
2020-12-21 16:18:23 -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