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

3815 Коммитов

Автор SHA1 Сообщение Дата
Vincent Riemer a40747e2d8 Add experimental disclaimers to pointer event APIs
Summary: Changelog: [Internal] - Add experimental disclaimers to pointer event APIs

Reviewed By: lunaleaps, p-sun

Differential Revision: D35682318

fbshipit-source-id: e85a37a2eb9568df636352e170bd42a3bb30a2f6
2022-04-18 15:47:55 -07:00
Richard Howell 7d4f6840f6 add casts for implicit int to float
Summary: Apply //fbobjc/Tools/cAST:implicit_conversion to existing warnings

Reviewed By: adamjernst

Differential Revision: D35692786

fbshipit-source-id: 13fb4f8a6b6e701c324b00c682943a4b3d80de72
2022-04-18 11:51:50 -07:00
Vincent Riemer 8e58f685a2 Fix pointer-events crash in catalyst-ios when running RNTester in legacy mode
Summary: Changelog: [Internal] Fix pointer-events setter crash in Paper

Reviewed By: appden

Differential Revision: D35617077

fbshipit-source-id: 975840a2474235a027279035ac327e9eb88d3f08
2022-04-14 10:40:54 -07:00
Phillip Pan e500e89fd6 check if bridge exists when we access the module registry
Summary:
Changelog: [internal]

we have an issue where the moduleRegistry that the TM uses is released, adding this log to check if it's bc the bridge was released

Reviewed By: RSNara

Differential Revision: D35420922

fbshipit-source-id: 93c206b5afefeac3121df148940d9658736cb9d2
2022-04-13 19:29:09 -07:00
Vincent Riemer c5cb707ba8 Add basic onPointerEnter/Leave event emitting to iOS
Summary: Changelog: [Internal] Add basic onPointerEnter/Leave event emitting to iOS

Reviewed By: lunaleaps

Differential Revision: D35414116

fbshipit-source-id: dd62cf7736c466e328b9ebbf51bf010610f4bd92
2022-04-11 15:49:30 -07:00
Paige Sun c032401b67 Fix sticky headers for scrollviews by sending onScroll event to legacy RCTEventDispatcher
Summary:
Changelog: [Internal][Bridgeless] Fix sticky headers for scrollviews by sending onScroll event to legacy RCTEventDispatcher

## Extra Context

FYI. <ScrollView> is the only Fabric component view that needs to send events via the legacy RCTEventDispatcher. Ideally, all component views should only use `ViewEventEmitter` to send events to JS and not use RCTEventDispatcher. This ScrollView does use ScrollViewEventEmitter, a subclass of ViewEventEmitter:
```
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScroll([self _scrollViewMetrics]);
```

However, it also needs RCTEventDispatcher for animations using `Animated.event` for `useNativeDriver: true`. See [ScrollView.js](370c65b943/Libraries/Components/ScrollView/ScrollView.js (L1124-L1129)).

Reviewed By: RSNara

Differential Revision: D35540277

fbshipit-source-id: a28535ed10cac8e003523ecda6080574fbb89b85
2022-04-11 15:30:14 -07:00
Vincent Riemer 3693928fb8 Add mechanism for iOS native components to expose capturing-only events
Summary: Changelog: [Internal] Add mechanism for iOS native components to expose capturing-only events

Reviewed By: lunaleaps

Differential Revision: D35328883

fbshipit-source-id: 0becb5e26ede3a12a69b0eb41fb15742422f5a4f
2022-04-07 14:07:58 -07:00
Vincent Riemer 179c24e255 Emit touch-equivalent W3C pointer events on iOS
Summary: Changelog: [Internal] Emit touch-equivalent W3C pointer events on iOS

Reviewed By: lunaleaps

Differential Revision: D35295104

fbshipit-source-id: 1c1d5a4159bbfed92df151f7e12a4973ec44e970
2022-04-07 14:07:58 -07:00
Vincent Riemer e85f2e2547 Add ObjC feature flag for dispatching w3c pointer events
Summary: Changelog: [Internal] Set up iOS feature flag for w3c pointer event dispatch

Reviewed By: lunaleaps

Differential Revision: D35233280

fbshipit-source-id: de439d9bbad4d5d2010a8ca3b99dd46c9a33946c
2022-04-07 14:07:58 -07:00
Lorenzo Sciandra 5cd6367f0b Bump boost for Android to 1.76 to align with iOS + fix (#33565)
Summary:
The reason why I'm working on this is to reduce the delta between this and the react-native-macos fork, in particular with the android patch folder "Build": https://github.com/microsoft/react-native-macos/tree/main/android-patches/patches/Build (it's a long story)

While checking the changes in there, I noticed that one of them was a bump of boost. Looking back into main (here), I then noticed that there have been two bumps to boot in the repo so far:
* a combo update 5 years ago to 1.63:
  * 193afff926
  * 5c24a9110a
* and an update for the iOS side to 1.76 by Kudo last year: https://github.com/facebook/react-native/pull/31840

So this quickly turned into this: the PR wants to re-align the version of boost used in both iOS and Android.

I explored the option of bumping both to 1.78 (latest at the time of writing: https://www.boost.org/users/history/version_1_78_0.html) but then I noticed that there's a Flipper dependency, `Flipper-Boost-iOSX`, on the iOS pods side that has been released only once and it seems to imply that it's 1.76 only compatible https://github.com/priteshrnandgaonkar/Flipper-Boost-iOSX/releases/tag/1.76.0.1.11.

So going to 1.78 at least for now seems like a no-go, and I've settled for just aligning everything to 1.76 and just like iOS, move away from `boost-for-react-native` in favour of the original one.

While doing so, I also noticed that the `React/third-party.xcconfig` still had a reference to 1.68 instead of 1.76 which seems like a leftover from Kudo's PR... it's probably because it was not doing anything in the first place, so lmk if you want me to delete 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
-->

[Android] [Changed] - Bump boost for Android to 1.76 to align with iOS

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

Test Plan:
CI is green (aside an unrelated ios rntester job that is also broken on main) 
Locally both RNTester and new app work:
<img width="432" alt="Screenshot 2022-04-05 at 16 42 31" src="https://user-images.githubusercontent.com/16104054/161815444-0de63919-b90d-4a48-963a-872f0cc4ce79.png">

<img width="346" alt="Screenshot 2022-04-05 at 18 06 01" src="https://user-images.githubusercontent.com/16104054/161815438-b7b1c997-9dcd-47bd-acbe-732155941bb0.png">

Reviewed By: sshic

Differential Revision: D35433032

Pulled By: cortinico

fbshipit-source-id: 0d93f61f8c26eda1dd04127a8b20e799ab6828cb
2022-04-07 04:50:30 -07:00
Paige Sun 88814d52dd Fix: Make RCTSurfacePresenter weakly retain its observers
Summary:
Changelog: [Fabric][iOS] Fix: Make RCTSurfacePresenter weakly retain its observers

There is retain cycle because RCTSurfacePresenter is keeping an array of  RCTSurfacePresenterObserver, which is strongly retaining the class that owns this RCTSurfacePresenter.

This diff makes RCTSurfacePresenter weakly retain observers instead.

Reviewed By: RSNara

Differential Revision: D35439589

fbshipit-source-id: ddc7813976b543de12af6173b2f1b31c69b043a8
2022-04-06 20:29:30 -07:00
Phillip Pan 98071f736a remove override on setModuleRegistry
Summary:
changelog: [internal]

this never fired, so it's not the cause of the nil moduleRegistry issue

Reviewed By: christophpurrer

Differential Revision: D35419873

fbshipit-source-id: 45693d3aa97d9efed2fe5085c281b57f1629764d
2022-04-06 12:11:50 -07:00
Chris Olszewski daa105aba5 Fixup typo in pfh labels
Summary:
Now that the PFH node has been renamed this updates the pfh label.

Produced via `xbgs -l -e '"pfh:ReactNative_CommonInfrastructurePlaceholde"' | xargs sed -i 's/"pfh:ReactNative_CommonInfrastructurePlaceholde"/"pfh:ReactNative_CommonInfrastructurePlaceholder"/'`

Reviewed By: jkeljo

Differential Revision: D35374087

fbshipit-source-id: 61590f69de5a69ec3b8a0478f6dd43409de3c70b
2022-04-05 12:15:05 -07:00
Chris Olszewski ceae48c0f7 Add pfh labels to targets
Summary:
While it would be better to be able to do all of the ownership metadata at the Buck macro level, that proved to be more work than expected.

This diff adds the corresponding pfh label to all targets in `xplat/js/react-native-github` that have a Supermodule label. Once the migration is complete the Supermodules labels will be able to be removed.

Reviewed By: cortinico

Differential Revision: D35221544

fbshipit-source-id: d87d5e266dfb5e6ee087251dc34dff5db299bbaf
2022-03-30 14:37:03 -07:00
Chris Olszewski 75edd288cb Backout feature args
Reviewed By: jkeljo

Differential Revision: D35203884

fbshipit-source-id: 87d50b138aaa3dd16a24b5ff2795910c3644d418
2022-03-30 06:53:44 -07:00
Paige Sun 6031e4ab62 Fix: Add api to disable New Architecture validation reporting, and reset reporting when FBReactModule is recreated
Summary:
Changelog: [iOS][Internal] Add api to disable New  validation reporting

Previously `RCTNewArchitectureValidationSetEnabled` was not set to false once it was set to true when a use is in app-wide Bridgeless mode.
This resulted it being in an incorrect state if a user:
1) Opens RN while in app-wide Bridgeless enabled
2) Logout
3) Re-login as another user without killing the app.

The fix is to set `RCTNewArchitectureValidationSetEnabled(RCTNotAllowedValidationDisabled)` in FBReactModule initialization.

Reviewed By: RSNara

Differential Revision: D35233335

fbshipit-source-id: 82a2c2ed030df5d68267a40b14322e652eb29e96
2022-03-29 18:40:19 -07:00
Paige Sun 37e5fa3a6c Refactor: Migrate Logbox surface initialization to Fabric when available, in Bridge and Bridgeless modes
Summary:
Changelog: [iOS][Internal] Refactor: Migrate Logbox surface initialization to Fabric when available, in Bridge and Bridgeless modes

# Why
This diff main purpose is to add `RCTErrorNewArchitectureValidation(RCTNotAllowedInAppWideFabric)` in `RCTSurface`, to ensure Paper surfaces are never created in FBiOS.

