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

3491 Коммитов

Автор SHA1 Сообщение Дата
Xin Chen 55392f65a6 Fix issue with setting shadow node state data after scrolling programmatically
Summary:
This issue is found when investigating T101563978 with IOS platform. When animation is off, the x position measurement is off after `scrollToItem` is called.

The android fix is checked in at D31492685 (1a9e2d5d55). For IOS, the correct state data is updated only for animated cases, but not for instant scroll cases. This diff unified them.

Changelog
[IOS][Fixed] Fixed an edge case when scroll to item/index is called without animation, the offset position is not updated. This caused the measurement of the position to be wrong.

Reviewed By: sammy-SC

Differential Revision: D31564169

fbshipit-source-id: 89f47d8054afb03c2ace1d595163b160e5bb2036
2021-10-12 17:43:26 -07:00
Neil Dhar aae93553d0 Remove libstdc++ dependency (#32247)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32247

I don't think we need both libc++ and libstdc++.

allow-large-files

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30950943

fbshipit-source-id: d0669815ff59c3e9ac45954a4a11930d1bc3959f
2021-10-08 14:16:54 -07:00
Samuel Susla c99a0212a0 Fix failing assert in EventTarget
Summary:
changelog: [internal]

calling `setEnabled(true)` needs to have a matching `setEnabled(false)` in order for `eventTarget_` to be deallocated correctly.

Also, retaining `eventTarget_` longer, does not mean instanceHandle will be available later on.

Reviewed By: p-sun

Differential Revision: D31503119

fbshipit-source-id: 324e16fe0f6ad937ab2c38be9a536bdf14851172
2021-10-08 13:44:37 -07:00
Lulu Wu c901c43d11 Remove shared responsibility between LogBox and ExceptionsManager native module
Summary:
## Context
Right now we are using both LogBox and ExceptionsManager native module to report JS errors in ExceptionsManager.js, from below code we can tell they have some overlapping - when ```__DEV__ === true``` both could report the error.

https://www.internalfb.com/code/fbsource/[5fb44bc926de87e62e6e538082496f22017698eb]/xplat/js/react-native-github/Libraries/Core/ExceptionsManager.js?lines=109-141

## Changes
In this diff overlapping is removed: in ```ExceptionsManager.js``` LogBox will be responsible for showing the error with dialog when ```__DEV__ === true```, when it's prod we'll use ExceptionsManager native module to report the error. As a result LogBox and ExceptionsManager native module don't share responsibilities any more.

Changelog:
[General][Changed] - Remove shared responsibility between LogBox and ExceptionsManager native module

Reviewed By: philIip

Differential Revision: D30942433

fbshipit-source-id: 8fceaaa431e5a460c0ccd151fe9831dcccbcf237
2021-10-08 11:08:43 -07:00
Brent Kelly 25a2c608f7 Addressing various issues with the Appearance API (#28823) (#29106)
Summary:
This PR fixes a few issues with the Appearance API (as noted here https://github.com/facebook/react-native/issues/28823).

1. For the Appearance API to work correctly on Android you need to call `AppearanceModule.onConfigurationChanged` when the current Activity goes through a configuration change. This was being called in the RNTester app but not in `ReactActivity` so it meant the Appearance API wouldn't work for Android in newly generated RN projects (or ones upgraded to the latest version of RN).

2. The Appearance API wasn't working correctly for brownfield scenarios on Android. It's possible to force an app light or dark natively on Android by calling `AppCompatDelegate.setDefaultNightMode()`. The Appearance API wasn't picking up changes from this function because it was using the Application context instead of the current Activity context.

3. The Appearance API wasn't working correctly for brownfield scenarios on iOS. Just like on Android its possible to force an app light or dark natively by setting `window.overrideUserInterfaceStyle`. The Appearance API didn't work with this override because we were overwriting `_currentColorScheme` back to default as soon as we set it.

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

### Fixed

https://github.com/facebook/react-native/issues/28823

* [Android] [Fixed] - Appearance API now works on Android
* [Android] [Fixed] - Appearance API now works correctly when calling `AppCompatDelegate.setDefaultNightMode()`
* [iOS] [Fixed] - Appearance API now works correctly when setting `window.overrideUserInterfaceStyle`

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

Test Plan: Ran RNTester on iOS and Android and verified the Appearance examples still worked [correctly.](url)

Reviewed By: hramos

Differential Revision: D31284331

Pulled By: sota000

fbshipit-source-id: 45bbe33983e506eb177d596d33ddf15f846708fd
2021-10-05 20:23:48 -07:00
CodemodService FBSourceClangFormatLinterBot 2372e7a008 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31362458

fbshipit-source-id: e26b6b5e1c99dd6adbd661240d6979160633c10b
2021-10-02 08:33:02 -07:00
Phillip Pan d8931e2f94 provide public hook to programatically turn on voiceover
Summary:
Changelog: [Internal]

https://fb.workplace.com/groups/rn.support/posts/6677051292343429

ax team is building a tool to extract information about the views for design reviewers, and RN has some AX information that is not working atm because of dependency on whether voiceover is on or not. so, this will give them the ability to programmatically set that field and hopefully be able to get accurate ax info

Reviewed By: ikenwoo

Differential Revision: D31010566

fbshipit-source-id: 4c8a33fce40266b270dd5994442c8472ca88f5dd
2021-10-01 21:17:07 -07:00
Sota Ogo 8595f3f22c Back out "Feature: ScrollView `automaticallyAdjustKeyboardInsets`"
Summary:
Original commit changeset: 9ccfb4b6d477 / D30015799 (6e903b07fa)

The diff caused a redbox/error in some products. Reverting now and will try it again.

Changelog: Backing out PR: 31402

Differential Revision: D31238961

fbshipit-source-id: b2ccd3d3ab9d7e764e41fb54d8a7e60882d1405f
2021-09-28 14:05:00 -07:00
Samuel Susla 8d0a2e7921 Stop subview clipping recursion at RCTScrollViewComponentView component
Summary:
changelog: [internal]

Prevent `RCTScrollViewComponentView`'s children from being clipped by stopping clipping recursion.

Reviewed By: fkgozali

Differential Revision: D31196948

fbshipit-source-id: 09548ade9cf993730784f544b565b9fde77a6ee4
2021-09-26 12:15:38 -07:00
Marc Rousavy 6e903b07fa Feature: ScrollView `automaticallyAdjustKeyboardInsets` (#31402)
Summary:
Currently, ScrollViews provide the prop `keyboardDismissMode` which lets you choose `"interactive"`. However when the keyboard is shown, it will be rendered above the ScrollView, potentially blocking content.

With the `automaticallyAdjustKeyboardInsets` prop the ScrollView will automatically adjust it's `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) props to push the content up so nothing gets blocked.

* The animation curve and duration of the Keyboard is exactly matched.
* The absolute position of the ScrollView is respected, so if the Keyboard only overlaps 10 pixels of the ScrollView, it will only get inset by 10 pixels.
* By respecting the absolute position on screen, this automatically makes it fully compatible with phones with notches (custom safe areas)
* By using the keyboard frame, this also works for different sized keyboards and even `<InputAccessoryView>`s
* This also supports `maintainVisibleContentPosition` and `autoscrollToTopThreshold`.
* I also fixed an issue with the `maintainVisibleContentPosition` (`autoscrollToTopThreshold`) prop(s), so they behave more reliably when `contentInset`s are applied. (This makes automatically scrolling to new items fully compatible with `automaticallyAdjustKeyboardInsets`)

## Changelog

* [iOS] [Added] - ScrollView: `automaticallyAdjustKeyboardInsets` prop: Automatically animate `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) to avoid the Keyboard. (respecting absolute position on screen and safe-areas)
* [iOS] [Fixed] - ScrollView: Respect `contentInset` when animating new items with `autoscrollToTopThreshold`, make `automaticallyAdjustKeyboardInsets` work with `autoscrollToTopThreshold` (includes vertical, vertical-inverted, horizontal and horizontal-inverted ScrollViews)

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

Test Plan:
<table>
<tr>
<th>Before</th>
<th>After</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708680-9700aa80-a370-11eb-8016-e75d81a92cd7.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708699-9b2cc800-a370-11eb-976f-c4010cd96d55.MP4

</td>
</table>

### "Why not just use `<KeyboardAvoidingView>`?"

<table>
<tr>
<th>Before (with <code>&lt;KeyboardAvoidingView&gt;</code>)</th>
<th>After (with <code>automaticallyAdjustKeyboardInsets</code>)</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708749-abdd3e00-a370-11eb-8e09-a27ffaef12b8.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708777-b3044c00-a370-11eb-9b7a-e040ccb3ef8c.MP4

</td>
</table>

> Also notice how the `<KeyboardAvoidingView>` does not match the animation curve of the Keyboard

### Usage

```jsx
export const ChatPage = ({
  flatListProps,
  textInputProps
}: Props): React.ReactElement => (
  <>
    <FlatList
      {...flatListProps}
      keyboardDismissMode="interactive"
      automaticallyAdjustContentInsets={false}
      contentInsetAdjustmentBehavior="never"
      maintainVisibleContentPosition={{ minIndexForVisible: 0, autoscrollToTopThreshold: 100 }}
      automaticallyAdjustKeyboardInsets={true}
    />
    <InputAccessoryView backgroundColor={colors.white}>
      <ChatInput {...textInputProps} />
    </InputAccessoryView>
  </>
);
```

## Related Issues

* Fixes https://github.com/facebook/react-native/issues/31394
* Fixes https://github.com/facebook/react-native/issues/13073

Reviewed By: yungsters

Differential Revision: D30015799

Pulled By: sota000

fbshipit-source-id: 9ccfb4b6d477da192a96db4cfa07c31a2d2cefcb
2021-09-24 18:46:00 -07:00
Joshua Gross 10fe09c456 Back out "Send unix timestamp for touch events instead of systemUptime"
Summary:
Original commit changeset: 2acd52ae5873

This original change was made in D26705430 (b08362ade5) and D26705429 (69feed518d). The intention was to change the timestamp definition to make touch telemetry easier, but this is (1) unnecessary and (2) causes other issues.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D31183734

fbshipit-source-id: 6af669bb5696896b43fa4508af1171446d62c6d6
2021-09-24 18:11:33 -07:00
Phillip Pan 99f706e5df introduce RCTComputeScreenScale
Summary:
Changelog: [Internal]

in this diff, we add a function that allows us to retrieve screen scale. enforcing thread safety will be dependent on the consumer to make sure it's used on main thread.

i'd like for this to be a more temporary solution, i think we should have a more scalable screen solution for consumers to handle the gambit of uiscreen use cases.

Reviewed By: sammy-SC

Differential Revision: D31163909

fbshipit-source-id: 78104e9ef982b47c60697461141afb4b06eede72
2021-09-24 16:59:29 -07:00
Phillip Pan c744528da1 fix inaccurate comment for RCTScreenSize()
Summary:
Changelog:
[iOS][changed] - fixed inaccurate comment

while looking around, i saw this comment for RCTScreenSize that says it's called on app start - i looked around and also put a breakpoint here, and this assumption doesn't seem accurate anymore. just updating the comment for clarity.

Reviewed By: sammy-SC

Differential Revision: D31136182

fbshipit-source-id: 5f02a1a9fd95e16495bb79b3645b5f4e3bc1d9c9
2021-09-24 16:59:29 -07:00
CodemodService FBSourceClangFormatLinterBot 1a1c3a6405 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31138547

fbshipit-source-id: ba134ae7f057c918eaefdc6310f7663e187e9749
2021-09-23 07:54:31 -07:00
Muhammad Numan 01856633a1 feat: add cancelButtonTintColor props in ActionSheetIOS for change cancel button tint color (#31972)
Summary:
we need to change the text color of the cancel button in `ActionSheetIOS` but `tintColor` changes the all button text color except `destructiveButtonIndex`

so I have added `cancelButtonTintColor` prop to change only the text color of the cancel button

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

[General] [Changed] - added `cancelButtonTintColor` prop for `ActionSheetIOS` to change only the text color of the cancel button

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

Test Plan:
With this PR you can change the cancel text button of `ActionSheetIOS` by this `cancelButtonTintColor` prop

| <img src="https://user-images.githubusercontent.com/36044436/128414537-c4454786-a5cf-49d2-8225-1ff26c9c5058.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414549-74a21509-711e-48e0-baf1-3718beae1598.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414559-4bee9d1a-ac9f-4cd2-b158-5c4c441158ec.png"  /> |
|-|-|-|

Reviewed By: lunaleaps

Differential Revision: D30878022

Pulled By: yungsters

fbshipit-source-id: c70204f9f2510c75d8e9bed4e0fba79f1c941a1f
2021-09-22 10:44:17 -07:00
Kudo Chien e2b5b6504c Propose to connect metro server programmatically (#31828)
Summary:
nowadays, we could only specify metro server by either dev settings or building time ip.txt.
this pr adds a new way to specify metro server programmatically which makes rn launcher or testing more feasible.

## Changelog

[Internal] [iOS] [Added] - Propose to connect metro server programmatically

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

Test Plan:
just exposing a public interface for RCTPackagerConnection without much code change.
test to call this interface success locally.

Reviewed By: sammy-SC

Differential Revision: D30878774

Pulled By: yungsters

fbshipit-source-id: 5f1d6a4835a983abde7e095d20153e4ba2146a61
2021-09-22 10:40:06 -07:00
Ken Tominaga 398595e074 Remove iOS 11 version check (#32151)
Summary:
This pull request aims to remove iOS 11 version check which is no longer needed.

The minimum iOS deployment target for React Native is `iOS 11` but we still have iOS 11 version check like below.

```
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
        if (available(iOS 11.0, *)) {
```

> React Native apps may target iOS 11.0 and Android 5.0 (API 21) or newer.

ref: https://github.com/facebook/react-native#-requirements

------

If there is a team motivation to remove the deprecated methods and classes before iOS 10, I can continue the work in this pull request or in the continuing pull requests.

We have deprecated warnings for these in the project.

- `UIUserNotificationSettings`
- `UILocalNotification`
- `topLayoutGuide` and `bottomLayoutGuide`
- `automaticallyAdjustsScrollViewInsets`

## Changelog

[iOS] [Changed] - Remove iOS 11 version check

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

Reviewed By: sammy-SC

Differential Revision: D30877917

Pulled By: yungsters

fbshipit-source-id: d903ea5d557beeb65ef87bfce572e4db3532b3c5
2021-09-22 10:37:09 -07:00
Samuel Susla 3d83ca0331 Ship initial max size on iOS
Summary:
changelog: [internal]

Ship initial max size on iOS

Reviewed By: fkgozali

Differential Revision: D30990650

fbshipit-source-id: cf8f202ee862145a6fa9f173c2073096f86015e3
2021-09-21 08:23:08 -07:00
Pieter De Baets 6025611bd0 Use real propsParserContext in LayoutAnimation
Summary: Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D31053819

fbshipit-source-id: 8ec21012500f3bfc7e8aea018b5ca72323da2d9e
2021-09-21 04:24:28 -07:00
Radek Pietruszewski c0e04460f5 Time out packager liveness check after 10s (#31367)
Summary:
`isPackagerRunning` check on iOS makes a http request to packager's /status endpoint to check if it's alive... The problem is if the packager can't be reached, but doesn't error out immediately. This can happen, for example, if running the app on device, and host computer's firewall doesn't allow a :8081 connection. In that case, the request will never succeed or fail until default timeout of 60s. It makes debugging the underlying issue quite unbearable. It's hard for me to imagine a legitimate packager connection that wouldn't respond in less than a second, so I propose a conservative timeout of 10s

## Changelog

[iOS] [Fixed] - Don't hang app for 60s if packager can't be reached

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

Test Plan: Checked my app in dev mode to see if packager connects properly.

Reviewed By: sammy-SC

Differential Revision: D30912047

Pulled By: charlesbdudley

fbshipit-source-id: 110743dc45b9cc7d30e49f79ce3b0d5986f7aebd
2021-09-20 13:29:27 -07:00
Ramanpreet Nara 564b944e56 Ensure RCTJSThread is initialized in Bridgeless mode
Summary:
## Context
When Venice is enabled app-wide, we won't be creating/initializing the bridge. This means that RCTBridge +(void)initialize; won't execute:

https://www.internalfb.com/code/fbsource/[d8b25a1907ee55baa21e02a69ecab0f7a9442b8e]/xplat/js/react-native-github/React/Base/RCTBridge.m?lines=167%2C171-180

## Problem
When RCTBridge initialize isn't executed, we won't initialize RCTJSThread to kCFNull. RCTJSThread will be nil.

NativeModules like RCTEventDispatcher use RCTJSThread to indicate that their methods must be executed on the JavaScript thread:

https://www.internalfb.com/code/fbsource/[44976912ae618619a394f063c4c942ef020b86e8]/xplat/js/react-native-github/React/CoreModules/RCTEventDispatcher.mm?lines=198-201

If RCTJSThread is nil, these NativeModules will fail to initialize w/ the TurboModule system:

https://www.internalfb.com/code/fbsource/[f6a04f529ac1354b2973bd3553d12aef28ff24f2][blame]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm?lines=584-589%2C595%2C599%2C610-618

How:
1. The TurboModuleManager will see that each of these NativeModules has a methodQueue getter (line 587 above).
2. It'll invoke that getter (line 588), and get a nil methodQueue out, when **that methodQueue should be kCFNull**.
3. Because the TurboModuleManager gets a nil method queue from the getter, !methodQueue will pass (line 595).
4. So, TurboModuleManager try to create and assign a method queue to these modules (line 611), which'll raise an error (line 613), because none of these modules synthesize the methodQueue (b/c they expose a getter to methodQueue instead).

## Changes
We need to initialize RCTJSThread to kCFNull in all cases, to prevent this breakage. So, I moved RCTJSThread into its own header: RCTJSThread.h. RCTJSThread.h exports a function that initializes the RCTJSThread constant: _RCTInitializeJSThreadConstantInternal. This function gets invoked inside RCTHost initialize, and RCTBridge initialize.

Created from CodeHub with https://fburl.com/edit-in-codehub

Changelog: [Internal]

Reviewed By: p-sun, mdvacca

Differential Revision: D30910515

fbshipit-source-id: 2dd9b0cfcda92c497bb497f12f9fb847da563f47
2021-09-19 16:23:53 -07:00
Samuel Susla 6c66cef8ec Show warning if TTRC flag may clipped
Summary: changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D31016886

fbshipit-source-id: 26b5b97382936141ae7ef69fb1701d9822df5e8c
2021-09-17 14:23:54 -07:00
Tim Yung 5683932862 RN: Fix NSInvalidArgumentException for Invalid Font Family Name
Summary:
We observed that in certain production scenarios, `[UIFont fontNamesForFamilyName:familyName]` returns `nil`.

This is problematic because we cannot insert `nil` (which is not an object type) into `NSCache`. Currently, this is causing `NSInvalidArgumentException` to be thrown.

This fix works around the problem by guarding against `nil`.

Changelog:
[iOS][Fixed] - Fix NSInvalidArgumentException for invalid font family names.

Reviewed By: fkgozali

Differential Revision: D31011394

fbshipit-source-id: a9eb9ce69efd832acca65787c665fcbb7b42a795
2021-09-16 23:23:33 -07:00
Kevin Gozali b0c8a4eee8 Link RCT-Folly against libc++abi
Summary:
Folly now depends on libc++abi. This solves linker error for RCT-Folly.podspec like this:

```
Undefined symbols for architecture arm64:
  "___cxa_increment_exception_refcount", referenced from:
      folly::exception_ptr_get_type(std::exception_ptr const&) in libRCT-Folly.a(Exception.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

See https://github.com/react-native-community/releases/issues/251

Note: RNTester was not affected by this bug for some reason, so the only way to verify is via the new app generated via `npx react-native init`.

Changelog: [Fixed][iOS] Unbreak Folly linker error

Reviewed By: lunaleaps

Differential Revision: D30950944

fbshipit-source-id: 3eb146e23faa308a02363761d08849d6801e21ca
2021-09-16 22:24:10 -07:00
Jimmy Zhang a8cd8f7696 Setup a new macro to gate the core packager functionality
Summary:
Changelog:
* Rename `ENABLE_PACKAGER_CONNECTION` macro to a more appropriate name `RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION` to reflect this is only used in RCT_DEV_SETTINGS

* Introduce `RCT_PACKAGER_LOADING_FUNCTIONALITY` that can be separate from `RCT_DEV_MENU`, by default, it equals to `RCT_DEV_MENU`

Reviewed By: fkgozali

Differential Revision: D30546025

fbshipit-source-id: f409c02dc1486041d7db5abdbf7eb482520fa171
2021-09-13 12:09:12 -07:00
Ramanpreet Nara 801909be5b Disable TurboModulManagerDelegate locking by default
Summary:
This diff disables the TurboModuleManager delegate locking by default in the TurboModule system.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30862260

fbshipit-source-id: 917c1e5862c69a753e33813705eead0e97cf5e9a
2021-09-13 02:32:20 -07:00
Samuel Susla d2cc91bcc3 Add a way to simulate memory access to ImageProps in LayoutAnimations
Summary:
changelog: [internal]

I'm chasing down a crash in LayoutAnimations, it would help me to simulate the memory access which causes the crash to learn where the bad memory is coming from.

Reviewed By: RSNara

Differential Revision: D30776840

fbshipit-source-id: 1e97fac28ba2df37ba3e47ec2c110043c3823e70
2021-09-12 08:56:32 -07:00
Samuel Susla 24b961b6f7 Add option to crash the app if component descriptor is missing in LayoutAnimations
Summary:
changelog: [internal]

Add a log behind feature flag to learn more about missing component descriptor.

Component descriptor should never be missing, that's a state of program that is impossible as far as I can tell. This logic was introduced in D22216030 (6342e6e3f1) and I think it is just cover the real cause of crashes in LA on iOS.

Reviewed By: RSNara

Differential Revision: D30765947

fbshipit-source-id: 6843384e02529de2f024c59c61ae21b8682ac371
2021-09-11 00:26:27 -07:00
Héctor Ramos ef6ad1f2d6 Codegen: Remove generate-specs.sh
Summary:
First part of the codegen script cleanup effort. Everything that was done in generate-specs.sh is now part of the CocoaPods recipe (e.g. codegen method in `react_native_pods.rb`).

Now that `generate-specs.sh` has been removed, the codegen may still be invoked manually for test purposes like so:

```
cd react-native

# Generate Schema - do this whenever your JS specs change
node packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js <output_file_schema_json> <javascript_sources_dir>

# Generate native interfaces for iOS (use schema.json generated by previous step)
node scripts/generate-specs-cli.js ios <output_file_schema_json> <output_dir> <library_name>
```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30648067

fbshipit-source-id: 29688e0aac5496886657db82becb05bc8da076c9
2021-09-10 17:28:55 -07:00
Samuel Susla ae4068d63c Add option to skip invalidated key frames
Summary:
changelog: [internal]

Maybe invalid keyframe animation shouldn't be queued. This adds a fix behind feature flag to verify if it fixes iOS crashes.

Reviewed By: RSNara

Differential Revision: D30730005

fbshipit-source-id: 8a2bb54c449449a95d14d51a1a78bfaccad61877
2021-09-09 11:57:24 -07:00
Ramanpreet Nara e36bfef0f1 Conditionally disable TurboModuleManager delegate locking
Summary:
## Context
Whenever the TurboModuleManager calls into its delegate, it [acquires a lock](https://www.internalfb.com/code/fbsource/[f14548634e72009989c844a2ef025915ef74159e]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm?lines=429%2C513). We initially introduced this mutex (in D21170099 (2c473e1a38)). It serializes access to the TurboModuleManager delegate during TurboModule create.

## Problems
- When we call into the delegate, we acquire a lock, and call into arbitrary product code: getModuleClassFromName, getModuleInstanceFromClass. If any of these two product methods create another TurboModule, the application will deadlock, because we'll acquire the same std::mutex twice.

## Fix
The delegate methods of TurboModuleManager are usually implemented as [switch cases over the NativeModule names or NativeModule classes](https://www.internalfb.com/code/fbsource/[f015e461de4e7a18d0d52a697a53086fe6a3b91c]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=1481-1488%2C1490-1537%2C1539-1577). So, it should be safe to call into them concurrently for two different modules.

So, while we could fix the problem by migrating the TurboModuleManager to an std::recursive_mutex, one could make an argument that this locking shouldn't even be necessary in the first place. We don't have this locking in the Android TurboModule system.

## Changes
This diff introduces a flag in React Native that allows to to safely remove this TurboModuleManager delegate locking in production.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30754875

fbshipit-source-id: d04a831c18a2a8b46e9bc07ddf690d8e4d0be8e0
2021-09-08 12:53:17 -07:00
Ramanpreet Nara 7243517481 Give RCTSurfaceHostingProxyRootView access to the bridgeless RCTModuleRegistry
Summary:
## Context
In bridgeless mode, RCTRootView is actually an instance of RCTSurfaceHostingProxyRootView.

A lot of code that uses RCTRootView uses its RCTEventDispatcher or RCTModuleRegistry properties. Both of properties reach into the bridge, which means these APIs only work in bridge mode.

## Changes
- Give RCTSurfaceHostingProxyRootView access to the bridgeless RCTModuleRegistry, in bridgeless mode.

## Benefits
- This makes the RCTEventDispatcher and RCTModuleRegistry properties of RCTSurfaceHostingProxyRootView work in bridgeless mode. This allows us to eliminate branching in native code that uses these properties. Diffs incoming.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D30753829

fbshipit-source-id: 0815f8ae5507686bd5aff20a3abc1843533bb132
2021-09-08 12:46:35 -07:00
Ramanpreet Nara 5a44c596b6 Move RCTModuleRegistry attachment into React Native initialization layer
Summary:
## Context
RCTModuleRegistry allows NativeModules to require other NativeModules, regardless of if they're using the old or the new system.

## Problems
Currently, the TurboModuleManager owns the RCTModuleRegistry. This results in the following ownership diagram:
{F660246242}

As you can see, for the bridge case, we're maintaining two *different* RCTModuleRegistry objects, both of which maintain a backward reference to the bridge and the TurboModuleManager.

## Changes
If we stop having TurboModuleManager own the RCTModuleRegistry, and just have React Native's initialization layer attach it to NativeModules, then we can simplify the above ownership diagram to this:
{F660246285}

## Benefits
- Less complicated design for RCTModuleRegistry
- RCTModuleRegistry understands the old and the new NativeModule system. So, it makes more sense for RCTModuleRegistry to be owned by the bridge, which also understands the old and the new NativeModule system.
- **Actual Motivation:** This allows us to start exporting RCTModuleRegistry from the bridgeless core, which is safer than leaking the TurboModuleManager from the bridgeless core. Diffs incoming.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30753286

fbshipit-source-id: cf374092b7b939bc177c3c3448424f2fb53033c3
2021-09-08 12:46:35 -07:00
Ramanpreet Nara ddc4225dd4 Move NativeModule initialization logic outside of setModuleRegistry
Summary:
## Context
A while ago, we introduced a new initialization API in NativeModules via RCTInitializing.h (diff: D28435078 (9b45df1fce)).

## Problem
A number of our NativeModules still use setModuleRegistry to perform initialization.

## Changes
This diff migrates those NativeModules to instead use the initialize API.

## Motivation
In bridgeless mode each NativeModule object is [created and decorated by the RCTInstance](https://www.internalfb.com/code/fbsource/[89f6c0df78e453a20555975e06bc46b4e0d2bbe9]/fbobjc/Apps/Internal/Venice/Core/RCTInstance.mm?lines=180-189), while [holding the TurboModuleManagerDelegate mutex](https://www.internalfb.com/code/fbsource/[c50ce2bb3fb078d28e1f9afdef5e8793f1413472]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm?lines=429%2C431). After D30753286, setModuleRegistry will be called in RCTInstance getModuleInstanceForClass, which means that we'll start calling setModuleRegistry while holding the TurboModuleManagerDelegate lock. This leads to a deadlock, because calling setModuleRegistry on RCTDeviceInfo [creates RCTAccessibilityManager](https://www.internalfb.com/code/fbsource/[89f6c0df78e453a20555975e06bc46b4e0d2bbe9]/xplat/js/react-native-github/React/CoreModules/RCTDeviceInfo.mm?lines=50), which tries to acquire the TurboModuleManagerDelegate lock again. The NativeModule initialize method isn't called while holding the TurboModuleManagerDelegate lock. That's why moving all initialization logic to the initialize method mitigates this deadlock hazard.

In general, we shouldn't do any sort of initialization inside setters for these bridge/bridgeless APIs. No other NativeModules do initialization outside of initialize.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30754870

fbshipit-source-id: 7c2d50f995cba6f58ee2dfebfabd36f640579bcb
2021-09-08 12:46:35 -07:00
Samuel Susla 4f0671b409 Clean up Layout Animation initialisation
Summary:
changelog: [internal]

No need for ivar here.

Reviewed By: sshic

Differential Revision: D30726786

fbshipit-source-id: ba8f71c9f182c1afbfd5118adc15a098d9f56027
2021-09-07 02:49:22 -07:00
Ramanpreet Nara 9f69c922cb Remove RCTRootView.bridge usage from RCTBaseViewController
Summary:
RCTBaseViewController uses RCTRootView.bridge to call RCTViewEventEmitter.emit.

## Changes
- RCTEventDispatcher now exposes a method to dispatch RCTViewEventEmitter events.
- RCTRootView (for paper), and RCTSurfaceHostingProxyRootView (for fabric and bridgeless mode) now exports the RCTEventDispatcher by grabbing it from the bridge
- RCTBaseViewController now uses the event dispatcher exported from RCTRootView to dispatch the RCTViewEventEmitter event.

## Benefits
- RCTBaseViewController no longer uses the bridge to dispatch RCTViewEventEmitter events
- In the future, we'll make RCTSurfaceHostingProxyRootView work with bridgeless mode, which'll allow us to remove the bridge/bridgeless fork in RCTBaseViewController.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30434884

fbshipit-source-id: d961a56ac2abc08a661f8fe7c37926f219b731d0
2021-09-02 16:50:08 -07:00
Ramanpreet Nara bfead74e69 Allow RCTRootView users to require NativeModules without the bridge
Summary:
RCTRootVeiw exports the bridge. One reason why is to allow users of RCTRootView users to access NativeModules.

## Changes
- RCTBridge now exports the RCTModuleRegistry
- RCTRootView now exports the RCTModuleRegistry exported by the bridge
- Users of RCTRootView use the RCTModuleRegistry exported by RCTRootView to access NativeModules

## Benefits
Down the line, we'll change how RCTRootView gets the RCTModuleRegistry (i.e: it won't use the bridge in bridgeless mode).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30434886

fbshipit-source-id: 875fce24d2fd9ee6350f128c8612e613e61e390e
2021-09-02 16:50:08 -07:00
Ramanpreet Nara a909ba20db Remove !RCTRootView.bridge check from FBReactRootViewController
Summary:
Users of RCTRootView access the bridge from it, to see if it's nil or not.

## Changes
- Instead of exposing the bridge from RCTRootView for this use-case, we're now exposing a property on RCTRootView: hasBridge. This will be false in bridgeless mode, and true in bridge mode.

## Benefits

This takes us one step closer towards removing RCTBridge leakage through RCTRootView.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30434885

fbshipit-source-id: 02f50e16831852b5049a626e8b08d59a90b2059a
2021-09-02 16:50:08 -07:00
Samuel Susla 66deb8a9c0 Pass surfaceId to PropsParserContext when created though native animated
Summary:
changelog: [internal]

Pass surfaceId to PropsParserContext instead of placeholder -1.

Reviewed By: RSNara

Differential Revision: D30667846

fbshipit-source-id: bed98ad6c829c1346d8eb9e68d7beeb6696d6c4a
2021-09-01 10:27:31 -07:00
Héctor Ramos 2e8893fb5b Replace envvars with required params in codegen script and add Fabric output overrides
Summary:
The codegen script now takes parameters for any necessary configuration. Now, there are three *required* parameters: JS_SRCS_DIR, LIBRARY_NAME, and OUTPUT_DIR.
By default, all modules and components output will be copied to the OUTPUT_DIR under a single LIBRARY_NAME.

If a fourth argument is provided, this COMPONENT_LIBRARY_NAME will be used for the component library name.
If a fifth argument is provided, this COMPONENT_OUTPUT_DIR will be used as the output directory for the component library.

These last two arguments are used to build the core FBReactNativeSpec modules and rncore components libraries. Eventually, all module and component output will be part of a single library, but for the time being we need to keep these apart for the core modules and components.

The script will output usage instructions if no argument is provided:

```
 ./scripts/generate-specs.sh

NAME
        ./scripts/generate-specs.sh -- generate specs

SYNOPSIS
        ./scripts/generate-specs.sh javascript_sources_directory specs_library_name output_directory
        ./scripts/generate-specs.sh javascript_sources_directory specs_library_name output_directory component_library_name [component_output_directory]

DESCRIPTION
        In the first synopsis form, this script collects native module and native component JavaScript spec definitions in javascript_sources_directory, then uses react-native-codegen to generate the native interface code into a library named specs_library_name, which is copied to the destination output_directory.

        In the second synopsis form, the component_library_name will be used as the name of the component native interface code library. If provided, the component output will be copied to the component_output_directory, otherwise it will be copied to the output_directory.
```

With these changes, `codegen.js` became redundant and has been removed.

Changelog:
[Internal] - Codegen script interface changes.

Reviewed By: fkgozali

Differential Revision: D30626294

fbshipit-source-id: 475c29242497db5f93213aa64ca9b7c480140d55
2021-08-31 05:40:47 -07:00
Samuel Susla 53c6494615 Remount children in scrollView if layout changes
Summary: changelog: [internal]

Reviewed By: hramos

Differential Revision: D30603617

fbshipit-source-id: bc189d4a0a997202e6b2cd5314b997395bcdf7b2
2021-08-29 09:32:21 -07:00
Adlai Holler 4ac42d88ef Optimize font handling on iOS (#31764)
Summary:
Few issues I saw when profiling RNTester:
- Repeatedly calling `-lowercaseString` during `weightOfFont` causes a TON of extra memory traffic, for no reason.
- `NSCache` is thread-safe, so no need for a mutex.
- Using `stringWithFormat:` for the cache key is slow. Use `NSValue` to store the data directly instead.
- Calling `-fontDescriptor` in `isItalicFont` and `isCondensedFont` is overly expensive and unnecessary.
- `+fontNamesForFamilyName:` is insanely expensive. Wrap it in a cache.

Unscientific test on RNTester iPhone 11 Pro, memory & time. Before:
<img width="1656" alt="Screen Shot 2021-06-23 at 7 40 06 AM" src="https://user-images.githubusercontent.com/2466893/123092882-f4f55100-d3f8-11eb-906f-d25086049a18.png">
<img width="1656" alt="Screen Shot 2021-06-23 at 7 41 30 AM" src="https://user-images.githubusercontent.com/2466893/123092886-f6267e00-d3f8-11eb-89f6-cfd2cae9f7b6.png">

After:
<img width="1455" alt="Screen Shot 2021-06-23 at 9 02 54 AM" src="https://user-images.githubusercontent.com/2466893/123101899-7d2c2400-d402-11eb-97f8-2ee97ee69ec4.png">
<img width="1455" alt="Screen Shot 2021-06-23 at 8 59 44 AM" src="https://user-images.githubusercontent.com/2466893/123101892-7bfaf700-d402-11eb-9a10-def46b37b87f.png">

Changelog:
[iOS][Changed] - Optimized font handling

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

Reviewed By: appden

Differential Revision: D30241725

Pulled By: yungsters

fbshipit-source-id: 342e4f6e5492926acd2afc7d645e6878846369fc
2021-08-26 22:47:41 -07:00
Jimmy Zhang 1a42bd6e97 Add UIAccessibilityTraitUpdatesFrequently to progressBar role
Summary:
Changelog:
Add UIAccessibilityTraitUpdatesFrequently when the AccessibilityRole is set to progressBar. This trait tells the accessibility system where content may change with every percentage point, but without annoying the user with constant announcements.

Reviewed By: ikenwoo

Differential Revision: D30510587

fbshipit-source-id: e75690a2a56ce42476dc999383cf58c0811fcbdf
2021-08-25 05:10:27 -07:00
Steven Bell ddf9a63acb fix typos in comments (#32061)
Summary:
Fixed some typos in the code comments.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments

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

Test Plan: N/A

Reviewed By: javache

Differential Revision: D30482511

Pulled By: cortinico

fbshipit-source-id: ff67bc00d57972df88e41ee7a933259673de3aa2
2021-08-24 07:21:56 -07:00
Jimmy Zhang d756d4394d Add support for AccessibilityValue
Summary:
Changelog:
[Fabric][iOS] Add support for AccessibilityState

Specification: https://reactnative.dev/docs/accessibility#accessibilityvalue

Reviewed By: sammy-SC

Differential Revision: D30452786

fbshipit-source-id: 0d459d3a7b9c037bd1877e5c7ead40bbb42830c3
2021-08-24 05:18:46 -07:00
Jimmy Zhang 11f8d9c7cd Add support for the UIAccessibilityTraitsTabBar
Summary:
Changelog:
Add the capability to set tabbar accessibilityRole which maps to the iOS's UIAccessibilityTraitsTabBar

Reviewed By: yungsters

Differential Revision: D30490752

fbshipit-source-id: f7561a8932306e133d2f65a5ab40ba0be3899ec3
2021-08-24 02:31:17 -07:00
Dmitry Rykun 9187e20752 Selection prop is applied for TextInput when component is mounting
Summary:
Changelog: [Internal]
TextInput's predefined "selection" prop is now applied when view did move to window, and when attributed string is set.

Reviewed By: sammy-SC

Differential Revision: D30045271

fbshipit-source-id: e5495171b07a25e1e822421ff1627a8686cd0904
2021-08-23 10:07:57 -07:00
Dmitry Rykun 8434177722 Added Selection prop to TextInputProps
Summary:
Changelog: [iOS][Added]
1. Added new primitive type "Selection" to C++
2. Added property "selection" to TextInputProps
3. Added parser for that

Reviewed By: sammy-SC

Differential Revision: D30043256

fbshipit-source-id: eefa67ca23759761901cba1d2ab3052877a153a7
2021-08-23 06:04:01 -07:00
Paige Sun 1271e7afc3 iOS: Don't display LogBox in Dev if Bridge was invalided
Summary: Bridge can get invalidated during tear down. If a JS error is thrown then, don't display a LogBox so we don't hit the invalid bridge assert in RCTSurface.

Reviewed By: fkgozali

Differential Revision: D30464848

fbshipit-source-id: 87a8daa95fd06342d194a4805ecfa97279820f2e
2021-08-20 18:45:11 -07:00
Samuel Susla c2b971d6d4 Set initial maximum surface size to viewport size
Summary:
Changelog: [internal]

There is a possibility of race between JavaScript sending "completeRoot" and maximum size set on surface. To prevent this race, we set the initial maximum size to be equal to the viewport size.

Alternative solution is to set maximumSize to {0, 0} initially instead of infinity. This is what old architecture does, even though not explicitly.

Reviewed By: fkgozali

Differential Revision: D30402207

fbshipit-source-id: 44427404eaf060a81de257797823edf971ffc1bb
2021-08-20 05:42:21 -07:00