Commit Graph

21603 Commits

Author SHA1 Message Date
Ramanpreet Nara bccbf4d00a Round 3: Remove @synthesize bridge = _bridge from NativeModules
Reviewed By: fkgozali, ejanzer, mdvacca

Differential Revision: D25649765

fbshipit-source-id: 3ba6d977abce145039f6bdc581283c19445a1032
2020-12-19 06:01:48 -08:00
Ramanpreet Nara a26f20dc9a Codemod away from RCTBridge uiManager viewForReactTag
Summary: Changelog: [Internal]

Reviewed By: fkgozali, mdvacca

Differential Revision: D25648595

fbshipit-source-id: 7b338500e7d13ff12c9969663768408ede8e0ee3
2020-12-19 06:01:48 -08:00
Ramanpreet Nara 1a2d1dbae8 Attach RCTViewRegistry to NativeModules
Summary:
After this diff, NativeModules can synthesize the RCTModuleRegistry, and use that to query for UIViews of components, given their reactTags.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25645052

fbshipit-source-id: bb17606cc4862d07b739ef2c31a5e57f59201364
2020-12-19 06:01:48 -08:00
Ramanpreet Nara 86cdd88569 Integrate TurboModules with Venice's RCTSurfacePresenter
Summary:
After we create the RCTSurfacePresenter in Venice, we use it to create an RCTBridgelessComponentViewProvider, and pass it over to the RCTTurboModuleManager. In Venice, this allows all TurboModules to query components' UIViews given their reactTag.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25643261

fbshipit-source-id: 31da07c490d249534f700b7c8430e9cb43b5b0db
2020-12-19 06:01:48 -08:00
Ramanpreet Nara b71ebd10e5 Attach RCTViewRegistry to TurboModules
Summary:
Now, TurboModules that synthesize RCTModuleRegistry will have it available at runtime.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25643260

fbshipit-source-id: e9915f3da8412de823ae3d3e17849979c5cbd465
2020-12-19 06:01:47 -08:00
Ramanpreet Nara fced0765d6 Introduce RCTViewRegistry
Summary:
## Problem
Many of our NativeModules use the bridge to access the UIManager. They then use the UIManager to call viewForReactTag. This makes all these NativeModules Venice-incompatible. P155700869

## Solution
This diff introduces a Venice-compatible API called RCTViewRegistry that will implement viewForReactTag. When the bridge exists, RCTViewRegistry will delegate to the UIManager. When the bridge doesn't exist, it'll delegate to RCTSurfacePresenter. Fingers crossed, this should allow us move ~50 NativeModuels off the bridge.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25641391

fbshipit-source-id: 144f4f7a35af1245401ad640068852dd66bbf65d
2020-12-19 06:01:47 -08:00
Valentin Shergin fb4e06b1a5 Fabric: Introducing UIManagerCommitHook, unified way to alter commits
Summary:
The new UIManagerCommitHook can be used to implement commit-atering features without modifying the core.
E.g. State Reconciation seems can be implemented as a coomit hook but first we will use it for a new feature called Timeline (see the coming diffs).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25221312

fbshipit-source-id: dbe41b475bc8b36e1780d81447ab43b32758bdff
2020-12-18 16:01:30 -08:00
Valentin Shergin d2ae775bf7 Fabric: Introducing ShadowTreeDelegate::shadowTreeWillCommit()
Summary:
With the change, a new delegate method allows a receiver to alter a new (proposed) shadow tree with another tree by returning the altered tree.
We will it use in future diffs to implement Commit Hooks.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25221313

fbshipit-source-id: 9f83577d862b713fff71fa365ce660cc1de87c84
2020-12-18 16:01:30 -08:00
Javier Fraire 932c04cc99 Back out "Roll out RCTNetworking extraneous NativeModule call removal"
Summary:
It broke Forecast.

Original commit changeset: 0da20475a088

Changelog: [Internal]

Differential Revision: D25641098