# The Situation
Before this diff, in Bridged Fabric, `[RCTLogbox show]` initializes a Paper `RCTSurface`, [using `[RCTLogBoxView initWithWindow]`](https://github.com/facebook/react-native/blob/main/React/CoreModules/RCTLogBoxView.mm#L46))
In this diff,  in Bridged and Bridgeless Fabric, `[RCTLogbox show]` initializes a Fabric `RCTFabricSurface`.

Before this diff, in Bridgeless Fabric,  RCTLogBox posts a "CreateLogBoxSurface" notification to RCTInstance.
In this diff, the notification hack is replaced by the same `RCTFabricSurface` initialization above.
Behavior is the same.

Reviewed By: RSNara

Differential Revision: D35177311

fbshipit-source-id: 6de418af8a01f914c9a806bb8d74915015f9087a
2022-03-29 18:40:19 -07:00
Paige Sun a3bccdacc0 (Easy) Remove RCTNotAllowedInBridgeless validation for RCTRegisterModule
Summary:
Changelog: [iOS][Internal] Remove RCTNotAllowedInBridgeless validation for RCTRegisterModule

In the TurboModule system, `RCTRegisterModule` gets called for all `RCTBridgeModules` that calls `RCT_EXPORT_MODULE()` and it works fine in Bridgeless mode.

Reviewed By: RSNara

Differential Revision: D35203039

fbshipit-source-id: 8ae2be4487fe21653a7f1628fa92606a7d36d467
2022-03-29 17:27:05 -07:00
Imran Shitta-Bey 68fd1e5508 fix: deadlock when sending events (#33490)
Summary:
In short, if an RCTEventDispatcher observer sends an event on the same thread that the observer was initially on, there will be a deadlock due to `sendEvent` already having the lock active on the `_observers` NSHashTable. An example where this occurred was when we had react-native-gesture-handler trigger an animated event, which then triggered an event on the underlying component being animated as a result of it being an observer on the animation event. Since this all occurred on the main thread, we ended up with a deadlock and the app froze.

To prevent this scenario, I used a `NSRecursiveLock` for _observersLock to be able to dispatch events on the same thread from observers.

joebernard

## 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] [Fix] - Prevent deadlock when dispatching events from observers on the same thread.

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

Test Plan:
Not sure if there are any tests present for sending events with RCTEventDispatcher already in place, but In regular app usage this solution has proved to be a viable and stable option so far and has prevented the deadlock from occurring.

This would still be thread-safe since we are now allowing the event to be sent through observers on the same thread the initial event was dispatched on. The only issue I could see here is the behavior of sending an event could be changed.

Reviewed By: RSNara

Differential Revision: D35118752

Pulled By: charlesbdudley

fbshipit-source-id: 7e93a8d49841e001b235a437ccca1e072dcc7ab1
2022-03-29 14:04:07 -07:00
Paige Sun eeb244a612 (Easy) Rename RCTNotAllowedInFabric to RCTNotAllowedInAppWideFabric
Summary:
Changelog: [iOS][Internal] Rename RCTNotAllowedInFabric to RCTNotAllowedInAppWideFabric

Clarify that methods marked with `RCTNotAllowedInAppWideFabric` are only NOT available when Fabric is app-wide (which is necessary for app-wide Bridgeless mode). These methods may still be called in apps with legacy pre-Fabric surfaces.

Reviewed By: RSNara

Differential Revision: D35194789

fbshipit-source-id: e16fa54d22ea67be995e93f6ff60567a117398be
2022-03-29 11:52:49 -07:00
CodemodService Bot b6e72c5922 Annotate targets with feature xplat/js/react-native-github/Libraries/RCTRequired/BUCK -> xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK
Reviewed By: jkeljo

Differential Revision: D35178374

fbshipit-source-id: be4ad27928a1b9260a9d6321c9705b30aebe04d6
2022-03-28 13:11:16 -07:00
Vincent Riemer d31d83f410 Update iOS LogBox to render its UIWindow with the key window's UIWindowScene
Summary:
If an RN app is embedded in a Mac Catalyst app that uses the UIWindowScene API to manage multiple windows, LogBox would fail to render because it didn't know which UIWindowScene to render to. This diff fixes that situation by ensuring that the LogBox window gets rendered in the key window's scene.

Changelog:
[iOS][Fixed] - Update iOS LogBox to render its UIWindow with the key window's UIWindowScene

Reviewed By: appden

Differential Revision: D35027831

fbshipit-source-id: e0df5865f95323b03d08d6b1fb3ec912aa9a9167
2022-03-25 13:28:50 -07:00
Paige Sun 743d0706e2 1/3 Add validation reporting APIs for unexpected uses of Paper when Fabric is enabled, in Bridge mode
Summary:
Changelog: [Internal][iOS] Add validation reporting APIs for unexpected uses of Paper when Fabric is enabled

## RCTNotAllowedInBridgeless
Previously, we only had violation reporting APIs for when **Bridge APIs** are used in **Bridgeless mode**, which was only enabled in Bridgeless mode.

## RCTNotAllowedInFabric
This diff adds violation reporting APIs to use when **pre-Fabric Bridge APIs** are used in **Bridge or Bridgeless mode**. This allows us to add RCTAssert/RCTError/RCTLog to more APIs in Bridge mode. The main purpose is to distinguish between Bridge APIs that still work in Fabric, versus Bridge APIs that are no longer used in Fabric, so that the latter can be removed.

Reviewed By: philIip

Differential Revision: D35015758

fbshipit-source-id: 35366bc5143a59ee9a16d75da4de546ebfe250e6
2022-03-22 20:14:32 -07:00
Erich Graham 45e2941367 Remove folly import in GenerateModuleObjCpp
Summary:
Changelog:

[iOS][Changed]
Replaced folly::Optional with std::optional from C++17 in Objc module generator.

Reviewed By: philIip

Differential Revision: D32367103

fbshipit-source-id: f0d254c4add7d6d2e0bdbceb09a852b4a01ea8c7
2022-03-22 17:10:18 -07:00
Phillip Pan 982ca30de0 bump iOS and tvOS from 11.0 to 12.4 in cocoapods
Summary:
Changelog: [iOS][Deprecated] Deprecating support for iOS/tvOS SDK 11.0, 12.4+ is now required

allow-large-files

Reviewed By: sammy-SC

Differential Revision: D34547333

fbshipit-source-id: a24bb09d03939a092de4198efb1aa4a44c69f718
2022-03-16 21:08:01 -07:00
Phillip Pan 126873f63d get rid of weird nil check on CGFloat
Summary:
Changelog: [Internal]

this doesn't really make any sense, first of all CGFloat is a primitive data type so comparing it against nil only will return true if it's 0. but that won't catch cases where CGFloat is uninitialized bc it will be holding junk in memory.

the error checking of the value is already handled in the accessibility manager, so just remove it here.

Reviewed By: p-sun

Differential Revision: D34909365

fbshipit-source-id: 483f9c100433f8533edd784622523c5469c616c2
2022-03-16 21:03:36 -07:00
Phillip Pan 9b4bb54fdf add error logs for nil moduleRegistry
Summary:
Changelog: [Internal]

for the last 6 months or so, we've been getting this task where the moduleRegistry in RCTDeviceInfo is nil. in this change, i add some logs to see what might be setting this to nil.

 in all honestly, i don't really think this is happening, but it would be good to verify.

Reviewed By: sshic

Differential Revision: D34908902

fbshipit-source-id: d375285467a87453605ba0fecfc124bc3bff6e63
2022-03-16 21:03:36 -07:00
Pieter De Baets be0ff779b1 Fix parseTypeFromHeader for Hermes bytecode
Summary: Changelog: [Internal] Fix bug where Hermes bytecode bundles were not always recognized

Reviewed By: motiz88

Differential Revision: D34718511

fbshipit-source-id: 5bbebe49962d098988d99153b0938fbb5d449ae6
2022-03-15 05:58:52 -07:00
Danilo Bürger 75105e692c Start surface after setting the delegate (#33402)
Summary:
When starting the surface, _propagateStageChange is called. This checks the delegate to call surface:didChangeStage: on it.

When initWithSurface:sizeMeasureMode: is called after start, then the delegate will be nil and thus not be called.

This turns it around so a delegate is present for the surface to propagate its state to.

This fixes RCTContentDidAppearNotification not getting posted otherwise.

## Changelog

[iOS] [Fixed] - Post RCTContentDidAppearNotification with new arch

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

Test Plan:
I found it best to set a breakpoint in XCode to where RCTContentDidAppearNotification is being posted.

Prior to the patch that breakpoint will not be called. After applying the patch, it will be called.

Reviewed By: philIip

Differential Revision: D34753329

Pulled By: ShikaSD

fbshipit-source-id: cc44a4c3a787d49e22e9d0c3a82c0f11ed281a0a
2022-03-12 08:32:09 -08:00
Gabriel Donadel Dall'Agnol 64ebe5bbdd feat: Add dismissActionSheet method to ActionSheetIOS (#33189)
Summary:
This PR adds a `dismissActionSheet` method to `ActionSheetIOS` in order to allow dismissing an ActionSheet programmatically. This is especially useful in apps where a user has the ability to open an ActionSheet and then open a push notification that will redirect them to another screen which usually leads to scenarios where the presented ActionSheet has no relation with the current screen.

#### TODO
- [ ]  Submit react-native-website PR updating ActionSheetIOS documentation.

## Changelog

[iOS] [Added] - Add dismissActionSheet method to ActionSheetIOS

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

Test Plan:
1. Open the RNTester app and navigate to the ActionSheetIOS page
2. Test `dismissActionSheet` through the `Show Action Sheet and automatically dismiss it` example

https://user-images.githubusercontent.com/11707729/155867546-c6770a49-9b09-45e3-a6b1-4f7645d67dbf.mov

Reviewed By: lunaleaps

Differential Revision: D34518952

Pulled By: cortinico

fbshipit-source-id: 912a9b83ee078f791b42efddf5abb7e1cd09d520
2022-03-11 16:33:17 -08:00
Kudo Chien a6c2846b37 Fix ios build error when use_frameworks is on and fabric is off (v2) (#33409)
Summary:
alternative solution for https://github.com/facebook/react-native/issues/33379

> when `use_frameworks!` is on, there are errors like:
> ```
> 'FBReactNativeSpec/FBReactNativeSpec.h' file not found
> #import <FBReactNativeSpec/FBReactNativeSpec.h>
> ```
> this error may come from from https://github.com/facebook/react-native/commit/f7e4c07c84b6 regression.
>
> when `use_frameworks!` is on, xcode will search headers from framework directories, the correct imports would be `#import <React_Codegen/FBReactNativeSpec/FBReactNativeSpec.h>` (xcode will transform dash to underscore, so it is `React_Codegen` but not `React-Codegen`). in the other hand, when `use_frameworks!` is off, the correct import is `#import <React-Codegen/FBReactNativeSpec/FBReactNativeSpec.h>`.
>
>
> this fix is specific for old architecture (fabric is off).
>
> when fabric is on, there are other errors from duplicated headers when copying to build folder. [the reason is that framework build would try to flatten headers](https://mkonrad.net/2015/03/29/xcode-static-libraries-preserving-header-directory-structure.html). we have `primitives.h` in different folders and they would be flattened into `React_Fabric.framework/Headers`. to be honest, i don't know how to deal with the problem in the meantime,  maybe subspecs are not enough, we should separate them from subspecs to dedicated podspecs so that we can have these targets as different frameworks.

in this alternative fix, i try to add `React-Codegen/React_Codegen.framework/Headers` into header search paths and make original `#import <FBReactNativeSpec/FBReactNativeSpec.h>` reachable.

[this change](7a0398c331) in the pr is just a workaround to solve breaking in latest main branch and this is not important to the `use_frameworks!` fix at all. this breaking was coming from 1804951595.

## Changelog

[iOS] [Fixed] - Fix iOS build error when Podfile `use_frameworks!` is on and Fabric is off

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

Test Plan:
verify with rn-tester
1. change `fabric_enabled` to false in `packages/rn-tester/Podfile`
2. `USE_FRAMEWORKS=1 pod install`
3. build rn-tester in xcode

Reviewed By: dmitryrykun

Differential Revision: D34817041

Pulled By: cortinico

fbshipit-source-id: 4d1a610e99a807793eb3f64461e0d735c0a9ca9c
2022-03-11 09:08:07 -08:00
Samuel Susla c9bbe75be8 Remove gating for legacy interop layer view hierarchy changes
Summary: changelog: [internal]

Reviewed By: javache

Differential Revision: D34756141

fbshipit-source-id: f78ee2376d03652813353bfd88c3c349d1c6ae4f
2022-03-11 09:00:17 -08:00
Lulu Wu 1804951595 Hook EarlyJsErrorHandler
Summary:
Hoop up EarlyJsErrorHandler so we could pass js error data to object-c to report.

Changelog:
[iOS][Chagned] - Add function to report early js errors

Reviewed By: RSNara

Differential Revision: D34096343

fbshipit-source-id: fdbc6ea5d1f3cc6ab55fcd22b48bbe8fb1f1ca8f
2022-03-10 10:25:32 -08:00
Vincent Riemer 84f8c9ad55 Ensure LogBoxView is sized based on the "window" size instead of the "screen" size
Summary:
In iOS, the native LogBox that gets rendered for JS errors/warnings is statically sized once and bases that size off of the entire screen's size. This causes issues when being run in a Mac Catalyst app since 1) the sizing is not static since we can resize the window and 2) the size of the LogBox's root should fill the *window* and not the screen. This diff fixes both of these issues.

Changelog:
[iOS][Fixed] - Ensure LogBoxView is sized relative to the key window instead of the full screen

Reviewed By: appden

Differential Revision: D34697076

fbshipit-source-id: 9665fd51bc86ed29837672cec882bac97904b0c8
2022-03-09 15:43:37 -08:00
Samuel Susla 538636440b Convert CGFLOAT_MAX to infinity
Summary:
changelog: [internal]

For embedded React Native screens, we need to calculate the intrinsic size. To do that, we need to pass Yoga value `YGUndefined`. However, if available size was `CGFLOAT_MAX` (which is not inifinity), we would pass it to Yoga and it would calculate layout with available height/width `CGFLOAT_MAX`.

To fix this, we convert `CGFLOAT_MAX` to infinity. Which in YogaLayoutableShadowNode gets converted to YGUndefined.

Reviewed By: ShikaSD

Differential Revision: D34719047

fbshipit-source-id: e6fd40724f81abfba164e67efc9ca8fc74e9b235
2022-03-09 03:36:11 -08:00
Diego Pasquali 7b05b091fd Integrated iOS-only `accessibilityLanguage` prop (#33090)
Summary:
This PR fixes https://github.com/facebook/react-native/issues/30891

This PR is going to add an `accessibilityLanguage` prop to all the available components. This props is currently working only on iOS and should follow the [guidelines of the relative configuration](https://developer.apple.com/documentation/objectivec/nsobject/1615192-accessibilitylanguage).

I'm in no way an expert on native programming (especially Objective-C) so I'm open to changes / improvements 🙂

## 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] [Added] - Integrated the `accessibilityLanguage` prop to all the available components. The prop is available for any platform but it will work only on iOS.

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

Test Plan:
This has been tested using both the Simulator, checking for the `Language` attribute, and using a physical device with the Voice Over enabled.

<img width="1083" alt="Screenshot 2022-02-11 at 13 17 32" src="https://user-images.githubusercontent.com/5963683/153590415-65fcb4ff-8f31-4a0f-90e5-8eb1aae6aa3d.png">

Reviewed By: philIip

Differential Revision: D34523608

Pulled By: rh389

fbshipit-source-id: b5d77fc0b3d76ea8ed8f30c8385459ba98122ff6
2022-03-07 09:43:30 -08:00
Samuel Susla a159416333 Use std::optional instead of butter::optional
Summary: changelog: Use std::optional instead of butter::optional

Reviewed By: fkgozali

Differential Revision: D33352680

fbshipit-source-id: 45a53fec181a6ffb6218909bc23348f7c9f21ec4
2022-03-04 07:25:59 -08:00
Samuel Susla c2e4ae39b8 Add support for C++17 in OSS
Summary: changelog: Add support for C++17

Reviewed By: cortinico

Differential Revision: D34612257

fbshipit-source-id: 88a0307a750f2e0793a639b7a2b670a4571332fe
2022-03-04 07:25:59 -08:00
HeyImChris 46f68aceb2 onDismiss to be an RCTDirectEventBlock (#33222)
Summary:
We're seeing a red box that `Component 'RCTModalHostView' re-registered bubbling event 'topDismiss' as a direct event moduleConstantsForComponent` in some downstream react-native-macOS builds.

Looking at other usage of this object, we treat it as a direct event block everywhere else, just this one spot it's a bubbling event block. It was added with [this PR](7bf78eae5e) which doesn't explicitly address the desire for the prop to bubble up through the view hierarchy or not, so I'm guessing it was just mislabeled and should be direct like the other usages.

## Changelog

[iOS] [Bug] - Fix modal redbox for onDismiss

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

Test Plan: We don't redbox downstream anymore

Reviewed By: p-sun, RSNara

Differential Revision: D34628759

Pulled By: philIip

fbshipit-source-id: bb3cc78fa43d20808579c614e25716880d002d88
2022-03-03 18:06:08 -08:00
Paige Sun 260c5fab9f (Easy) Migrate DatePickerIOS for Bridgeless
Summary: Changelog: [iOS][Internal] Migrate DatePickerIOS for Bridgeless mode

Reviewed By: RSNara

Differential Revision: D34595944

fbshipit-source-id: b20050dd5b350c186e4d1062c5d796a26d6aeb3e
2022-03-02 17:42:13 -08:00
Paige Sun 2c268d7fe6 2/3 Make interop WebView component Bridgeless compatible, and make `uiManager addUIBlock` migration easier
Summary:
Changelog: [iOS] Add `_viewRegistry_DEPRECATED addUIBlock`  to replace `uiManager addUIBlock` for Fabric migration

Allow people to directly replace `uiManager addUIBlock` with `_viewRegistry_DEPRECATED addUIBlock` when they migrate the method in RCTViewManagers.

Currently we add an if check in the RCTViewManager, which makes migration a bit harder for OSS.
```
  if (self.bridge) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
      work();
    }];
  } else {
    RCTExecuteOnMainQueue(work);
  }
```

Reviewed By: sammy-SC

Differential Revision: D34532609

fbshipit-source-id: 19647fea03be8fd71d8f46dfe216275894d8165c
2022-03-02 14:09:56 -08:00
Paige Sun 6e03945c7f Use @synthesize viewRegistry_DEPRECATED for Keyframes to remove RCTWeakViewHolder hack
Summary:
Changelog: [iOS][Internal] Use synthesize viewRegistry_DEPRECATED for Keyframes to remove RCTWeakViewHolder

Remove the `RCTWeakViewHolder` hack, since it can be replaced with `viewRegistry_DEPRECATED viewForReactTag`.

Reviewed By: RSNara

Differential Revision: D34468082

fbshipit-source-id: be41ed2df6ee195409724f6069fd99a793dca01a
2022-02-25 13:45:22 -08:00
Danilo Bürger 267d36d0af Updated borderColor view property to UIColor (#33176)
Summary:
In c974cbff04 I changed the borderColor from CGColor to UIColor. I missed this view property which should also be updated to reflect the original change.

## Changelog

[iOS] [Fixed] - Set RCTView borderColor to UIColor

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

Test Plan: Nothing to test. See PR https://github.com/facebook/react-native/pull/29728

Reviewed By: javache

Differential Revision: D34461141

Pulled By: genkikondo

fbshipit-source-id: 51adf39c1cebe8e3b53285961358e4c7f26192db
2022-02-25 08:59:09 -08:00
Paige Sun 917d63b37c (Easy) 2/5 Refactor RCTModuleData to use RCTBridgeModuleDecorator, to attach @synthesize ivars to non-TurboModule RCTBridgeModules in Bridge mode
Summary:
Changelog: 2/n Refactor RCTModuleData to use RCTBridgeModuleDecorator, to attach synthesize ivars to non-TurboModule RCTBridgeModules in Bridge mode

I decided to not include the `RCT_PROFILE_BEGIN_EVENT`s in [RCTBridgeModuleDecorator attachInteropAPIsToModule] because people don't override the set methods for the 4 synthesize ivars, so setting each ivar should be instant.

Reviewed By: RSNara

Differential Revision: D34438180

fbshipit-source-id: 871ac4cadd7a36821dac1274f0645c19d63943fc
2022-02-25 08:50:34 -08:00
Paige Sun 94b1b8a573 1/5 Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach @synthesize ivars to RCTTurboModules, in Bridge mode
Summary:
Changelog: [iOS][Internal] Refactor CxxBridge: Introduce RCTBridgeModuleDecorator to attach synthesize ivars to RCTTurboModules, in Bridge mode

This doesn't change any logic. RCTBridgeModuleDecorator was created to consolidate several nearly identical implementations of the `attachInteropAPIsToModule` method to one place.

Most importantly, it allows us to attach interop APIs in RCTBridgeModuleDecorator to RCTViewManagers in diff 4/4, using  `attachInteropAPIsToModule`. Before this stack, these four synthesize ivars in RCTViewManagers are nil in Bridgeless mode, and point to instances in Bridge mode.

# Context
These are used in RCTBridgeModules to access APIs for view managers. These APIs are necessary and compatible with Bridgeless mode.

*  synthesize viewRegistry_DEPRECATED
*  synthesize bundleManager
*  synthesize callableJSModules
*  synthesize moduleRegistry

Reviewed By: RSNara

Differential Revision: D34437802

fbshipit-source-id: b773d511cf877d4896436fabf4893c978e5f8dd9
2022-02-25 08:50:34 -08:00
Samuel Susla 5e88223d85 Add support for nested components in legacy interop
Summary: changelog: [internal]

Reviewed By: ShikaSD

Differential Revision: D34173837

fbshipit-source-id: 09fbf12e9d8eb13a170ff92afff97f203d0ef805
2022-02-18 07:11:44 -08:00
Amy Lee 16feabf676 Address some RN build warnings
Summary:
Addresses build warnings for some additional compiler flags.

Changelog: [Internal]

Reviewed By: nlutsenko

Differential Revision: D34299822

fbshipit-source-id: d3d873fb600990a869cb0e6fbe9fff4ebc8c5d0e
2022-02-17 19:18:11 -08:00
Paige Sun af793dd14d Don't error to Logview APIs not supported by new architecture that are expected to happen often
Summary:
Changelog: [Internal]

In the new architecture, when an interop component is being called, log instead of warn/error, since at the moment we expect this to happen often.

Reviewed By: fkgozali

Differential Revision: D34252666

fbshipit-source-id: 971156a1cd9ef9b788f677c49fa2c55bd86ad4fa
2022-02-16 14:18:08 -08:00
Janic Duplessis 8935d6e697 Fix action sheet callback invoked more than once on iPad (#33099)
Summary:
iOS will sometimes invoke the UIAlertAction handler for the cancel button more than once on iPad. This can be reproduced relatively easily by having a button that opens an action sheet and spam tapping outside the action sheet while it is opening. Since native module callbacks can only be invoked once this causes the app to crash here https://github.com/facebook/react-native/blob/main/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm#L206.

## Changelog

[iOS] [Fixed] - Fix action sheet callback invoked more than once on iPad

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

Test Plan: Tested on iPad simulator to reproduce the crash and verified that this fixes it.

Reviewed By: philIip

Differential Revision: D34215327

Pulled By: ShikaSD

fbshipit-source-id: 6f406e4df737a57e6dd702dd54260aa72eab31d6
2022-02-16 04:38:50 -08:00
Paige Sun 3c4850d76b (Easy) Log errors to Logview when Bridge is used in Bridgeless
Summary:
Changelog: [Internal]

# Diff Changes
- Set `RCTEnableNewArchitectureViolationReporting` to YES in app-wide Bridgeless mode.
- Rename `RCTWarnNotAllowedForNewArchitecture` to `RCTErrorNotAllowedForNewArchitecture`, and use `RCTLogError` instead of `RCTLogWarn` so the error goes to Logview.

Reviewed By: RSNara

Differential Revision: D34202682

fbshipit-source-id: 471486c65f7a42f8f11140e61ff60592dc826f61
2022-02-14 19:42:07 -08:00
Paige Sun 74f5697fdc Fix RCTLogError and RCTLogWarn to display RedBox or LogBox in Bridgeless
Summary:
Changelog: [Internal]

After the diff Bridgeless and Bridge behaves the same for `RCTLogError` and `RCTLogWarn`.

Reviewed By: RSNara

Differential Revision: D34197703

fbshipit-source-id: 0645857aad609fa911df6681de9c0c251cf72a36
2022-02-14 19:42:07 -08:00
Janic Duplessis 899da15a31 Remove unused _callbacks hashmap (#33097)
Summary:
Stumbled upon this unused code.

## Changelog

[Internal] [Fixed] - Remove unused _callbacks hashmap

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

Test Plan: Test it still builds

Reviewed By: philIip

Differential Revision: D34215314

Pulled By: ShikaSD

fbshipit-source-id: 7357a9be725d57b37f697f7222b95c1fd1d9f67c
2022-02-14 11:01:49 -08:00
Phillip Pan 7cece34233 test RCTView with c swizzling example
Summary:
writing a test that has an example of c swizzling in oss. testing this:

https://www.internalfb.com/code/fbsource/[c58818169205f1e0fa816968efdb4c3fac8333e9]/xplat/js/react-native-github/React/Views/RCTView.m?lines=452-454%2C460-468

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949237

fbshipit-source-id: f16c98ec1a736f3f2152d1e411b693083519a7b9
2022-02-11 13:46:02 -08:00
Samuel Susla cefc056241 Remove flag react_native_new_architecture:runtimescheduler_enable_yielding_ios
Summary:
changelog: [internal]

This is shipped on iOS, let's remove gating.

Reviewed By: javache

Differential Revision: D34144360

fbshipit-source-id: 8ca1b3a061470155405bf1b71cdc9ddda6fc2be3
2022-02-11 07:16:30 -08:00
Genki Kondo 49f3f47b1e Support color animation with native driver for iOS
Summary:
Adds support for Animated.Color with native driver for iOS. Reads the native config for the rbga channel AnimatedNodes, and on update(), converts the values into a SharedColor.

Followup changes will include support for platform colors.

Ran update_pods: https://www.internalfb.com/intern/wiki/React_Native/Preparing_to_Ship/Open_Source_Pods/

Changelog:
[iOS][Added] - Support running animations with AnimatedColor with native driver

Reviewed By: sammy-SC

Differential Revision: D33860583

fbshipit-source-id: 990ad0f754a21e3939f2cb233bcfa793ef12eb14
2022-02-10 11:18:39 -08:00
Andrei Shikov 980c52de41 Disable view flattening when the view has event handlers on Android
Summary:
The views with touch event props are currently flattened by Fabric core, as we don't take event listeners into account when calculating whether the view should be flattened. This results in a confusing situation when components with touch event listeners (e.g. `<View onTouchStart={() => {}} /> `) or ones using `PanResponder` are either ignored (iOS) or cause a crash (Android).

This change passes touch event props to C++ layer and uses them to calculate whether the view node should be flattened or not. It also refactors events to be kept as a singular bitset with 32 bit (~`uint32_t`).

Changelog: [Changed][General] Avoid flattening nodes with event props

Reviewed By: sammy-SC

Differential Revision: D34005536

fbshipit-source-id: 96255b389a7bfff4aa208a96fd0c173d9edf1512
2022-02-10 06:07:39 -08:00
Minsik Kim 1a83dc36ce Fix a broken input for the Korean alphabet in TextInput (#32523)
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

Fix https://github.com/facebook/react-native/issues/32503

Updating the attributed text in TextView/TextField while inputting Korean language will break input mechanism of the Korean alphabet. This results unexpected text input.

This PR supersedes the previous fixes: https://github.com/facebook/react-native/issues/19809, https://github.com/facebook/react-native/issues/22546

## 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] - Fix a broken input for the Korean alphabet in TextInput

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

Test Plan: https://user-images.githubusercontent.com/20317121/140013434-1674c391-54d6-4410-b4c1-c633697e639d.mov

Reviewed By: lunaleaps, sammy-SC

Differential Revision: D32470543

Pulled By: philIip

fbshipit-source-id: e7e34bd362fa2ab2ca579103db01ad8d1a891c35
2022-02-09 22:06:55 -08:00
Danilo Bürger 9a35818797 Use trait collection to resolve border colors (#32492)
Summary:
c974cbff04 changed the border colors to be of UIColor instead of CGColor. This allowed working with dark mode to switch the border colors automatically. However, in certain situation the system can't resolve the current trait collection (see https://stackoverflow.com/a/57177411/2525941). This commit resolves the colors with the current trait collection to ensure the right colors are selected. This matches with the behavior of how the background color is resolved (also in displayLayer:).

## Changelog

[iOS] [Fixed] - Resolve border platform color based on current trait collection

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

Test Plan: Same test plan as https://github.com/facebook/react-native/pull/29728

Reviewed By: sammy-SC

Differential Revision: D33819225

Pulled By: cortinico

fbshipit-source-id: 2f8024be7ee7b32d1852373b47fa1437cc569391
2022-02-07 10:24:47 -08:00
Samuel Susla 9cd43340a7 Attempt to fix crash during app termination
Summary:
changelog: Attempt to fix a crash during app termination on iOS in the new renderer

We need to stop all surfaces before it is terminated to prevent app from crashing.

The crash happens on background thread.
The app crashes because it is probably accessing static variable that has been deallocated by the main thread. How can main thread deallocate things when background thread is still running? Because main thread is attached to our app's process, background thread is provided by the system and continues to live.

Reviewed By: ShikaSD

Differential Revision: D33977161

fbshipit-source-id: 87546d7b70d1aa465e63f0d37b70bae1fffa2304
2022-02-03 11:29:22 -08:00
Felipe Perez 3552ff0562 Back out "Delete RuntimeScheduler yielding mobile config"
Summary:
D33740360 (16ed62a850) broke Explore VR on React Native. The app would go into a loop on boot and not finish mounting. This is probably a product code issue, but it's not a trivial issue to solve. Unlanding to unblock the RN migration.

Changelog:

[internal] internal

Reviewed By: mdvacca

Differential Revision: D33918026

fbshipit-source-id: cc77c70ece9994d82c91f7ae8783e959629e9cfb
2022-02-01 15:17:14 -08:00
Danilo Bürger 89efa1a0c1 Only find closest font if system font was not found (#32482)
Summary:
Before f951da912d finding a system font used to return early. In order to allow variants, the referenced patch removed the early return so that variants could be applied later. However, there is no need to find the closest font as we already selected the proper system font. This also fixes a bug with setting a custom font handler via RCTSetDefaultFontHandler whos return could get overwritten by the closest font search.

## 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] - Respect RCTSetDefaultFontHandler chosen font

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

Reviewed By: ShikaSD

Differential Revision: D33844138

Pulled By: cortinico

fbshipit-source-id: 05c01fc358cd19f8be342218cdba944b303073ed
2022-01-28 07:38:39 -08:00
Samuel Susla 16ed62a850 Delete RuntimeScheduler yielding mobile config
Summary:
changelog: [internal]

Yielding in RuntimeScheduler is shipped. This diff removes the gating around it.

Reviewed By: sshic

Differential Revision: D33740360

fbshipit-source-id: 267372e81e66dda96e451435954a7c3546cc6fbe
2022-01-26 09:23:08 -08:00
CodemodService FBSourceClangFormatLinterBot 45d196a9e5 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D33762300

fbshipit-source-id: 34957241276cf9cdcdcf175cc73accd837ff7a54
2022-01-25 03:30:00 -08:00
Mattéo Martin e6a3410afe Add allowsEdgeAntialiasing on views with rotations or skew tr… (#32920)
Summary:
…ansforms

On iOS, if a View is rotated with the a transform (e.g. <View style={{transform: {rotationZ: 5}}} />), the view has aliasing  (see screenshot). Same for a skew transformation. We don't have the issue on Android

This behavior had originally being fixed by this PR https://github.com/facebook/react-native/pull/1999

However a new PR was merge ( https://github.com/facebook/react-native/pull/19360 ) that broke this. I think it was made to add antialiasing during perspective transforms but seems to have broken the antialiasing when rotationZ transforms

This PR adds back the antialising during rotation transform , while keeping it during perspective transform.

## Changelog

I changed the allowsEdgeAntialiasing condition, making it "true" when the m12 or m21 is not 0. From this article https://medium.com/swlh/understanding-3d-matrix-transforms-with-pixijs-c76da3f8bd8 , I've understood that in all rotation or skew transformations, m12 or m21 is different than 0 . In the other transformation (e.g. scale or translate) it stays at 0.

Although, I'm not a matrix transformation expert so I may be mistaken

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

Test Plan:
I've written several views with all rotateX/Y/Z , skewX,Y and perpective transformation. Before the PR some transformation was showing aliasing on iOS (e.g. top-left view in the screenshot, don't hesitate to zoom in the image if you don't see it) and with this PR it does not have anymore

Before

![Simulator Screen Shot - iPhone 13 - 2022-01-19 at 10 09 35](https://user-images.githubusercontent.com/6890533/150100149-5370c0fc-ba4f-499f-8e41-a40a10b466a9.png)

After
![Simulator Screen Shot - iPhone 13 - 2022-01-19 at 10 10 39](https://user-images.githubusercontent.com/6890533/150100229-1bb5077f-d6bb-48a2-b852-acf726fcb59e.png)

Code I used to test

```
const commonStyle = {
  width: 150,
  height: 100,
  backgroundColor: "red",
  margin: 10,
}

const Test = () => (
  <View style={{ flexDirection: "row" }}>
    <View>
      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateZ: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateX: "30deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateY: "30deg" }],
          },
        ]}
      />
      <View
        style={[
          commonStyle,
          {
            transform: [{ rotateX: "30deg" }, { rotateY: "30deg" }, { rotateZ: "3deg" }],
          },
        ]}
      />
    </View>

    <View>
      <View
        style={[
          commonStyle,
          {
            transform: [{ skewX: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ skewY: "4deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ skewY: "4deg" }, { rotateZ: "3deg" }],
          },
        ]}
      />

      <View
        style={[
          commonStyle,
          {
            transform: [{ perspective: 1000 }],
          },
        ]}
      />
    </View>
  </View>
)
```

Reviewed By: lunaleaps

Differential Revision: D33665910

Pulled By: sshic

fbshipit-source-id: 91163ec2a0897a73ddf0310d86afacea04b89bc7
2022-01-24 07:21:57 -08:00
Moses DeJong 95585a9730 Avoid self capture in blocks that would extend RCTDevSettings instance lifetime.
Summary:
Avoid self capture in blocks that would extend RCTDevSettings instance lifetime.

Changelog:
[iOS][Fixed] - Use weakSelf in objc block instead of self.

Reviewed By: RSNara

Differential Revision: D33594868

fbshipit-source-id: 2dce135ae88337a09fb2f3e9462e10a4692bc7a7
2022-01-20 15:39:51 -08:00
Liam Jones 9d2df5b8ae Fix for iOS displaying a RedBox for LogBox handled errors (#32641)
Summary:
Fix for iOS displaying a RedBox for LogBox handled errors, this has been happening since RN 0.65 (in 64.2 and earlier, if it was handled by LogBox then it wouldn't trigger RedBox)

Fixes https://github.com/facebook/react-native/issues/32106

## Changelog

[iOS] [Fixed] - Stop RedBox from appearing for LogBox handled errors

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

Test Plan: Manually tested. Seems to fix things (and RedBox still displays for things like 'Could not connect to development server') but I would appreciate RSNara or someone else who is more familiar with the code to confirm that the original switch was a mistake and not something deliberately changed.

Reviewed By: christophpurrer

Differential Revision: D33661481

Pulled By: cortinico

fbshipit-source-id: c9c262adb3f977ae3f13beb9575d3eaa2445f663
2022-01-19 12:17:03 -08:00
Pieter De Baets 3addafa525 Support constructing UIEdgeInsets with single value
Summary:
This is only required in the old renderer, as in Fabric the parsing behaviour is shared across platforms (https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L264). JS changes are following in D33453327.

Changelog: [iOS][Fixed] Enable hitSlop to be set using a single number.

Reviewed By: philIip

Differential Revision: D33453326

fbshipit-source-id: f15a4fd1d26dcac6f40b064be1a8266051b6aedf
2022-01-19 03:08:31 -08:00
Asaf Korem a46a99e120 fix(iOS): remove alert's window when call to `hide`. (#32833)
Summary:
Resolves this issue: https://github.com/facebook/react-native/issues/32304.
**NOTE:** This PR is based on a prior PR for this fix: https://github.com/facebook/react-native/pull/32305, I've co-authorized its creator for this change (paddlefish).

Without this change, calling to hide an alert, leaves a `UIWindow` that blocks user interactions with the screen.

The correct way to remove a `UIWindow` in iOS is to set its hidden property to `YES`. Also, it is required to remove all references to the window (the associated `windowScene` for example) and ARC will automatically free this `UIWindow`.

The line after this change, set the `_alertWindow` reference to `nil`, but the window is already associated with a scene (see the screenshots from [this PR](https://github.com/facebook/react-native/pull/32305#discussion_r720521707)). So we also need to remove the `windowScene` from that window, as recommended by Apple: https://developer.apple.com/documentation/uikit/uiwindowscene/3198091-windows.
>To remove the window from the current scene, or move it to a different scene, change the value of the window's windowScene property.

## 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] - remove alert's window when call to `hide`.

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

Test Plan: See https://github.com/facebook/react-native/pull/32305

Reviewed By: hramos

Differential Revision: D33460430

Pulled By: lunaleaps

fbshipit-source-id: b13c2c7ee6404f1e1c787265bc4af8a31005bcf1
2022-01-19 01:09:17 -08:00
Ramanpreet Nara 6b42bcc1f4 Fix NVC for RCTModalHostView
Summary:
## iOS Failure
```
 LOG  SVC RCTModalHostView Invalid
 LOG  {
  "missing": {},
  "unexpected": {
    "validAttributes": {
      "statusBarTranslucent": true,
      "hardwareAccelerated": true,
      "animated": true
    }
  },
  "unequal": {}
}
```

Reviewed By: sshic

Differential Revision: D33409398

fbshipit-source-id: 4651878207d0dca1a559fef2191f7538217c093a
2022-01-14 16:31:50 -08:00
Ramanpreet Nara 28f5abc717 Fix NVC for RCTSlider
Summary:
## Android Failures
```
LOG  SVC RCTSlider Invalid
 LOG  {
  "missing": {
    "directEventTypes": {
      "topSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    }
  },
  "unexpected": {
    "bubblingEventTypes": {
      "paperValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      },
      "topValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      }
    },
    "directEventTypes": {
      "paperSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    },
    "validAttributes": {
      "disabled": true,
      "maximumTrackImage": {
        "process": "[Function resolveAssetSource]"
      },
      "minimumTrackImage": {
        "process": "[Function resolveAssetSource]"
      },
      "thumbImage": {
        "process": "[Function resolveAssetSource]"
      },
      "trackImage": {
        "process": "[Function resolveAssetSource]"
      }
    }
  },
  "unequal": {}
}
```

## iOS Failures
```
 LOG  SVC RCTSlider Invalid
 LOG  {
  "missing": {},
  "unexpected": {
    "bubblingEventTypes": {
      "paperValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      }
    },
    "directEventTypes": {
      "paperSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    },
    "validAttributes": {
      "enabled": true
    }
  },
  "unequal": []
}
```

Reviewed By: yungsters

Differential Revision: D33409401

fbshipit-source-id: 519b6e35246e6671dbea1f374435d92937d96c1d
2022-01-14 16:31:50 -08:00
Paige Sun 6be46b0bb5 Comments only. Clarify a few Venice and SVC methods
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D33468276

fbshipit-source-id: bcc62ba1e728bba2492dbbbb0e4569285effeca7
2022-01-07 17:41:55 -08:00
Ramanpreet Nara ca5aaa7663 Remove {eventName}: true from ViewConfig validAttributes
Summary:
For every direct and bubbling event, RCTComponentData (iOS-only) creates a {eventName}: true entry in the component's ViewConfig validAttributes. This entry is unnecessary, and creates a discrepancy between ViewConfigs on iOS vs Android.

This diff removes this entry for all events to:
1. Reduce bloat in native ViewConfigs
2. Create consistency betweeen Android and iOS.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33303950

fbshipit-source-id: 870c8a2a6d41156ac89bd8554eb09f292bb6108e
2022-01-06 19:09:53 -08:00
Andres Suarez e22b760e59 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33372796

fbshipit-source-id: 51a515be3d570b53b238302a22975ec91099df06
2021-12-31 14:42:42 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Samuel Susla 8c6a98400e Introduce TextInput.onChangeSync
Summary:
changelog: [internal]

Add experimental `TextInput.onChangeSync` which delivers onChange event synchronously.

Reviewed By: ShikaSD

Differential Revision: D33188083

fbshipit-source-id: 1e1dcd0d71c7eec98d3d5f69967659e07ac4e6a6
2021-12-30 06:38:50 -08:00
CodemodService FBSourceClangFormatLinterBot 725bffce51 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D33316567

fbshipit-source-id: cfeb96eb2adc7539b97d3a8f0de6710cd5f6ce5b
2021-12-25 08:28:35 -08:00
Richard Howell e60f0f5034 cast implicit int to CGFloat conversions [3/3]
Summary: Insert casts for implicit int -> CGFloat conversions. This warning category is generally benign and explicitly casting will preserve existing behavior.

Reviewed By: NSProgrammer

Differential Revision: D33303887

fbshipit-source-id: b21adbcf754e707adfe3f8eaa0fe9c3a65380cc5
2021-12-24 09:19:42 -08:00
Kevin Gozali fb39d45ed5 C++ - better => butter
Summary:
Renaming the `better` utilities to `butter`:
- to prevent claims that this library is superior to others - it really depends on use cases
- to indicate ease of use throughout the codebase, easily spread like butter

Changelog: [C++][Changed] Renaming C++ better util to butter, used by Fabric internals

Reviewed By: JoshuaGross

Differential Revision: D33242764

fbshipit-source-id: 26dc95d9597c61ce8e66708e44ed545e0fc5cff5
2021-12-20 22:25:14 -08:00
Luna Wei 3204c55981 Remove usages of bump-oss-version from generated scripts
Summary: Changelog: [Internal] - Update the source of the changes in generated files, no longer bump-oss-version but set-rn-version

Reviewed By: sota000

Differential Revision: D33110408

fbshipit-source-id: 8cd5004f5d40dde82fe4d6271d5b8598cd27ca31
2021-12-17 18:37:37 -08:00
Samuel Susla b3e996496c Fix implicit type conversion in RCTSliderComponentView
Summary:
changelog: [internal]

Just getting rid of some implicit type conversions and using std::max and std::min instead of macros.

Reviewed By: philIip

Differential Revision: D33161766

fbshipit-source-id: c72011c54f35a145afa236f1dc3d185b19e46cc3
2021-12-17 05:30:55 -08:00
Sota Ogo 41cad354e5 Fix the default template when RCT_NEW_ARCH_ENABLE=1 (#32775)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32775

Changelog: [Internal] Fix build issues for the new app template with the new architecture enabled

Reviewed By: philIip

Differential Revision: D33157325

fbshipit-source-id: ee63f38fbfc088ca193dfa1b48f4b6611257b787
2021-12-16 15:10:49 -08:00
Phillip Pan 0912ee179c remove fallbackResource from RCTBundleURLProvider api
Summary:
if you xgbs for `fallbackResource:`, you'll find only one place is actually passing a non-nil value to this parameter.

https://www.internalfb.com/code/fbsource/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/FBReactSourceLoaderProd.mm?lines=79

but if we look at the implementation, `@"main"` is the fallback value...

https://www.internalfb.com/code/fbsource/[cd930f5f15cca0feb732317147de318ce6aa1db3]/xplat/js/react-native-github/React/Base/RCTBundleURLProvider.mm?lines=224

let's just simplify this api and get rid of this parameter.

Changelog: [Internal]

Reviewed By: raedle

Differential Revision: D32641476

fbshipit-source-id: 637a8c0f7bea834bfecd804a521155f41aaaff7e
2021-12-16 00:46:14 -08:00
Sota Ogo 1cd8f05ee8 Refactor app template setup util functions
Summary:
Changelog: [internal] Refactor RCTAppSetupUtils to c functions.

Since RCTAppSetupUtils doesn't retain any states, we don't need it to be a class.

Reviewed By: philIip

Differential Revision: D33084352

fbshipit-source-id: 1372a2737eafffa46ee6e5164a970dd12699c71c
2021-12-15 18:14:36 -08:00
Sota Ogo c0c5439959 Rename the new architecture flag to RCT_NEW_ARCH_ENABLED
Summary: Changelog: [internal] Changed teh new architecture flag in the new app template to RCT_NEW_ARCH_ENABLED

Reviewed By: philIip

Differential Revision: D33083694

fbshipit-source-id: f2cc6c564c724b4ebed7b465a533464b6717ac27
2021-12-15 18:14:36 -08:00
Sota Ogo 2e9a376c84 Add fabric option to the default app template.
Summary:
Changelog: [internal] Added fabric option to the default app template.

Use RCT_TM_FABRIC_ENABLED C++ flag to enable fabric.

Reviewed By: sammy-SC

Differential Revision: D33052956

fbshipit-source-id: 28313829c80abcf02baa521bdb0b70213c94a97f
2021-12-15 18:14:35 -08:00
Sota Ogo 8ec0e6919c Add turbo module support in the default app template (#32752)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32752

Changelog: [internal] Add an optional support for Turbomodule. Define RCT_TM_FABRIC_ENABLED to enable the new architecture.

Reviewed By: philIip

Differential Revision: D33052777

fbshipit-source-id: 6d32790586bb51f9c9244344522c95245c912114
2021-12-15 18:14:35 -08:00
Adam Cmiel b1ecac9d14 replace __nullable with _Nullable
Summary:
Modernize our null annotations
From the swift blog:
This feature was first released in Xcode 6.3 with the keywords nullable and nonnull. Due to potential conflicts with third-party libraries, we’ve changed them in Xcode 7 to the _Nullable and _Nonnull you see here.
drop-conflicts

Reviewed By: cuva

Differential Revision: D33121042

fbshipit-source-id: 821f5ec858d9afd5bfb1d6081c669f4ca18a36ed
2021-12-15 15:13:43 -08:00
Samuel Susla 102b9f3256 Fix type conversion in RCTViewComponentView
Summary:
changelog: [internal]

[CALayer opacity] is of type `float`, not `CGFloat`.

Reviewed By: philIip

Differential Revision: D33058967

fbshipit-source-id: 98b214e32f6d35e904a7abb0e01c2d01da50a285
2021-12-14 07:30:42 -08:00
Sota Ogo 73a04d1452 Refactor the iOS app template to move setups to a helper class
Summary:
Changelog: [internal] Move initital setups in AppDelegate to util classes.

This will make it easy to apply the new architecture changes in the future.

Reviewed By: cortinico

Differential Revision: D33051517

fbshipit-source-id: 16e326b7816fae83df65450c545e7dce1a93b9d0
2021-12-13 23:13:32 -08:00
Andrei Shikov 1d4e7f6d40 Use reference for command args
Summary:
The IDE warning suggests that passing folly::dynamic by value will create a copy on each call.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D32978154

fbshipit-source-id: a47a60c332a9d299eb2110d3537dfab0bc2398b6
2021-12-09 09:47:38 -08:00
Paige Sun 60e60a9b3d Refactor: Assign string label to each case in RCTPLTag enum for startup performance logging
Summary:
`_labelsForTags` is an array with string labels used only for local profiling, that we had to manually keep it in sync with `RCTPLTag`. Refactor so labels are assigned with switch instead.

Changelog: [iOS] Refactor: Assign string label to each case in RCTPLTag enum for startup performance logging

Reviewed By: fkgozali

Differential Revision: D32889043

fbshipit-source-id: 81da592a160a31b91e78289be0990cc2ff960f29
2021-12-08 14:51:04 -08:00
Samuel Susla f5f6fd70f2 Introduce TextInput.onKeyPressSync
Summary:
changelog: [internal]

Introduce a way to execute `onKeyPress` synchronously. This feature is experimental and will be changed in the future. It is not decided if marking native events as "sync" is going to be path forward with synchronous access.

NOTE: This is experimental API.

Reviewed By: ShikaSD

Differential Revision: D32882092

fbshipit-source-id: 68c66a9bb7c97758219e085c88a77f3c475c1eb3
2021-12-07 13:42:18 -08:00
Marc Rousavy 49a1460a37 Feature: ScrollView `automaticallyAdjustKeyboardInsets` (#31402)
Summary:
Retrying D30015799 (6e903b07fa) with a fix where ScrollViewNativeComponent was missing the automaticallyAdjustKeyboardInsets prop.
----- Original 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: D32578661

Pulled By: sota000

fbshipit-source-id: 45985e2844275fe96304eccfd1901907dc4f9279
2021-12-06 13:31:13 -08:00
Samuel Susla 387e79f8aa Remove background_executor flag
Summary:
changelog: [internal]

Background executor has been shipped on both platforms for a long time.
I've kept the flag around because I wanted to run tests and compare Concurrent Mode vs Background Executor. The intention was to see if we can get rid of Background Executor to simplify the threading model.

Since then, React team has moved away from Concurrent Mode towards more gradual rollout of concurrent rendering and it no longer makes sense to do this comparison. Right now, we don't have a concern with concurrent rendering and Background Executor. If we ever want to run the an experiment, this gating will need to be added again.

Reviewed By: javache

Differential Revision: D32674798

fbshipit-source-id: a1e51c9c5b8e48efa4cb0f25379d58e7eb80ccd9
2021-12-02 15:32:28 -08:00
Marc Rousavy 1721efb54f fix: Use same implementation for `performance.now()` on iOS and Android (#32695)
Summary:
I've noticed that the `performance.now()` implementations differ on iOS and Android.

iOS:
```objc
PerformanceNow iosPerformanceNowBinder = []() {
  // CACurrentMediaTime() returns the current absolute time, in seconds
  return CACurrentMediaTime() * 1000;
};
```
Android:
```c++
double reactAndroidNativePerformanceNowHook() {
  auto time = std::chrono::steady_clock::now();
  auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
                      time.time_since_epoch())
                      .count();

  constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;

  return duration / NANOSECONDS_IN_MILLISECOND;
}
```

For consistency, I thought why not just use the same implementation on both iOS and Android.

It also seems more logical to use Chrono on iOS, since it has nanosecond precision and we just multiply it to milliseconds, whereas `CACurrentMediaTime` multiplies to seconds, and we divide it down to milliseconds again.

## Changelog

(internal change only)

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

Test Plan:
Run on iOS and Android:

```ts
const now = global.performance.now()
console.log(`${Platform.OS}: ${now}`)
```

Reviewed By: feedthejim

Differential Revision: D32793838

Pulled By: ShikaSD

fbshipit-source-id: e7967780be95956a75a3a3757311af0077976d23
2021-12-02 12:32:29 -08:00
David Ashinsky 5da4872775 Restore react native override preference when live shopping ends.
Summary:
The current implementation of the prelive composer is setting the RN override preference to nil when live shopping ends. However, if the user had a previously set appearance override, this would clear it out.

To resolve this, I cache the user's override preference before we override it, and restore it when live shopping ends.

Additionally, I'm adding a missing callback to restore the override pref when live shopping is dismissed, but not cancelled.

Changelog:
[ReactiveNative][Appearance] - Add function to retrieve overridden RN appearance

Differential Revision: D32564739

fbshipit-source-id: d0b4e06d2bbadad68f172d951609cba3e4587e5d
2021-12-02 07:20:05 -08:00
Peter Carpenter 4d1357918a feat: support queuing accessibility announcements on ios (#32637)
Summary:
The current implementation of `AccessibilityInfo.announceForAccessibility` will immediately interrupt any existing in progress speech with the announcement. Sometimes this is desirable behaviour, but often you will want to wait until existing speech is finished before reading the new announcement. This change gives us that option.

My personal use case for this feature is a custom text input. When typing on iOS with voiceover enabled, each character is read out after being selected. I wanted to add some additional information after each character to help with the context of what has changed in the input, but I didn't want to override the reading of the character itself.

This feature is supported natively on iOS by constructing an `NSAttributedString` with the property [`accessibilitySpeechQueueAnnouncement`](https://developer.apple.com/documentation/foundation/nsattributedstring/key/2865770-accessibilityspeechqueueannounce), so this change just adds an extra parameter to `AccessibilityInfo.announceForAccessibility` which controls the value of that property on the native side. Adding this as an extra optional parameter with false as the default ensures that existing uses of the function won't be affected.

Unfortunately, this feature doesn't appear to be supported on Android, so the new second property will be iOS only.

## Changelog

[iOS] [Added] - add new argument to announceForAccessibility to allow queueing on iOS

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

Test Plan:
I've updated the `announceForAccessibility` section in RNTester with multiple buttons to demonstrate the difference between `queue: false` (default) and `queue: true` and show they work as intended.

Here's the expectation for each button:

- "Announce for Accessibility Immediately": on press, should start reading the button label, then be interrupted by the announcement
- "Announce for Accessibility Queued": on press, should read the button label then read the announcement afterwards
- "Announce for Accessibility Queue Multiple": on press, should read the button label, then read three announcements sequentially, no interruptions

You can see the realisation of those expectations in the following video recorded on an iPhone 12 running iOS 15.0.2:

https://user-images.githubusercontent.com/14826539/142770536-d57bfd69-eba5-444d-9c89-4bf4851ea062.mov

I've also tested the same way on an iPhone 8 running iOS 13.4 and it works exactly the same.

Reviewed By: yungsters

Differential Revision: D32637989

Pulled By: philIip

fbshipit-source-id: 3e90add523f11eb0eb34ea623211249263f257e2
2021-12-02 00:34:05 -08:00
Samuel Susla 1989ad3955 Attempt to fix a crash in Scheduler::uiManagerDidCloneShadowNode
Summary:
changelog: [internal]

Attempt at fixing a crash in `Scheduler::uiManagerDidCloneShadowNode` by setting delegate to nullptr explicitly.

I don't think this will make a difference because `scheduler_` is released at the end of `dealloc` but it is worth a shot. Maybe some complex interaction between Obj-C and C++ comes into play here.

In this diff I also removed `_animationDriver = nullptr` because dealloc will do that automatically.

Reviewed By: philIip

Differential Revision: D32720901

fbshipit-source-id: 227ced2331384c47e8d15a323ee8a621bbb3d179
2021-12-01 03:09:47 -08:00
Sota Ogo 0ff02f9a41 Add log function binding to Facebook App
Summary:
Adding the RCTLog binding to Facebook app. More context is in D30271863 (c317a709d5)

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31299188

fbshipit-source-id: 5234242e2f82262f9d2538e6c689f4a3738f37bb
2021-11-29 14:42:10 -08:00
Samuel Susla 3ba237b663 Remove gating for subview clipping
Summary:
changelog: [internal]

Remove gating for subview clipping

Reviewed By: philIip

Differential Revision: D32594194

fbshipit-source-id: e35e698cc3303f289cdd44a7f34274ea046dfd81
2021-11-25 08:08:56 -08:00
Christoph Purrer 3fff164dfa RCTDisplayLink.m > Use autoreleasepool from CFRunLoopPerformBlock
Summary:
Changelog:
[iOS][Fixed] This is a quick speculative fix since we know `CFRunLoopPerformBlock` does not push/pop an autorelease pool.

Reviewed By: appden

Differential Revision: D32657298

fbshipit-source-id: 4641ad89baf7889ba4bf80e6e64e26de02818cb8
2021-11-24 16:57:43 -08:00
Phillip Pan b8f0e975b7 use NSInteger for NS_ENUM instead of NSUInteger
Summary:
as title

in practice, this doesn't make any difference, but this is to follow the apple recommendation and for us to have a more consistent codebase.

https://developer.apple.com/library/content/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html

>The NS_ENUM macro helps define both the name and type of the enumeration, in this case named UITableViewCellStyle of type NSInteger. The type for enumerations should be NSInteger.
>Like enumerations, the NS_OPTIONS macro defines both a name and a type. However, the type for options should usually be NSUInteger.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32641990

fbshipit-source-id: 56e4cd44cdefe54f61c90844665a685ee2d6ffad
2021-11-24 15:45:23 -08:00
Phillip Pan d4c1c5f686 clean up RCTBundleURLProvider
Summary:
a lot of unused code here, cleaning it up

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32640185

fbshipit-source-id: 2917b4e3ea9c08ccb520250de509f0253d5dae61
2021-11-24 15:35:28 -08:00
CodemodService FBSourceClangFormatLinterBot 52b78a0bb7 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D32638856

fbshipit-source-id: a362894018de2a2ce144e90363a7978d8e4da25b
2021-11-24 04:45:45 -08:00
Phillip Pan 749a9207b6 introduce RCTMockDef
Summary:
here's a way we can mock C apis - however i am not sure if the flag i'm using is correct

used in D31949237

Changelog:
[General][Added] - add macros to be able to stub C functions in tests

Reviewed By: RSNara

Differential Revision: D31949238

fbshipit-source-id: 0f18a65f810f1b855dbc844f11f5a304c1e5ecea
2021-11-23 22:33:54 -08:00
Paige Sun 160807d112 Add ReactMarker::LogTaggedMarkerBridgeless, to replace LogTaggedMarkerWithInstanceKey
Summary:
# Issue in iOS
Before this diff, [Venice would override](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTPerformanceLoggerUtils.mm?lines=52%2C57) the static function ReactMarker::LogTaggedMarker [created in CxxBridge](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/xplat/js/react-native-github/React/CxxBridge/RCTCxxBridge.mm?lines=179%2C183). This means that in mixed mode they would share the Bridgeless instance of RCTPerformanceLogger [owned by Venice-only RCTInstance](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTInstance.mm?lines=65%2C73).

This is wrong because Bridge is supposed to use the instance of RCTPerformanceLogger [owned by RCTBridge](https://www.internalfb.com/code/fbsource/[73ab70b2d9e28569171b62f60e9f25744461d4d9]/xplat/js/react-native-github/React/Base/RCTBridge.m?lines=353).

# Fix iOS and refactor Android

1) Add LogTaggedMarkerBridgeless to use the bridgeless RCTPerformanceLogger.

2) Use LogTaggedMarkerBridgeless to replace logTaggedMarkerWithInstanceKey.
- Remove logTaggedMarkerWithInstanceKey because it always clear from the code that instanceKey is 0 for Bridge, and 1 for Bridgeless,
- iOS doesn't use instanceKey and keeps separate instances of FBReactBridgeStartupLogger, FBReactWildePerfLogger, and RCTPerformanceLogger instead. This is better than using instanceKey because they are all [deallocated when Bridgeless is invalidated](https://www.internalfb.com/code/fbsource/[ea436e5ea6ae4ebc5e206197c4900022be867135]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=1160%2C1167%2C1170).
- logTaggedMarkerWithInstanceKey is only called from Venice's ReactInstance.cpp so it's easy to remove.

Reviewed By: sshic

Differential Revision: D32588327

fbshipit-source-id: 3151a44c9796da88fef4459b9b56946861514435
2021-11-23 12:55:56 -08:00
Phillip Pan 31b64c2615 kill RCTFabricSurfaceHostingView
Summary:
after D32591685, no one is using this. delete

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D32591686

fbshipit-source-id: 11ffb8cbf0fef605b7aefa47347db3ccc6e7d7fe
2021-11-23 02:29:25 -08:00
Phillip Pan 437b06f397 hook up onScroll event to RCTTextInputComponentView
Summary:
fixing oncall issue: https://fb.workplace.com/groups/rn.support/permalink/7241260632589156/

in this diff, we hook up the event emitter onScroll event to the native text input view

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32523146

fbshipit-source-id: d8035deacc8a511577a6fb892ac55c9e07b14392
2021-11-19 11:41:26 -08:00
Sota Ogo 85ce4ef4b6 use the third party provider in OSS
Summary:
This diff actually adds the usage of ThirdPartyFabricComponentsProvider. We cannot land this until we start using generate-artifacts.js at pod install time.

Changelog: [internal]

Reviewed By: hramos

Differential Revision: D32128889

fbshipit-source-id: 9af39d73c8b5fe3ff9d70190fd83f679914bfd27
2021-11-17 14:49:34 -08:00
Saad Najmi 70ddf46c8a Revert "Fix Deadlock in RCTi18nUtil (iOS) (#31032)" (#32574)
Summary:
This reverts commit fcead14b0e.

This should close https://github.com/facebook/react-native/issues/32509 . There was a bug where il8nManager.forceRTL() wouldn't work on app launch, and required an app restart. That was caused by an earlier change (https://github.com/facebook/react-native/pull/31032) which should not be necessary (the deadlock it was attempting to fix was actually caused by separate code).

## 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] - Fixed bug where forceRTL did not work on app launch

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

Test Plan: Simple revert back to previously working code.

Reviewed By: RSNara

Differential Revision: D32315034

Pulled By: GijsWeterings

fbshipit-source-id: dae6c1f0a2481e53f2f1e80f1ac083947681ef99
2021-11-15 08:08:11 -08:00
Nick Fujita 614e6025ab Fix RCTAlertController import when embed in existing iOS projects (#32457)
Summary:
Fixes a build error relating to RCTAlertController import when embedding react-native into existing iOS app. This PR resolves the issue detailed in https://github.com/facebook/react-native/issues/32356

## Changelog

Adjusts the import syntax which was added in:
f319ff321c (diff-56beca6ee071cdd162c269ce765ab12d5af8c8c0ca840bca1e9d1f59e9fab790)

Existing:
#import "RCTAlertController.h"

New:
#import <React/RCTAlertController.h>

[iOS] [Fix] - Fix RCTAlertController import build error when embedded in existing iOS projects

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

Test Plan:
Build this branch in existing iOS project using swift, and should not have the build error described in the issue above.

Would also like to have this fix cherry-pick'd to release 0.63 after merging.

Reviewed By: RSNara

Differential Revision: D31861814

Pulled By: charlesbdudley

fbshipit-source-id: e60f80c8ea982e400cbf6d9375037d4197bbb8a3
2021-11-11 15:30:50 -08:00
Sota Ogo 751708d779 Use dummy file for FBReactNativeSpecs.podspec so that it doesn't include any files even there are old files.
Summary:
FBReactNativeSpecs.podspec is currently only acting as a config for codegen. It should not include any sources. This would fix unintended build error related to FBReactNativeSpecs-generated file.

Changelog: [internal]

Reviewed By: philIip

Differential Revision: D32267102

fbshipit-source-id: 27b510198666dc26a890cd7a6f873a04a9df66ca
2021-11-11 14:15:57 -08:00
Liron Yahdav f249d21da0 Native changes for TextInput.setSelection method
Summary:
Native changes in preparation for adding a `setSelection` imperative method to `TextInput`.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D31590771

fbshipit-source-id: eed40d1c2803fec713f2008ab8053a2812249715
2021-11-11 13:35:46 -08:00
Phillip Pan f10741a946 replace contentInsetsForView: with RCTContentInsets()
Summary:
as title

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949240

fbshipit-source-id: 2660a4b44fd2aad5cda52ec61e741e7b4e9eb442
2021-11-10 13:56:52 -08:00
Phillip Pan 83fab36b93 clean up unneeded imports in RCTView
Summary:
just cleaning up some unused stuff

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949239

fbshipit-source-id: f6542a01a879cd9ee10903d99de32e6537aa573b
2021-11-10 12:01:07 -08:00
Phillip Pan 9fc3fc83ac introduce RCTViewUtils
Summary:
Changelog: [Internal]

in this diff, i convert the following method to a C function.
https://www.internalfb.com/code/fbsource/[c58818169205f1e0fa816968efdb4c3fac8333e9]/xplat/js/react-native-github/React/Views/RCTView.h?lines=43

besides for testing demonstration purposes later in the stack, C functions are a superior choice to static class methods because they incur less binary size cost (see section 4.3 of https://swolchok.github.io/objcperf/ if you're curious, and https://fb.workplace.com/groups/aexpixfn/posts/1909150855887748 for the impact of a conversion)

Reviewed By: RSNara

Differential Revision: D31949241

fbshipit-source-id: dd40871d48f1de168d360168c4dd60015145d7e3
2021-11-09 20:42:13 -08:00
Ken Tominaga 9b059b6709 Remove iOS 11 availability check (#32488)
Summary:
This pull request aims to remove iOS 11 availability 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 (available(iOS 11.0, *)) {
```

This is a continuation pull request of https://github.com/facebook/react-native/pull/32151

## 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] [Changed] - Remove iOS 11 availability check

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

Reviewed By: yungsters

Differential Revision: D32006312

Pulled By: ryancat

fbshipit-source-id: 0ee6579e433a15d3d220a52d2ccd6931b0513971
2021-11-03 09:06:06 -07:00
Sota Ogo f7e4c07c84 Move codegen output out of node_modules
Summary:
In this diff, it moves the codegen output location out of node_modules and to build/generated/ios folder.

A temp pod spec will be created so that those files will be included in the Xcode project.

Changelog: [Internal]

Reviewed By: hramos, cortinico

Differential Revision: D31809012

fbshipit-source-id: ba1c884c8024306ba0fd2102837b7dbebc6e18ac
2021-10-25 20:48:24 -07:00
CodemodService FBSourceClangFormatLinterBot 64711b0d98 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31891742

fbshipit-source-id: f6f6ad019e972de5acc8d04f0e8c8d9c9a2e3324
2021-10-25 04:08:21 -07:00
Andrew Rahn 72ea0e111f Hide the logbox window explicitly. New behavior in iOS SDK appears to… (#32435)
Summary:
Fixes  https://github.com/facebook/react-native/issues/32434: RCTLogBox window is orphaned, covering entire screen.

After this change, the logbox window once again is removed from the screen.

## Changelog

Some third-party SDKs may hold references to created UIWindow, UIViewController, or UIView objects. Doing so means that the current code's `hide` method that releases the reference to the UIWindow in LogBox will not cause the window to be dealloc'd, and thus instead it will remain on the screen. This change explicitly hides the LogBox window when the reference is released, so that even if some other SDK holds onto the window it will still be taken off the screen.

<!-- 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] - 32434

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

Test Plan:
1.     Use console.warn to generate a yellow warning message in log box.  Also install a third-party SDK that holds onto a reference to UIWindow -- for example the Facebook SDK, the Data Dog SDK, or any number of other SDKs that use `swizzling` to intercept calls like `viewDidAppear:`.
2.     click the log
3.     tap "dismiss"
4.     try to tap anywhere
5. Use Xcode view debugger to inspect the UI state

## Expected

The app still responds to the touch.
In Xcode, there is not an extra UIWindow covering the screen

Reviewed By: philIip

Differential Revision: D31794242

Pulled By: sshic

fbshipit-source-id: 28aa247b3ed3fd60b8e7c2ed7d0606cbf5c42408
2021-10-24 13:52:40 -07:00
Phillip Pan def7dd857d use new instead of alloc init
Summary:
i saw this a lot in the codebase, it's not optimal bc we're using two selectors when we only need one.

  fastmod --extensions m,mm '\[\[(.*) alloc] init]' '[${1} new]' --dir xplat/js/react-native-github/*

i manually updated the callsites that this codemod couldn't handle (e.g., where there were more than one of these instances in a single line)

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31776561

fbshipit-source-id: 1b16da240e8a79b54da67383d548921b82b05a9f
2021-10-20 22:18:38 -07:00
Phillip Pan 6acb18ca5d do not return BOOL for start and stop methods
Summary:
Changelog: [Internal]

these are returning bools for some reason even though no one is using the returned value. changing them to return void

Reviewed By: RSNara

Differential Revision: D31594241

fbshipit-source-id: 04c115b573b74996eaf2fef631eedb12c6734ea8
2021-10-20 15:42:22 -07:00
Phillip Pan f1aabc5164 remove unnecessary public methods on RCTFabricSurface
Summary:
Changelog: [Internal]

`start` and `stop` are already part of `RCTSurfaceProtocol` which is a public protocol conformance, we don't need to add these to this header, it's just extra work for the compiler

Reviewed By: RSNara

Differential Revision: D31776005

fbshipit-source-id: d89ad4dbe35e1b67cfa750c6414c40f9b4fc7f24
2021-10-20 15:42:22 -07:00
Phillip Pan f3eb675d23 clean up RCTFabricSurface imports
Summary:
Changelog: [Internal]

making these imports a little more optimal & clean

Reviewed By: javache

Differential Revision: D31594240

fbshipit-source-id: 076610454a6f3c35ac58e97bd9f887b05b86f5bb
2021-10-15 16:15:37 -07:00
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
Samuel Susla b7616242aa Remove redundant includes
Summary:
changelog: internal

Removing unused headers. Fewer headers = faster compilation

Reviewed By: p-sun

Differential Revision: D30398600

fbshipit-source-id: a64801e49d283ad1e2d0cb9c9d688445e30bf0ed
2021-08-20 03:02:02 -07:00
Jimmy Zhang f085e09be5 Passing the scheme field throughout all the metro connection pipeline to allow different scheme other than the default hardcoded http
Reviewed By: lunaleaps

Differential Revision: D30218490

fbshipit-source-id: 3832c731156a4f88ad1c55be0a0e4f68fa3e1d48
2021-08-19 10:28:49 -07:00
Nishan Bende c29ec46b0e fix#29319 - ios dismiss modal (#31500)
Summary:
This PR aims to resolve iOS can't dismiss Modal on swipe gesture.
https://github.com/facebook/react-native/issues/29319

When modal presentationStyle is pageSheet, iOS allows to dismiss the modal using swipe gesture. This PR adds support for that feature
## 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] [Added] - Support for onRequestClose for iOS Modal component.

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

Test Plan:
- If onRequestClose updates the visibility state, modal will be closed.

```
<Modal
    visible={visible}
    animationType="slide"
    presentationStyle="pageSheet"
    onRequestClose={dismiss}>
</Modal>
```

https://user-images.githubusercontent.com/23293248/117590263-36cd7f00-b14c-11eb-940c-86e700c0b8e7.mov

## Notes
- In this PR, only support for partial drag is added. i.e. user can't drag the modal up and down completely. I added full user dragging but reverted in this [commit](bb65b9a60d) to support controllable onRequestClose. If someone has any suggestion to have full draggable support + controllable onRequestClose, please let me know.

<!--

 the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->

Reviewed By: p-sun

Differential Revision: D30041625

Pulled By: sammy-SC

fbshipit-source-id: 9675da760bd5c070c4f0e1d30271c8af5c50b998
2021-08-16 11:25:57 -07:00
Ikko Ashimine ecd6927b9a Fix typo in RCTConvert.m (#31067)
Summary:
seperated -> separated

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - Fixed typo in comment

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

Test Plan: NONE

Reviewed By: sammy-SC

Differential Revision: D30176244

Pulled By: sota000

fbshipit-source-id: 617607aaa7eb5f613344773c4bbbc09a8c5096c1
2021-08-13 16:29:41 -07:00
Saad Najmi fcead14b0e Fix Deadlock in RCTi18nUtil (iOS) (#31032)
Summary:
Note: PR to react-native-macos here https://github.com/microsoft/react-native-macos/pull/733

Internally in Microsoft code, we ran into a deadlock where the main queue and the UIManager queue were both trying to access `[RCTI18nUtil sharedInstance]`, and were blocked on each other. This is similar to an earlier issue with RCTScreenScale decsribed [here](https://github.com/facebook/react-native/issues/18096).

To summarize:
1- RCTShadowView (on the UIManager queue) and RCTView (on the main queue) both try to access `[RCTI18nUtil sharedInstance]`
2- The UIManager thread gets there first, and lazily initializes the sharedInstance. Meanwhile, the main thread is waiting on a lock possessed by the UIManager thread
3- As part of the initialization, we set an NSUserDefault, which seems to require the (blocked) main thread.
4- Deadlock.

For whatever reason, this only happens on debug. I did not figure out why, but I do know based on [this comment](https://github.com/facebook/react-native/issues/18096#issuecomment-368718081), that the UIManagerQueue should never block the main queue.

The fix is to not use NSUserDefaults, and simpy use atomic properties instead. We get the thread safety for free, and it also simplifies the code somewhat without changing the public API. The downside is values aren't persisted anymore, but I do not think that was necessary / intended.

## 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] - Fix deadlock on RCTi18nUtil

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

Test Plan:
Ran the RTLExample in RNTester, and ensured switching to RTL still worked, and that setting forceRTL would still work after reloading the bundle.

https://user-images.githubusercontent.com/6722175/108775429-aefdae80-7526-11eb-9a89-3114f7ddc2af.mov

Reviewed By: javache

Differential Revision: D29522152

Pulled By: RSNara

fbshipit-source-id: 160840f63a7b1d6721b0fd8294fb11990a4509fa
2021-08-06 02:44:50 -07:00
Moti Zilberman b26ae3e0c9 Move RCT* Buck targets to GitHub
Summary: Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D30030454

fbshipit-source-id: 02a4c36f5c5ca519e4de3d1a3d79708d0d0b6d01
2021-08-04 13:03:21 -07:00
Paige Sun 363a8fb08c iOS: Log error when invalid NSNull data is passed to RCTAsyncLocalStorage
Summary: Changelog: [Internal]

Differential Revision: D30081478

fbshipit-source-id: 7d425e71b020eaeb4eb1b33b500fbf5df7ea9c29
2021-08-03 16:41:32 -07:00
Moti Zilberman d4ee734f32 Merge BUCK file at Libraries/ into root
Summary:
Merges the Facebook-internal Buck target definitions in `Libraries/` into the BUCK file at the root of the repo (which is currently not synced to GitHub at all). This does not affect how React Native is built in open source.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D27967499

fbshipit-source-id: 39c51a544b3868242598072d24cb6cfb5a6e2d8c
2021-08-03 05:42:03 -07:00
Ramanpreet Nara 32bfd7a857 Stop sharing LongLivedObjectCollection with the bridge
Summary:
## Context
Previously, when you'd call TurboModule methods with JavaScript callbacks, we'd [store the callbacks](https://www.internalfb.com/code/fbsource/[c503ff1b38621aebca87b2bbebeae088b01886c4]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm?lines=173%2C248-249) into [this global LongLivedObjectCollection collection](https://www.internalfb.com/code/fbsource/[c503ff1b38621aebca87b2bbebeae088b01886c4]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h?lines=65). Then, when React Native's JavaScript VM got torn down, we'd [clear the global collection](https://www.internalfb.com/code/fbsource/[e26f476ce208c578f05b1edb7639d1dad5612c7d]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp?lines=49), which would ensure that we deleted all held jsi::Functions, before deleting the jsi::Runtime.

## Problem
With bridgeless mode enabled, there can be two TurboModule systems. Further, it is possible to tear down bridgeless mode, or the bridge, without tearing down the other initialization infra. In this scenario, the jsi::Function for the other initialization infra would also get deleted, which could lead to mysterious problems.

## Fix
In this diff, I refactored the jsi::Function cleanup in the TurboModule system. Now, there are 3 modes:
- kGlobalScope: Everything works as it did before
- kRCTGlobalScopeUsingRetainJSCallback: We still use the global LongLivedObjectCollection, but we do it through invoking a block passed to every ObjCTurboModule by the TurboModuleManager. This group exists to assess the impact of having each TurboModule retain/use the block. I suspect this will be negligible, but it'd be good to have actual data to back this claim.
- kRCTTurboModuleManagerScope: Every TurboModule uses a LongLivedObjectCollection that is owned by its TurboModuleManager. This should effectively fix the problem I outlined above.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D30019833

fbshipit-source-id: da50d884c7e37190107f570d8ed70eeda7d9ae83
2021-08-02 11:22:22 -07:00
Jacob Parker feae814153 Remove unused import (#30544)
Summary:
Remove unused import

## 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] [performance] - Remove unused import

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

Test Plan: Should build on CI

Reviewed By: lunaleaps

Differential Revision: D30000901

Pulled By: charlesbdudley

fbshipit-source-id: 3d3310917823b7af57564ca1ea397cd32cd0c4d5
2021-07-29 17:26:02 -07:00
CodemodService FBSourceClangFormatLinterBot ce44104b2b Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D29983521

fbshipit-source-id: bebd38e79180c544c8c1986605cc1af4b1f4df98
2021-07-29 04:23:09 -07:00
Joshua Gross 175b1ea636 Pass PropsParserContext to prop parsing layer
Summary: Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D29921232

fbshipit-source-id: ba045f545b564aedf1b287045a0e75428de30a0f
2021-07-28 20:18:20 -07:00
swittk f1b1ba8963 Makes "force" property available to Apple Pencil based events. (#31780)
Summary:
Fixes https://github.com/facebook/react-native/issues/31779

For more detailed explanation, see issue https://github.com/facebook/react-native/issues/31779

React Native touch handler events (onTouchStart, onTouchMoved, etc..) are intended to have "force" properties when used on devices which support pressure input (3D Touch & Apple Pencil events). However, due to a check in RCTForceTouchAvailable() function which checks for UITraitCollection's "forceTouchCapability" to be equal to UIForceTouchCapabilityAvailable, the check returns NO on iPad-based devices, due to iPad devices returning UIForceTouchCapabilityUnavailable at all times. This causes "force" values of Apple Pencils to never be passed on to React Native.
Since simply passing 0 as a value for force across the RN bridge for every touch event seemed like a change that might seem jarring to some, I decided that a simple additional boolean check if the touch event's type is UITouchTypePencil (this is the same as UITouchTypeStylus) should also suffice.

## 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] - Fixed "force" property of touch events for Apple Pencil/Stylus devices.
[iOS] [Feature] - Added "altitudeAngle" property to touch events from Apple Pencil/Stylus devices.

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

Test Plan:
The code compiles and runs, and trying a simple handler for a View like
````
  touchMove = (e: GestureResponderEvent) => {
    console.log(`pressure, altitude (${e.nativeEvent.force}, ${e.nativeEvent.altitudeAngle})`);
````
results in
<img width="424" alt="Screen Shot 2564-06-28 at 17 13 22" src="https://user-images.githubusercontent.com/5000572/123621055-0b563f00-d835-11eb-9eff-526ba27fdf7b.png">
and when pencil is oriented perpendicular to the screen and pressed with full force shows
<img width="412" alt="Screen Shot 2564-06-28 at 17 13 58" src="https://user-images.githubusercontent.com/5000572/123621139-1c06b500-d835-11eb-8207-68a49720d708.png">

Reviewed By: sammy-SC

Differential Revision: D29964102

Pulled By: sota000

fbshipit-source-id: 5a1f41d64c6fe325afbd2b9579eaf20a522e92dc
2021-07-28 18:36:42 -07:00
Samuel Susla f592ad0509 Attempt to fix undefined instance handle in EventTarget
Summary:
changelog: [internal]

Completion block can retain `_eventEmitter` beyond existence of the component. To fix this, do not retain `_eventEmitter` by block but try to acquire it inside it.

Reviewed By: JoshuaGross

Differential Revision: D29969189

fbshipit-source-id: 456c42f816acc160f9d6bbd3f9c8c55d611940b2
2021-07-28 14:45:12 -07:00
Samuel Susla c2ba8864f9 Remove redundant warnings for RCTMountingManager
Summary:
Changelog: [internal]

The warnings are in-actionable for product engineers.

Reviewed By: JoshuaGross

Differential Revision: D29911438

fbshipit-source-id: f0f81588e8cbe88059e531c8be302ab19b8eb83f
2021-07-27 12:25:31 -07:00
Samuel Susla c5f8c31435 Implement View.removeClippedSubviews prop
Summary:
Changelog: [internal]

Fabric didn't have prop [removeClippedSubviews](https://reactnative.dev/docs/view#removeclippedsubviews) implemented. This diff adds it. It is

Reviewed By: JoshuaGross

Differential Revision: D29906458

fbshipit-source-id: 5851fa41d7facea9aab73ca131b4a0d23a2411ea
2021-07-27 03:04:15 -07:00
Samuel Susla 7b1e6f5077 Remove gating for on demand view mounting
Summary:
Changelog: [internal]

This feature has shipped. I remove gating here.

Reviewed By: mdvacca

Differential Revision: D29906460

fbshipit-source-id: 23433cfd4d618633b135d8c858ce6cf90cfe9fa1
2021-07-26 14:23:05 -07:00
Jason Safaiyeh 48ba8df8f2 Resolve some XCode warnings (#31883)
Summary:
UIAccessibilityVoiceOverStatusChanged deprecated (iOS 11+) in favor for UIAccessibilityVoiceOverStatusDidChangeNotification ref: https://developer.apple.com/documentation/uikit/uiaccessibilityvoiceoverstatuschanged?language=objc

topLayoutGuide/bottomLayoutGuide deprecated (iOS 11+) in favor for safeAreaLayoutGuide ref: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621367-toplayoutguide

This block declaration is not a prototype warnings fixed by adding void to specify no parameters ref: https://stackoverflow.com/questions/47916585/objective-c-block-parameter-issue-this-block-declaration-is-not-a-prototype

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - Resolved some deprecations

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

Test Plan: Tests should pass, no functionality should change.

Reviewed By: fkgozali

Differential Revision: D29822033

Pulled By: mdvacca

fbshipit-source-id: dec8d612885634aca090ac3372cd4c7bf8a197ee
2021-07-21 13:27:14 -07:00
Samuel Susla b0e39b2ed9 Maintain cursor position when text changes in text input
Summary:
Changelog: [internal]

Cursor position needs to be calculated when attributed string changes.

Reviewed By: JoshuaGross

Differential Revision: D29786190

fbshipit-source-id: 99a42dc4d7c84e77c40f75bf4a9108d010bb1792
2021-07-20 15:14:48 -07:00
Dustin Shahidehpour 16bb2ae4f1 explicitly set autoglob=False on programatically created targets.
Summary:
I'm going to be flipping the default from autoglob on `fb_apple_library` to `True`. This prepares the target so that there are no behavior changes.

## Changelog: [Internal]

Reviewed By: natestedman

Differential Revision: D29769275

fbshipit-source-id: 7ac04f8a8f7e41ce8d43a81b25ebd063b3a9f3de
2021-07-19 14:37:02 -07:00
Kudo Chien b77948e33b Upgrade folly to 2021.06.28.00 and boost to 1.76.0 (#31840)
Summary:
1. [ios] upgrade folly to 2021.06.28.00 which aligned to android.
2. folly compile setting from c++14 -> c++17: _this folly requires c++17 for `std::unordered_map::insert_or_assign`._
3. boost 1.63.0 -> 1.76.0:  _the old boost does not support c++17._
4. deprecating react-native-community/boost-for-react-native: _by cocoapods installer, we could download the official target._

## Changelog

[iOS] [Changed] - Upgrade folly to 2021.06.28.00 and boost to 1.76.0

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

Test Plan: CI passed

Reviewed By: fkgozali

Differential Revision: D29668480

Pulled By: yungsters

fbshipit-source-id: 98eae9ca47f489dcea91974e6f5e9dcb4d66c40c
2021-07-16 15:13:12 -07:00
Anas Khurshid 25a16123a6 Added Support for Entrance/exit from collection by Flatlist (#31630)
Summary:
Issue https://github.com/facebook/react-native/issues/30964 .When using a screen reader, flatlist does not announce entrance/ exit from the flat list.

## Changelog

[Android] [Changed] - Added support for accessibility role of "list" for flatlist and sectioned list

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

Test Plan: I have added accessibility role prop in flatlist and sectioned list in rntester app, that will announce entrance/ exit from flatlist and sectioned list.

Reviewed By: kacieb

Differential Revision: D29599351

Pulled By: blavalla

fbshipit-source-id: e16ec69a694780d12f15f88a1e6bb5d7d77ac15f
2021-07-09 19:25:36 -07:00
Luna Wei cddb97ad18 Remove Picker from OSS (#31772)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/31772

Changelog:[General][Removed] - Remove Picker iOS code

Reviewed By: p-sun

Differential Revision: D29124724

fbshipit-source-id: d3b3a409961cf04e2cd079a91986d30e3166dcda
2021-07-08 13:23:49 -07:00
Justin Huntington bc1e602e0c Add ScrollView.automaticallyAdjustsScrollIndicatorInsets prop (on iOS) (#29809)
Summary:
iOS 13 added a new property to `UIScrollView`: `automaticallyAdjustsScrollIndicatorInsets`, which is `YES` by default.  The property changes the meaning of the `scrollIndicatorInsets` property.  When `YES`, any such insets are **in addition to** whatever insets would be applied by the device's safe area.  When `NO`, the iOS <13 behavior is restored, which is for such insets to not account for safe area.

In other words, this effects ScrollViews that underlay the device's safe area (i.e. under the notch).  When `YES`, the OS "automatically" insets the scroll indicators, when `NO` it does not.

There are two problems with the default `YES` setting:

1. It means applying `scrollIndicatorInsets` to a `ScrollView` has a different effect on iOS 13 versus iOS 12.
2. It limits developers' control over `scrollIndicatorInsets`.  Since negative insets are not supported, if the insets the OS chooses are too large for your app, you cannot fix it.

Further explanation & sample code is available in issue https://github.com/facebook/react-native/issues/28140 .

This change sets the default for this property to `NO`, making the behavior consistent across iOS versions, and allowing developers full control.

## 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] [Changed] - ScrollView scrollIndicatorInsets to not automatically add safe area on iOS13+

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

Test Plan:
Updated the RNTester example to explain what to expect. Also removed the `pageScreen` modal example for now as mentioned in my Github comment.

{F628636466}

Here are screenshots of the demo app (from the original bug) before (with safe area applied to insets) & after (without safe area applied to insets):

![before](https://user-images.githubusercontent.com/428831/91644197-ea03a700-ea07-11ea-9489-be27820930eb.png)

![after](https://user-images.githubusercontent.com/428831/91644200-eff98800-ea07-11ea-8788-daf1e783639d.png)

Reviewed By: p-sun

Differential Revision: D28229603

Pulled By: lunaleaps

fbshipit-source-id: 2e774ae150b1dc41680b8b7886c7ceac8808136a
2021-07-07 20:23:36 -07:00
Samuel Susla b52950bda2 Apply correct text attributes in TextInput.setTextAndSelection
Summary:
Changelog: [internal]

Make sure correct text attributes are used inside of view command.

Reviewed By: sshic

Differential Revision: D29585943

fbshipit-source-id: 4748c843ff586f1dd42f3a89460afb624f9b371a
2021-07-07 07:11:03 -07:00
Samuel Susla 3bce393766 Clean up enable_state_scroll_data_race_ios experiment
Summary:
Changelog: [internal]

Clean up the experiment.

Reviewed By: JoshuaGross

Differential Revision: D29547129

fbshipit-source-id: 08ecbf5d362385b9d287348c7a4a508ca24a42bf
2021-07-05 14:14:47 -07:00
Ramanpreet Nara 8c746dfc7e Fix CMD + OPT + R with Bridgeless mode only
Summary:
When you reload React Native surfaces via the CMD + OPT + R keystroke, this is the actual code that executes:

https://www.internalfb.com/code/fbsource/[9c79fc6a17b7738b391a605412abf1cb15ef8ea1]/xplat/js/react-native-github/React/CoreModules/RCTDevSettings.mm?lines=172-175%2C179-183

It's only executed when RCTDevSettings is instantiated by the bridge. So, if only bridgeless surfaces are loaded, then CMD + OPT + R doesn't work.

## Fix
In this diff, I ensure that
1. We set up the reload listener when RCTDevSettings is *first* instantiated
2. We clear the reload listener when all instances of RCTDevSettings are invalidated.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D29437952

fbshipit-source-id: 9f2ff8340575c0ed881df26249433b2075bbd2ac
2021-06-29 14:55:40 -07:00
Ramanpreet Nara c7d34527c9 Specify whether DevMenu is bridgeless or bridge
Summary:
The Facebook app can have both bridge and bridgeless surface. Each type of surface has its own DevMenu. It's important to specify which DevMenu is being rendered, because not doing so can make for some confusing/frustrating devx (e.g: the bridgeless dev menu shows up for bridge surfaces: https://pxl.cl/1L1m7).

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D29439980

fbshipit-source-id: 24de1e6b44e5315c0cee0684d0db5df31514d3e2
2021-06-29 14:41:49 -07:00
Samuel Susla d472efbd72 Remove feature flag for promises block guard
Summary:
Changelog: [internal]

Promises block guard is shipped. Let's remove gating.

Reviewed By: RSNara

Differential Revision: D29262010

fbshipit-source-id: c15e033573b11f0a3470b1ddfbef07b6f03ba069
2021-06-24 03:33:05 -07:00
Danilo Bürger c974cbff04 Allow PlatformColor to work with RCTView border colors (#29728)
Summary:
# See PR
https://github.com/facebook/react-native/pull/29728

# From PR Author
Using `PlatformColor` with border colors doesn't work currently when switching dark mode as the information is lost when converting to `CGColor`. This change keeps the border colors around as `UIColor` so switching to dark mode works.

```ts
<View
  style={{
    borderColor: DynamicColorIOS({ dark: "yellow", light: "red" }),
    borderWidth: 1,
  }}
>
...
</View>
```
This view will start with a red border (assuming light mode when started), but will not change to a yellow border when switching to dark mode. With this PR, the border color will be correctly set to yellow.

## Changelog

[iOS] [Fixed] - Allow PlatformColor to work with border colors

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

Test Plan:
1. Assign a `PlatformColor` or `DynamicColorIOS` to a view border color.
2. Toggle between dark / light mode. See the colors change.

Reviewed By: lunaleaps

Differential Revision: D29268376

Pulled By: p-sun

fbshipit-source-id: 586545b05be0beb0e6e5ace6e3f74b304620ad94
2021-06-23 13:37:22 -07:00
Samuel Susla fa3697bd9e Back out "Add option to disable sending scroll events to Paper"
Summary:
Changelog: [internal]

Original commit changeset: fa4d8944ad6b

Not sending onScroll events events to Paper has no effect.

Reviewed By: mdvacca

Differential Revision: D29229662

fbshipit-source-id: b84a2614bfd42c64ca67ca6a1cd9d0a815c11ad0
2021-06-23 02:02:03 -07:00
Kevin Gozali fb58fa1734 iOS: proxy minimumSize to RCTSurface, but as a noop
Summary:
Previously, RCTRootView added support for minimumSize as a workaround for some initial layout use cases. Going forward, we don't need this anymore. So let's add a proxy property but log an error if anyone calls it.

Changelog: [iOS][Changed] - Proxy minimumSize to RCTSurface as a noop

Reviewed By: JoshuaGross

Differential Revision: D29284227

fbshipit-source-id: 98b2dfc905c6c7e1adc03216e3a1cc3fda0a4133
2021-06-22 13:29:48 -07:00
Samuel Susla f175ff5c04 Remove feature flag for async event beat v2
Summary:
Changelog: [internal]

AsynchronousEventBeatV2 is shipped. Let's remove gating.

Reviewed By: fkgozali

Differential Revision: D29261752

fbshipit-source-id: 844cfc494c077e36945a7fa65f9368c2165d5c8c
2021-06-22 06:21:09 -07:00
Samuel Susla 9ca460f064 Take RTL into account in scrollTo view command
Summary:
Changelog: [internal]

ScrollView's `scrollTo` command doesn't work in RTL. It sets the offset from left of the screen instead of right. This diff fixes this for Fabric only.

Reviewed By: JoshuaGross

Differential Revision: D29164056

fbshipit-source-id: f685d3e013f474f9b445112333d8f5ad7ed36ea7
2021-06-16 11:04:13 -07:00
Samuel Susla 741b4d4421 Remove RuntimeScheduler from SchedulerToolbox
Summary:
Changelog: [internal]

Remove `RuntimeScheduler` from `SchedulerToolbox` and all of its uses.
`RuntimeScheduler` needs to be allocated before `Scheduler` and therefore its presence in the toolbox is redundant.

Reviewed By: JoshuaGross

Differential Revision: D29134769

fbshipit-source-id: fa00c5dcc4b565d6941e6d742c6aefade37b31c4
2021-06-15 17:35:32 -07:00
Samuel Susla d540f88df8 Initialise RuntimeScheduler before bundle is executed
Summary:
Changelog: [internal]

RuntimeScheduler can be accessed before any Fabric surface is rendered. Therefore, it needs to be created and installed in the runtime at the start up of the runtime.

Reviewed By: JoshuaGross

Differential Revision: D29091848

fbshipit-source-id: ff75ef8c4882550795e5d4a258355b651cb0e637
2021-06-14 10:52:09 -07:00
Samuel Susla 592e92fc90 Fix missing space when using iOS's autocomplete
Summary:
Changelog: [internal]

Using keyboard's autocomplete did not insert space at the end of the word.

Reviewed By: fkgozali

Differential Revision: D29085654

fbshipit-source-id: 35fee726ea7d2030fdfa64300e045a303ea98ce9
2021-06-13 04:36:32 -07:00
Samuel Susla a5b92f34c4 Resign text input as first responder in prepareForRecycle
Summary:
Changelog: [internal]

To prevent wrong TextInput becoming first responder, force a resign when preparing for a reuse.

Reviewed By: JoshuaGross

Differential Revision: D29085923

fbshipit-source-id: 246cdf0628f914c3928cc9c7499d029b77684f2c
2021-06-12 12:26:27 -07:00
Joshua Gross f2e0b2f45f Fix crash in PreAllocation optimization
Summary:
PreAllocation currently always happens at revision 0 (after ShadowNode creation), and all CREATE mutations are triggered for ShadowNodes at revision 1 or higher (since CREATE mutations are generated by the differ, it means that all ShadowNodes have revision 1 or higher when CompleteRoot is called). This means that between PreAllocation and CREATE, we /always/ expect at least one clone.

It is possible for a node to be "non-view-forming" at revision 0, causing view preallocation to be skipped, and "view-forming" at revision 1 (causing the CREATE mutation to be thrown away, since all CREATE mutations of revision 0 or 1 are thrown away). This causes a crash. It is extremely marginal, but there are repros in the wild.

Thus, I'm introducing one new UIManager and Scheduler delegate method that allows the mounting layer to be notified of clones. If a clone from rev 0->1 results in a node going from non-view-forming to view-forming, we can preallocate then, as well.

This resolves this crash, and allows us to keep experimenting safely with this View PreAllocation optimization. I believe all edge-cases are accounted for.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D29043426

fbshipit-source-id: dff11d3140ded1cbb02a5518a3aeb52dc812cc50
2021-06-10 15:50:14 -07:00
Joel Arvidsson 36c0a7dec1 Support user-defined PlatformColors on iOS (#31258)
Summary:
Original PR: https://github.com/facebook/react-native/pull/31258

## Imported PR from Github:

This is a continuation of https://github.com/facebook/react-native/pull/29683. I've talked to danilobuerger who does not intend on continue work on it and is OK with me picking up where he left. This PR is identical besides adding a test case in the RN Tester app as requested in the original PR.

In summary it gives iOS feature parity with Android in the sense that one can use user-defined native colors, something even the docs claim is possible. It's useful as it enables accessibility features such as high contrast colors and makes implementing dark mode simple. For an example on how it can be used, see https://github.com/klarna-incubator/platform-colors

## Changelog

[iOS] [Added] - Allow PlatformColor to return user-defined named asset color

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

Test Plan: Test case added to RN Tester.

Reviewed By: sammy-SC

Differential Revision: D28803206

Pulled By: p-sun

fbshipit-source-id: e0f0690274799bd2d09c9f9d1a6a95ac0f979498
2021-06-10 12:15:12 -07:00
Birkir Gudjonsson 4b9d9dda27 Accessible colors for DynamicColorIOS (#31651)
Summary:
Allow you to harvest the `UIAccessibilityContrastHigh` trait from iOS to show accessible colors when high contrast mode is enabled.

```jsx
// usage

PlatformColorIOS({
  light: '#eeeeee',
  dark: '#333333',
  highContrastLight: '#ffffff',
  highContrastDark: '#000000',
});

// {
//   "dynamic": {
//     "light": "#eeeeee",
//     "dark": "#333333",
//     "highContrastLight": "#ffffff",
//     "highContrastDark": "#000000",
//   }
// }
```

This is how apple's own dynamic system colors work under the hood (https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/#dynamic-system-colors)

 ---

The react native docs mention that more keys may become available in the future, which this PR is adding:

> In the future, more keys might become available for different user preferences, like high contrast.

https://reactnative.dev/docs/dynamiccolorios

## 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] [Added] - High contrast dynamic color options for dark and light mode.

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

Test Plan: Added unit tests for `normalizeColor` to pass the high contrast colors downstream to RCTConvert

Reviewed By: lunaleaps

Differential Revision: D28922536

Pulled By: p-sun

fbshipit-source-id: f81417f003c3adefac50e994e62b9be14ffa91a1
2021-06-08 11:51:23 -07:00
Shuhao Zhang f3b8d4976f Bug fix: <TextInput> content is reset when emoji is entered at the max length
Summary:
When maxLength is defined in <TextInput>, if the last character at max length is an emoji, the content of the input is cleared:

{F620865178} {F620865237}

Related Github issues:

https://github.com/facebook/react-native/issues/10929
https://github.com/facebook/react-native/issues/10964

## Root cause:

When NSString was created, unicode characters were 16-bit long, so Objective-C considers every unicode character as 16-bit. However, unicode was later extended to more than 16bit, for example, emojis, which causes NSString substring method cuts off at the wrong position.

Example:

```
NSString *s = @"abc{emoji:1f601}";
NSInteger len = s.length; //length is 5 (as {emoji:1f601} occupies two 16-bit characters)
NSString *s3 = [s substringToIndex: 3]; //s3 is "abc"
NSString *s4 = [s substringToIndex: 4]; //s4 is null!
```

If string s, "abc{emoji:1f601}", is entered in <TextInput>, which has max length 4, it will truncate the string to the first 4 characters, "cutting" the emoji in half which causes encoding error and returns null. The text input is cleared.

## Solution:

If the character at max length is longer than 16-bit, truncate the character BEFORE it instead. In the previous example, truncate till index 3 instead of 4. The end result will be "abc" and the emoji is dropped.

## Changelog:

[iOS] [Fixed] - <TextInput> content is reset when emoji is entered at the max length

Reviewed By: p-sun

Differential Revision: D28821909

fbshipit-source-id: 4720d864970b554160ed5388f65b352ce95a6199
2021-06-04 13:40:42 -07:00
Samuel Susla 80ceedc0d8 Wire shouldYield flag to a feature flag
Summary:
Changelog: [internal]

Add a feature flag to enable yielding in RuntimeScheduler

Reviewed By: JoshuaGross

Differential Revision: D28903226

fbshipit-source-id: c361ca144a2d531e8aa671bc8875bce075e13a2c
2021-06-04 12:08:52 -07:00
Samuel Susla a18a2de4b4 Fix crash in ~Pointer by not retaining LayoutManager beyond the runtime
Summary:
Changelog: [internal]

This is a life cycle issue where LayoutManager outlives the runtime. To fix this, we need to destroy `_accessibilityProvider` before the runtime. The way to do it is to destroy it inside `prepareForReuse` which is guaranteed to be called before runtime is destroyed.

Reviewed By: JoshuaGross

Differential Revision: D28898257

fbshipit-source-id: 9d2c0b9cebd9889caa4328f9ee7f005928bbf55a
2021-06-04 11:53:18 -07:00
Samuel Susla 0ee8e292a4 Fix for ScrollView race condition between C++ state update and onScroll
Summary:
Changelog: [internal]

There is a possibility of race between updating scrollview's state and virtualised list asking for layout of individual cells.
To make sure the race doesn't happen, state must be updated before dispatching onScroll event.

Android has implemented a different mechanism to tackle this issue in D28558380 (b161241db2).

Reviewed By: JoshuaGross

Differential Revision: D28642737

fbshipit-source-id: 33874beac69fc5a66eeb7f459fd89cd0b00dafcf
2021-05-26 03:32:03 -07:00
Samuel Susla 925af8ddea Add collapsable to RCTViewManager as property
Summary:
Changelog: [internal]

collapsable was not passed to Fabric because view configs are built using Paper' ViewManagers.

Reviewed By: p-sun

Differential Revision: D27944688

fbshipit-source-id: 73a5646e25b3dd7a1a9dfc1079406047ab483d88
2021-05-25 12:52:34 -07:00
Samuel Susla 3a9e14e8a9 Add synchronous access to the runtime to RuntimeScheduler
Summary:
Changelog: [internal]

Introduces synchronous access to the runtime from RuntimeScheduler.
At the moment, this is not used anywhere.

In case RuntimeScheduler isn't defined (controlled by MC), falls back to RuntimeExecutor.

Reviewed By: mdvacca

Differential Revision: D28024380

fbshipit-source-id: 90be36dd390202540ed51940a4396040f043cd90
2021-05-25 07:42:06 -07:00
Andrei Shikov faaeb778df Parse accessibilityAction props into object
Summary:
Android was using rawProps received from JS, so no updates needed.
Updated iOS callsite to use the name of the action.

Changelog:
[General][Fixed] - Parse accessibilityAction props into object instead of string

Reviewed By: mdvacca

Differential Revision: D28614407

fbshipit-source-id: 209134f8fac65ca8516039e10ea502e57d52a7a7
2021-05-24 10:27:27 -07:00
Samuel Susla 4bec099f7e Add option to disable sending scroll events to Paper
Summary:
Changelog: [internal]

Originally added in D17814260 (ffc7ec992c) to make parallax effect work in Dating.

This diff hides it behind a flag so we can properly evaluate what's the cost of sending scroll events to Paper.

Reviewed By: JoshuaGross

Differential Revision: D28608283

fbshipit-source-id: fa4d8944ad6b5e767363e231942f13fec9d18cb5
2021-05-22 12:19:05 -07:00
Ramanpreet Nara 8aa85241a4 Migrate RCTDevSettings to initialize
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28595955

fbshipit-source-id: e61c2d321826eafb60fdac820b76d0f7d100796a
2021-05-21 14:49:51 -07:00
Ramanpreet Nara ed86891d01 Migrate NativeModules to initialize
Summary:
This migrates all ObjC NativeModule setBridge: calls to the bridge compatible initialize: call. I filtered out ViewManagers.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28595520

fbshipit-source-id: b0e5dd681fb3563894f1aa3da1728f0c694f04bb
2021-05-21 14:49:51 -07:00
Samuel Susla 118489f6e5 Make LeakChecker available on Android
Summary:
Changelog: [internal]

Extend LeakChecker so it is available on Android (or any other platform as it is completely in C++ now).

Reviewed By: JoshuaGross

Differential Revision: D28600243

fbshipit-source-id: c77a003e3ffc6171e61c998508c9f34f10bb65ca
2021-05-21 10:39:43 -07:00
Andres Suarez ffab8e3f46 Apply clang-format
Reviewed By: igorsugak

Differential Revision: D28477074

fbshipit-source-id: f15dfc45b9fb30c661ebe2899cd882676d0fdf2a
2021-05-20 21:24:25 -07:00
Ramanpreet Nara 269fefb065 Call RCTInitializing initialize on NativeModules
Summary:
After D28435078, NativeModules can conform to the RCTInitializing protocol, and implement the `-(void)initialize` method. This diff makes the NativeModule system execute the module's initialize method after the infra is done setting it up.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28435430

fbshipit-source-id: 1ce00c3fb3c63b024d7e24895ff96c541a6fa654
2021-05-20 19:19:57 -07:00
Ramanpreet Nara 9b45df1fce Introduce RCTInitializing
Summary:
## Motivation
NativeModules need a way to execute custom initialization code. The current way to achieve this is by overriding the setBridge: method. This doesn't work in bridgeless mode, because in bridgeless mode, the TurboModule system doesn't (and shouldn't) invoke the setBridge: method.

## Changes
This diff introduces a new protocol RCTInitializing that NativeModules can conform to. Once they conform to this protocol, they can implement the `- (void)initialize;` method. Both the NativeModule and TurboModule infra will execute this method towards the end of NativeModule setup.

## Questions
Why don't we just override the NativeModule init method?
1. **Backwards compatibility:** The legacy NativeModule infra requires that [modules that override their init method](https://www.internalfb.com/code/fbsource/[8098212b4e3733f0b469f11f3e61c5249a47f9f5]/xplat/js/react-native-github/React/Base/RCTModuleData.mm?lines=82-83) [must be initialized on the main thread](https://www.internalfb.com/code/fbsource/[8098212b4e3733f0b469f11f3e61c5249a47f9f5]/xplat/js/react-native-github/React/Base/RCTModuleData.mm?lines=85). We ported this over [to the TurboModule system](https://www.internalfb.com/code/fbsource/[d58a07e9ae90951d382224c28cb78c32c7cda80d]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm?lines=684%2C686). *We cannot require all NativeModules that need custom initialization to be initialized on the main thread.*
2. **More flexibility:** A custom `- (void)initialize` hook can be invoked by the NativeModule infra after the NativeModule is prepared (i.e: the bridge, module registry, view registry, etc. is attached). The same isn't true of an overriden init method, which has to be invoked when the object is created. This means that a custom `- (void)initialize` hook can use the bridge/method queue, etc., but an overriden init method cannot.

What about Android?
- After this diff, NativeModules can implement the `initialize` method to initialize themselves, and the `invalidate` method to invalidate themselves. This unifies initialization/invalidation across both iOS and Android, because on Android, TurboModules can also implement the same methods:

https://www.internalfb.com/code/fbsource/[d58a07e9ae90951d382224c28cb78c32c7cda80d]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModule.java?lines=11-17

Changelog: [iOS][Added] - Introduce RCTInitializing to allow NativeModules to initialize themselves

Reviewed By: fkgozali

Differential Revision: D28435078

fbshipit-source-id: 1a4a95e30f0a8b32b0844e9b9beee274afcbb577
2021-05-20 19:19:57 -07:00
Thibault Malbranche 59abb5f378 fix(hermes): fixed hermes build on iOS (#31559)
Summary:
While testing 0.65, we noticed issues with hermes on iOS in the template projects
These changes create a subspec to the react-core pod so that it can access hermes header correctly.

## Changelog

Not applicable

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

Test Plan: I've ran e2e manual test. Tested RNTester manually also. Then tested a project inited with hermes and the default template

Reviewed By: mhorowitz

Differential Revision: D28564642

Pulled By: Huxpro

fbshipit-source-id: cfcb3363254f62a0e514ec99159b32f841ee4463
2021-05-20 15:23:07 -07:00
Samuel Susla e173bbe3bb Fix on demand mounting in RTL
Summary:
Changelog: [internal]

When calculating on demand views, RTL layout needs to be considered.

Reviewed By: JoshuaGross

Differential Revision: D28510293

fbshipit-source-id: 5e7b08fcc5c55fa1a978024a9bfedda705ce1702
2021-05-18 10:02:19 -07:00
Ramanpreet Nara 24a7f4bf98 Move RCTDevLoadingView init off main thread
Summary:
When we initialize RCTDevLoadingView, we dispatch_sync to the main thread. There isn't anything in the NativeModule that requires us to initialize it on the main thread. So, this diff toggles requiresMainQueueSetup to NO. This should mitigate this prefetch-related deadlock: T90970812. Please read the task comments for the rationale.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28490715

fbshipit-source-id: 7efceb392ec9e0cabe7f7cd8867cf4b07f8fff19
2021-05-17 16:03:32 -07:00
Ramanpreet Nara 73fbe80fc4 Delete RCTJSInvokerModule protocol
Summary:
This protocol is no longer necessary, because we introduced the bridgeless-compatible abstraction: RCTCallJSModuleMethod.

Changelog: [iOS][Removed] - Delete RCTCallJSModuleMethod protocol

Reviewed By: fkgozali

Differential Revision: D28395446

fbshipit-source-id: 0ad606ce7935b24bfbd6e0c2f35fbde480a8a6ff
2021-05-14 09:22:58 -07:00
Ramanpreet Nara 6c5ac8036e Bridgeless Mode: Migrate modules away from invokeJS
Summary:
This diff removes all synthesize invokeJS = _invokeJS calls, and instead funnels them through synthesize callableJSModules = _callableJSModules. Now, all these NativeModules shouldn't have different branching in bridgeless mode vs bridge mode.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28395445

fbshipit-source-id: 41a58d54c60be55e6bf5031e5417728f5eb6285c
2021-05-14 09:22:58 -07:00
Ramanpreet Nara 22ba277496 Attach RCTCallableJSModules to TurboModules
Summary:
This diff has the bridge attach RCTCallableJSModules to our TurboModules.

Changelog: [Internal]

Differential Revision: D28395450

fbshipit-source-id: 6861e56f7fa0c009cded41f80b569de57a383e83
2021-05-14 09:22:58 -07:00
Ramanpreet Nara 478365079b Attach RCTCallableJSModules to NativeModules
Summary:
This diff has the bridge attach RCTCallableJSModules to our NativeModules.

Changelog: [Internal]

Differential Revision: D28395447

fbshipit-source-id: 01ca62442013826d28ba0f710e28a5963f5efb65
2021-05-14 09:22:58 -07:00
Ramanpreet Nara ece373d244 Introduce RCTCallableJSModules
Summary:
This is a Bridgeless-compatible API to allow our NativeModules to call JSModule methods.

Changelog: [iOS][Added] - Introduce RCTCallableJSModules API for NativeModules

Differential Revision: D28395448

fbshipit-source-id: b7929ba8b4cc4410361961b45efa23c76baacd24
2021-05-14 09:22:58 -07:00
Samuel Susla 9b3c12dc87 Funnel All Fabric calls to RuntimeExecutor to RuntimeScheduler
Summary:
Changelog: [internal]

This diff moves all calls to RuntimeExecutor to RuntimeScheduler. The calls are still immediately dispatched. Timing of events will not change.

The goal of this diff is to prepare infrastructure for Concurrent Mode.

Reviewed By: JoshuaGross

Differential Revision: D27937665

fbshipit-source-id: 434d78c95ccf23d8da41186d0dae91bff4eda384
2021-05-13 08:03:29 -07:00
Ramanpreet Nara a43d36578b Migrate RCTDevLoadingView off bridge APIs
Summary:
When RCTDevLoadingView is created, it checks to see if the bridge is loading. If so, displays the loading banner with the bundleURL. This logic is better placed in the bridge, because the bridge is also responsible for updating progress on the DevLoadingView.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28301524

fbshipit-source-id: fb6c259b546d8cd9e08568a88c7046d06c70ed6f
2021-05-12 14:16:11 -07:00
Samuel Susla 83e5cdd369 Fix accessibility when entire text node is a link
Summary:
Changelog: [internal]

Fix accessibility when entire text node is a link

Reviewed By: JoshuaGross

Differential Revision: D28325749

fbshipit-source-id: 9ac68b802f13d028b5cdb6cae7bdae5f4924fc07
2021-05-11 01:23:04 -07:00
Ramanpreet Nara 1e39d8b829 Delete RCTJSInvokerModule setInvokeJSWithModuleDotMethod:
Summary:
RCTJSInvokerModule invokeJS can do the work done by setInvokeJSWithModuleDotMethod. Therefore, this diff reduces the surface area of Venice, and gets rid of setInvokeJSWithModuleDotMethod.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28232947

fbshipit-source-id: aa0d8497a1e0fba29109ca86a39de5d9e5b10c9c
2021-05-06 21:23:58 -07:00
Ramanpreet Nara c17674e12f Delete RCTBundleHolderModule
Summary:
This protocol is no longer necessary, because we migrated all our NativeModules to synthesize bundleManager = _bundleManager;

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D28232441

fbshipit-source-id: 0bd54fa49299574db8a75247c97b466476037f4f
2021-05-06 21:23:58 -07:00
Ramanpreet Nara f2157a0558 Migrate RCTDevSettings to RCTBundleManager
Summary:
This diff migrated RCTDevSettings to the RCTBundleManager, which works both in bridge/bridgeless mode. RCTDevSettings is the last TurboModule that synthesizes the bundleURL. So, after this diff, we can get rid of the RCTBundleHolderModule protocol.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28232320

fbshipit-source-id: ab53278fea0ea7e025cf748be62bc5d610593e7f
2021-05-06 21:23:58 -07:00
Samuel Susla e4b6392ee7 Remove gating for block guard
Summary: Changelog: Remove gating around leak fix in TurboModules infra

Reviewed By: RSNara

Differential Revision: D28253054

fbshipit-source-id: 9b3c236d3752b5ca042f83127e42e69250ccd112
2021-05-06 20:00:15 -07:00
Samuel Susla 10a9a4ed89 Enable block guard for promises
Summary:
Changelog: Resolve memory leak in promises on iOS

Enable block guard for promises

Reviewed By: RSNara

Differential Revision: D28252977

fbshipit-source-id: 052fefca0a6ac54597a46922fc467a2a39f7976f
2021-05-06 20:00:15 -07:00
Ramanpreet Nara eb0a918577 Migrate RCTSourceCode to RCTBundleManager
Summary:
See title.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28192005

fbshipit-source-id: b61406bdd32cd7511d7f2abb7bead819894fce9a
2021-05-04 18:33:23 -07:00
Ramanpreet Nara 1f105e6f16 Migrate RedBox to RCTBundleManager
Summary:
See title.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28192003

fbshipit-source-id: a1a21782b51f327b9b92c60c7e9bd7251fcdebf0
2021-05-04 18:33:23 -07:00
Ramanpreet Nara adaa1c98f6 Migrate RCTDevLoadingView to RCTBundleManager
Summary:
See title.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28192004

fbshipit-source-id: fd916237030ad51c7687e8196d7e0b6d3b3c02b5
2021-05-04 18:33:23 -07:00
Ramanpreet Nara 4198c2bcb6 Migrate RCTDevMenu over to RCTBundleManager
Summary:
This diff gets rid of bridge usage in RCTDevMenu's _menuItemsToPresent method.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28164301

fbshipit-source-id: 6445c787519af887209ee312f1c2dbaef873e00d
2021-05-04 18:33:23 -07:00
Ramanpreet Nara 8ba73a79f2 Attach RCTBundleManager to TurboModules (Bridge mode)
Summary:
See title.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D28160096

fbshipit-source-id: c14e5a5bc9f226f1e2559b3a256edcf5379d3c2e
2021-05-04 18:33:23 -07:00