fbshipit-source-id: 94daf0479963745bbca50b409b5a1dec1c8e8e71
2020-12-18 11:09:59 -08:00
Ron Edelstein c4cc636d9a Add autoglob to unbreak master
Reviewed By: mendoncakeegan

Differential Revision: D25633286

fbshipit-source-id: 69ca253a5494e0908d1091e7a01a404d4bbf24a8
2020-12-17 20:42:09 -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 0e0d2e84f5 Roll out RCTNetworking extraneous NativeModule call removal
Summary:
## Context
Every time we call RCTNetworking.sendRequest(), we [set up six event listeners inside XMLHttpRequest](https://fburl.com/diffusion/85k6ou5w) by calling RCTNetworking.addListener(). Seeing how RCTNetworking.addListener() is implemented, each call results in two async NativeModule call: [one to addListener()](https://fburl.com/diffusion/ng21jek6), and [another to removeEventListener()](https://fburl.com/diffusion/nua3y973).

For RCTNetworking, both of these NativeModule calls are unnecessary, as explained in D24272663 (https://github.com/facebook/react-native/commit/dabca52f77799bcdedb6b0ec44b1f6297483a46d)
> RCTNetworking.startObserving and RCTNetworking.stopObserving don't exist. The main purpose of RCTEventEmitter.addListener is to call these methods, and increment the _listeners counter, so that we can start dispatching events when _listeners > 0. In D24272560 (https://github.com/facebook/react-native/commit/82187bfb6b54fdffc5dadaa56e8bf97d2209708a), I made RCTEventEmitter dispatch events even when _listeners <= 0. This is sufficient for us to stop calling these two RCTNetworking methods entirely.

Therefore, this experiment gets rid of on average 6-8 NativeModule method calls for every network call we make in React Native on iOS.

Reviewed By: PeteTheHeat

Differential Revision: D25618704

fbshipit-source-id: 0da20475a0882ed737cf32de27f266fd2cd016af
2020-12-17 17:27:09 -08:00
Ramanpreet Nara 5275895af5 Roll out TurboModule block copy
Summary:
## Description
During TurboModule method invocation, when we convert JavaScript callbacks (i.e: jsi::Functions) into ObjC blocks inside the TurboModule jsi::HostObject, we [push them into an array](https://fburl.com/diffusion/r1n75ikx) that [gets cleared after the method gets invoked](https://fburl.com/diffusion/ubbvdmfs).

Prior to this experiment, we pushed these ObjC blocks into the array without copying them first. This goes contrary to ObjC best practices, which suggest that if you need to retain a block past its creation context for later invocation, you should defensively copy it to prevent it from being freed early. See the [Apple docs](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html#//apple_ref/doc/uid/TP40007502-CH5-SW1):
> Typically, you shouldn’t need to copy (or retain) a block. You only need to make a copy when you expect the block to be used after destruction of the scope within which it was declared. Copying moves a block to the heap.

The diff that introduced the fix: D23764329 (https://github.com/facebook/react-native/commit/9b76e217bb16935069f0ea5b60f4c4d9b73f86d6).

Reviewed By: PeteTheHeat

Differential Revision: D25617672

fbshipit-source-id: 24863b31a2d82c8d39a91c8ea8eb3a62724b800a
2020-12-17 17:27:09 -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 (https://github.com/facebook/react-native/commit/803a26cb003e6b790e3a1ab31beb0c95795fff0c) 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
Samuel Susla d51cc6b5e6 Implement default input accessory view for text input
Summary:
Changelog: [internal]

Fabric didn't implement default input accessory view.

Paper implementation: https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m?commit=1e2cd9ea1637&lines=589-629

Reviewed By: shergin

Differential Revision: D25612690

fbshipit-source-id: 7529c730211682bcffe17fdd4974e5df83c450d7
2020-12-17 10:52:23 -08:00
Ramanpreet Nara 18ea422e91 Show RedBoxes during promise resolve/reject errors
Summary:
Previously, we'd throw std::runtime_error objects when we invoked RCTPromiseResolveBlock and RCTPromiseRejectBlock. This would crash the app. Now, we'll just show RedBoxes. The RedBoxes also contain the name of the NativeModule, along with the method.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25549149

fbshipit-source-id: 33d5fc4480a577a1c17961c856ac42a9363b35f6
2020-12-17 10:29:41 -08:00
Ramanpreet Nara df0bfec201 Round 2: Remove synthesize bridge = _bridge
Summary:
All NativeModules that used to use the bridge to require other NativeModules now require other NativeModules via the Venice-compatible RCTModuleRegistry abstraction. Therefore, we can safely get rid of synthesize bridge = _bridge from them.

## How did I generate this diff?
1. Search for all NativeModules that have `synthesize bridge =`
2. Remove the `synthesize bridge = _bridge` from each NativeModule, and if it doesn't contain `_bridge`, `setBridge:`, or `elf.bridge`, add it to this codemod.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25551295

fbshipit-source-id: 585d50ad55cb9ab083e430b07e1cf30e31f0d3c5
2020-12-17 10:13:32 -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
Moti Zilberman 8c8172f143 Upgrade react/jsx-no-comment-textnodes lint to an error
Summary:
Upgrades the severity of the [`react/jsx-no-comment-textnodes`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md) lint rule from warning to error.

The higher severity is warranted because, in React Native code in particular, rendering an unintended text node is likely to throw an error at runtime (unless it happens to be wrapped in `<Text />`).

Furthermore, this lint is highly actionable because there's always a workaround that is less ambiguous:

1. If intending to write a comment (likely), wrap it in curly braces:
`<>{ /* this is a comment */ }</>`
2. If intending to write an actual text node beginning with `//` or `/*` (unlikely), wrap it in curly braces and quotes:
`<>{'/* this is a text node */'}</>`

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D25615642

fbshipit-source-id: d5a59989b04c244111071893efc546083641ac54
2020-12-17 08:49:04 -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
Valentin Shergin 98f1825f56 Fabric: Basic tests for zIndex and flattening
Summary:
Finally, a test for zIndex. Yay!

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25576920

fbshipit-source-id: daf8971f7d751e3316b89aae672fee4d25fe5b3e
2020-12-16 10:57:37 -08:00
Valentin Shergin 9a720ad47f Fabric: buildStubViewTreeWithoutUsingDifferentiator & buildStubViewTreeUsingDifferentiator
Summary:
After fixing `calculateShadowViewMutationsForNewTree` I realized that it will be even better to test Stacking Context and mutation instructions infra using both functions: `calculateShadowViewMutationsForNewTree` (used for testing) and the Differentiator itself. This diff implements it.

Now we have two similarly working functions with different implementations that we can use for testing Differentiator and other parts of the infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25576922

fbshipit-source-id: 7922e9ebfb9d6ef1792566554ba0c4a14f835ae2
2020-12-16 10:57:37 -08:00
Valentin Shergin 426b19073d Fabric: calculateShadowViewMutationsForNewTree now takes order-index into account
Summary:
Working on zIndex tests I found that calculateShadowViewMutationsForNewTree (that we use for testing) does not take zIndex into account. This fixes it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25576923

fbshipit-source-id: a71b3a4630430488c783cd5010c0fbb7273bdaa5
2020-12-16 10:57:37 -08:00
Valentin Shergin bc7a43b15e Fabric: Added yet another test for Stacking Context
Summary:
The test covers most props that must generate views.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25576921

fbshipit-source-id: df5bedb8f6d409b5142e472ca2edcb1953bee4e1
2020-12-16 10:57:37 -08:00
Mike c4950610e4 fix: First press not working after pull to refresh (#30291)
Summary:
According to https://github.com/facebook/react-native/issues/20011, the first onPress will not work after pull to refresh.

Dive into the code, found out that is because the state `isTouching` in `Libraries/Components/ScrollResponder.js` is not updated after the pull to refresh.

Update the `isTouching` state in `scrollResponderHandleResponderRelease` to fix this.

## 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] - First press not working after pull to refresh

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

Test Plan:
### Before
- The first onPress fail
![ezgif-4-c6aa5383e898](https://user-images.githubusercontent.com/48589760/97789482-cd4c4100-1bfb-11eb-8a6b-649e8a966b99.gif)
### After
- The first onPress success
![ezgif-4-195f9f6c302e](https://user-images.githubusercontent.com/48589760/97789488-da693000-1bfb-11eb-9a87-f005e61b8ad0.gif)

Eli:
I tested this myself internally using this code sample:

```
'use strict';

import PlaygroundRoute from 'PlaygroundRoute';
import type {SurfaceProps} from 'Surface';
import TetraText from 'TetraText';
import TetraView from 'TetraView';
import {TouchableOpacity, Text, View, ScrollView, RefreshControl, StyleSheet} from 'react-native';
import * as React from 'react';

type Props = SurfaceProps<PlaygroundRoute>;

class App extends React.Component<{}> {
  constructor() {
    super();
    this.state = {refreshing: true, items: []};
  }

  componentDidMount() {
    this.refresh();
  }

  refresh = () => {
    this.setState({
      refreshing: true,
      items: [],
    });

    setTimeout(
      () =>
        this.setState({
          refreshing: false,
          items: [0, 1, 2, 3, 4, 5],
        }),
      1500,
    );
  };

  renderItem = ({item}) => {
    return (
      <TouchableOpacity onPress={() => alert('pressed!')} key={`${item}`}>
        <Text style={{width: '100%', height: 48, backgroundColor: 'white'}}>
          {item}
        </Text>
        <View style={{width: '100%', height: 1, backgroundColor: 'gray'}} />
      </TouchableOpacity>
    );
  };

  render() {
    return (
      <View style={{flex: 1, padding: 48}}>
        <ScrollView
          style={{
            flex: 1,
            backgroundColor: '#aaa',
            borderColor: 'gray',
            borderWidth: 1,
          }}
          keyExtractor={item => `${item}`}
          refreshControl={
            <RefreshControl
              refreshing={this.state.refreshing}
              onRefresh={this.refresh}
            />
          }>
          {this.state.items.map(item => this.renderItem({item}))}
        </ScrollView>
      </View>
    );
  }
}

export default function Playground(props: Props): React.Node {
  return (
    <App />
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 10,
    paddingTop: 30,
  },
});
```

{F351458967}

Reviewed By: appden

Differential Revision: D25574927

Pulled By: TheSavior

fbshipit-source-id: 7abf8a2f947d94150419e51d46a19e792441c981
2020-12-16 10:14:02 -08:00
Ron Edelstein 9f05544b35 Explicitly set autoglob in bzl files
Reviewed By: strulovich

Differential Revision: D25537172

fbshipit-source-id: 6d1d0b1cab35059b8ed848d7c1de34c7e94347f7
2020-12-15 18:25:08 -08:00
Ramanpreet Nara ad75a3fbb0 Fix RCTBlobManager require inside RCTFileReaderModule
Summary:
RCTBlobManager actually has the name "BlobModule", not "BlobManager".

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25569865

fbshipit-source-id: f6b41300bda6485cef3f18d3d0308dad9c002b77
2020-12-15 15:15:11 -08:00
Samuel Susla 67309277fe Fix infinite loop in KeyboardAvoidingView
Summary:
Changelog: [General][Fixed] Fix stalling UI due to a bug in KeyboardAvoidingView

I introduced this bug in D22764192 (https://github.com/facebook/react-native/commit/b08fff6f869e00c20c0dcdf7aca71284c2f276f0).

The stalling was caused by onLayout in JavaScript triggering native layout which called onLayout in JavaScript without terminating condition.

The fix is to only cause native layout once from JavaScript's onLayout function. This makes sure both Fabric and Paper works correctly and UI stall isn't caused.

Resolves:
https://github.com/facebook/react-native/issues/30495
https://github.com/facebook/react-native/issues/30532

Reviewed By: TheSavior

Differential Revision: D25522362

fbshipit-source-id: 602e540bb1c40ae4f421b3e6ebc5a047cd920c17
2020-12-15 12:04:36 -08:00
simek 7485208498 Pressability: fix typo in variable, follow event check pattern, small tweak (#30151)
Summary:
This small PR introduces the following changes to the `Pressability`:
* fixes typo in internal `isActivationTransiton` variable name
* assigns `onPressMove` to variable before check and potential usage (this is the common pattern in this file)
* utilizes destructuring assignment to simplify passing coordinates to `_touchActivatePosition`

## Changelog

[Internal] [Fixed] - Pressability: fix typo in variable, follow event check pattern, small tweak

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

Test Plan: Successful `yarn test` run.

Reviewed By: kacieb

Differential Revision: D25545662

Pulled By: nadiia

fbshipit-source-id: 8d311fe21b485ee707e05dad120322b3027e686b
2020-12-15 11:50:02 -08:00
Valentin Shergin 5a4685b44e Fabric: A basic unit test for Stacking Context
Summary:
It tests some basic flattening operations. More tests are coming.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D25562529

fbshipit-source-id: 25978d97acdade8b6dc91c91fc227b6cbbd61899
2020-12-15 11:45:45 -08:00
Valentin Shergin 5d4514b492 Fabric: Small improvements in StubViewTree for more easier testing
Summary:
Added a couple of simple methods for quering view information.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D25562530

fbshipit-source-id: 697bea8d87c21d72475fb4896af3215f9279f34b
2020-12-15 11:45:45 -08:00
Ramanpreet Nara 0da02ab1ca Don't lookup TurboModules post-invalidation
Summary:
During cleanup, RCTNativeAnimatedModule [requires the RCTEventDispatcher](https://fburl.com/diffusion/0bnln893) to remove itself from the dispatcher a dispatch observer.

When the bridge is invalidated, if RCTEventDispatcher is has been cleaned up by then, we don't warn when this lookup fails: https://fburl.com/diffusion/rfioe5ay. This diff replicates that behaviour in the TurboModule infra.

Notes:
- In the legacy NativeModule infra, we can still query NativeModules post invalidation - we just won't create them. In the TurboModule infra, all requests for TurboModules from the TurboModuleManager start returning nil. Therefore, I simply did an early return inside TurboModuleManager moduleForName in the case that we're already invalidated. In addition to not displaying the warning, we just don't request/create the TurboModule in the first place.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25560228

fbshipit-source-id: 102dcc147bab6121daacdb39890bad48c0e60894
2020-12-15 11:20:28 -08:00
Mike Grabowski 42dde12aac Exclude i386 from valid architectures when building with Hermes on iOS (#30592)
Summary:
When building React Native application in Release mode for an iPhone Simulator _and_ targeting `armv7`, Xcode will build all architectures (due to `ONLY_ACTIVE_ARCH` set to `false`, unlike in Debug mode). As a result, Xcode will try building for `i386` (32-bit iPhone Simulator), which fails as we don’t build Hermes binaries for `i386`.

Fix is to disable `i386`, since it is not supported by `Hermes` and certain `Folly` features.

## Changelog

[IOS] [BREAKING] - `i386` architecture will be automatically disabled when Hermes is being used. This might be potentially breaking for your workflow if you target `armv7` devices, as you will no longer be able to test on the simulator.
[IOS] [FEATURE] - Replace `flipper_post_install` with `react_native_post_install` hook. Will automatically detect if Flipper is enabled.

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

Test Plan: Run React Native application with Hermes enabled (or Flipper) in Release mode and it should work just fine.

Reviewed By: appden

Differential Revision: D25564738

Pulled By: TheSavior

fbshipit-source-id: e786ab73fb0a77de5869cf9e5999726c7d29f1d4
2020-12-15 11:16:46 -08:00
Mike Grabowski e54ead6556 fix: default template on iOS (#30571)
Summary:
Recently introduced steps to run Hermes accidentally removed `!` from the `use_react_native`, causing `pod install` to fail with an error.

## Changelog

[INTERNAL] [iOS] - Fix Podfle in default template

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

Test Plan: Run `pod install` with this file and it should work.

Reviewed By: appden

Differential Revision: D25537263

Pulled By: TheSavior

fbshipit-source-id: da7f21775cbe641e34aded87a92c696539f4d5c3
2020-12-14 17:27:55 -08:00
Mike Grabowski fdcacd7f76 fix: building in release mode for simulator (#30543)
Summary:
Fixes https://github.com/facebook/react-native/issues/29984

Right now, running a React Native application with Xcode 12 in Release mode on an iPhone Simulator will fail with something like below:

> [some file path], building for iOS Simulator, but linking in object file built for iOS, file '[some file path]' for architecture arm64

The best explanation of this issue has been provided by alloy in https://github.com/facebook/react-native/issues/29984:

> This issue has started coming up with Xcode 12 and support for the new ARM based Macs, as `arm64` now no longer can be assumed to _only_ be for iOS devices. This means Xcode 12 will now also build for `arm64` simulator SDKs and it has become ambiguous if an arch slice in a prebuilt binary is meant for a simulator or device.
>
> In any case, for now this means that you can configure your Xcode project to exclude `arm64` when building for any iOS simulator SDK.

This PR implements aforementioned workaround.

## Changelog

[FIX] [IOS] - Fix running React Native project with Xcode 12 in Release on iPhone Simulator

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

Test Plan: Switch your scheme to Release and run the app on simulator. Will complete w/o issues.

Reviewed By: appden

Differential Revision: D25537295

Pulled By: TheSavior

fbshipit-source-id: 2dc05cb80e59f1d95d2a84ab55ed6a5b5446411c
2020-12-14 14:08:33 -08:00
Peter Argany 687ddf0f32 Downgrade TurboModule crash to warning
Summary:
This is to address a UBN blocking FBiOSv300 rollout. A TM is attempting to invoke a promise more than once and crashing. We can't find the TM, so downgrading this to a warning to unblock the release.

Plan going forward:
- Replace this with some better logging to try and identify the culprit module.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D25539676

fbshipit-source-id: 5b75b71110eaa393378049de6e0d9a77e6328831
2020-12-14 12:58:29 -08:00
Valentin Shergin 18149e4fa8 Fabric: Asserts in RCTMountingManager ensuring that props are not null
Summary:
We see crashes in `updateProps:oldProps:` methods in several components, and we suspect it might happen because of the props object being null.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25535605

fbshipit-source-id: f278a5cec47b7fd54d31d015427fa918c02d913b
2020-12-14 11:16:06 -08:00
Valentin Shergin af4edbb8c0 Fabric: Asserts in [RCTImageComponentView updateState:oldState:]
Summary:
We see crashes in this method, so we need asserts to understand why exactly it happens.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25535606

fbshipit-source-id: 8b0d275825a028f51343e4ab91682c8299904e8d
2020-12-14 11:16:06 -08:00
Jesse Katsumata 3cebd35b95 (eslint-config): update eslint-plugin-react-native (#30350)
Summary:
Currently, installing `react-native-community/eslint-config` with projects using eslint v7 causes the following warning

```
warning "react-native-community/eslint-config > eslint-plugin-react-native@3.8.1" has incorrect peer dependency "eslint@^3.17.0 || ^4 || ^5 || ^6".
```

This PR updates the eslint-plugin-react-native module to suppress the warning

## 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] [Changed] - update eslint-plugin-react-native for community eslint-config

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

Test Plan: eslint working without error with projects using eslint v7

Reviewed By: GijsWeterings

Differential Revision: D25480912

Pulled By: nadiia

fbshipit-source-id: 2a956070e5bb75168d68501f9ec9486a34011349
2020-12-14 06:12:34 -08:00
Valentin Shergin 272ef6b86f Fabric: AccessibilityProps::testId mapped to testID and implemented for iOS
Summary:
This should make `testID` prop work as it works in pre-Fabric renderer on iOS.
On Android it should already work fine.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D25524890

fbshipit-source-id: 3f25eb427d4449abaab790099546be18ae573f98
2020-12-13 22:36:10 -08:00
Ramanpreet Nara ff980050c9 Manual: Migrate from bridge.accessibilityManager to RCTModuleRegistry
Summary:
Ran `xbgs .accibilityManager`, and found all the NativeModules that used the bridge to access AccessibilityManager. Then, I migrated them to use RCTModuleRegistry.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25504726

fbshipit-source-id: fcfb1fffbeedc136ee160d043949d9859300b1e3
2020-12-12 19:02:04 -08:00
Ramanpreet Nara 6c3dd87ef1 Manual: Migrate from bridge.moduleForName to RCTModuleRegistry
Summary:
All NativeModules that use `[RCTBridge moduleForName:]` to access other NativeModules are now instead using the Venice-compatible RCTModuleRegistry to access other NativeModules.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25508910

fbshipit-source-id: 85fc390063af264f2f2843e5640fa7336a784ab4
2020-12-12 19:02:04 -08:00
Ramanpreet Nara 282b1a880f Manual: Migrate from bridge.moduleForClass to RCTModuleRegistry
Summary:
All NativeModules that use `[RCTBridge moduleForClass:]` to access other NativeModules are now instead using the Venice-compatible RCTModuleRegistry to access other NativeModules.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25508277

fbshipit-source-id: 1b415a5ad4055290940879e100ceaa84ae83feeb
2020-12-12 19:02:04 -08:00
Ramanpreet Nara 938bfed96d Manual: Migrate from bridge.redBox to RCTModuleRegistry
Summary:
Ran `xbgs .redBox`, and found all the NativeModules that used the bridge to access RedBox. Then, I migrated them to use RCTModuleRegistry.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D25507829

fbshipit-source-id: 91033ca4c57d5be5e8e6fa904b636960ec12c584
2020-12-12 19:02:03 -08:00
Ramanpreet Nara 60641c543d Manual: Migrate from bridge.devSettings to RCTModuleRegistry
Summary:
Ran `xbgs .devSettings`, and found all the NativeModules that used the bridge to access DevSettings. Then, I migrated them to use RCTModuleRegistry.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25503402

fbshipit-source-id: 26afc45cd1bc63d5de99ea331e7b2949b66be7ce
2020-12-12 19:02:03 -08:00
Ramanpreet Nara 41929eb9c5 Codemod: Migrate from bridge.devSettings to RCTModuleRegistry
Summary:
All NativeModules that access the _bridge from self to require the DevSettings NativeModule now instead get the DevSettings NativeModule from the _moduleRegistry.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25503289

fbshipit-source-id: ebd1fd45d40aca37c0ead83bbaab59fa99d45044
2020-12-12 19:02:03 -08:00
Ramanpreet Nara c7e1355dec Manual: Migrate from bridge.webSocketModule to RCTModuleRegistry
Summary:
All NativeModules that access the _bridge from self to require the WebSocketModule NativeModule now instead get the WebSocketModule NativeModule from the _moduleRegistry.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25500433

fbshipit-source-id: 21aebc5684dd6a058de4e35b042c9fb255ffcb33
2020-12-12 19:02:03 -08:00
Ramanpreet Nara e1fea9d152 Manual: Migrate from bridge.devMenu to RCTModuleRegistry
Summary:
Ran xbgs `.devMenu`, and found all the NativeModules that used the bridge to access DevMenu. Then, I migrated them to use RCTModuleRegistry.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25499960

fbshipit-source-id: 70478616d44808f3788dd0b194da155db0877db9
2020-12-12 19:02:03 -08:00