Commit Graph

5239 Commits

Author SHA1 Message Date
Alfonso Curbelo c1db41f060 Fixed - Text with adjustsFontSizeToFit changes the text layout infinitely (#33135)
Summary:
Fixes the infinite loop explained in the issue https://github.com/facebook/react-native/issues/33129 by reverting commit  59021521e7. PR https://github.com/facebook/react-native/pull/31538.

`onCollectExtraUpdates` is part of the node update cycle. By marking the node as updated `markUpdated()` in `onCollectExtraUpdates` we are restarting the update infinitely.

Unfortunately, reverting this PR also reintroduces the original issue https://github.com/facebook/react-native/issues/30717 which IMO is minor compared to the infinite loop.

## Changelog

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

[Android] [Fixed] - Text with adjustsFontSizeToFit changes the text layout infinitely

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

Test Plan:
I added a console.log to the Text `onTextLayout` in [packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js ](https://github.com/facebook/react-native/blob/main/packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js) to see if the infinite loop is gone.

![image](https://user-images.githubusercontent.com/3791120/154523914-e6aa7cf5-7a1c-488f-a392-898f4c85a833.png)

![Screen Shot 2022-02-17 at 11 20 31 AM](https://user-images.githubusercontent.com/3791120/154524274-880c3bed-d2c6-456b-8947-42e75793c424.jpg)

```

Reviewed By: ShikaSD

Differential Revision: D34310218

Pulled By: lunaleaps

fbshipit-source-id: 0d40f49d15c562ec25983145897bd95dc182f897
2022-02-17 13:46:23 -08:00
David Vacca 78e03b6fb7 Refactor of Fb4aReactFabricPerfLogger
Summary:
This diff refactors Fb4aReactFabricPerfLogger in order consume fabric commit statistics outside of fabric

changelog: [internal] internal

Reviewed By: sshic

Differential Revision: D34056540

fbshipit-source-id: 8f3b8003e1601ca36c9ba57be874a40bad455235
2022-02-16 00:23:59 -08:00
David Vacca 8dddff5547 Refactor logging of Fabric commit statistics
Summary:
This is a refactor of the logging of Fabric commit statistics to simplify the way we track performance points.

we'll later refactor and iterate on the API to integrate fabric perf point into developer tools

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D34006700

fbshipit-source-id: 93a01accd90dfacc8b44edd158033b442a843284
2022-02-16 00:23:59 -08:00
David Vacca 6ab5bb6869 Rename ReactNativeConfig.getInt64 -> ReactNativeConfig.getLong
Summary:
In this I'm renaming ReactNativeConfig.getInt64 -> ReactNativeConfig.getLong

changelog: [internal] internal

Reviewed By: javache, philIip

Differential Revision: D33901536

fbshipit-source-id: 688aff9a849299eb8ad904b75b03d7fb5f0d8172
2022-02-15 15:21:38 -08:00
Pieter De Baets 45af635b1e Fix some nits/typos in MapBuffer
Summary:
Was trying out some behaviour when using the MapBuffer experiment and fixed some small issues.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34108859

fbshipit-source-id: 550ca0847419006ec17472cc4b70d38fc8d05396
2022-02-15 14:06:42 -08:00
Genki Kondo 9f6f97151c Fix ReactHorizontalScrollView contentOffset
Summary:
Brings the same fix https://www.internalfb.com/diff/D34015853 (https://github.com/facebook/react-native/commit/be260b9f479a3b55ee43d2959d2c49fd3c1eb4ac) for ReactScrollView to ReactHorizontalScrollView

When setting ScrollView's contentOffset, if the ScrollView hasn't been laid out yet when ReactHorizontalScrollViewManager.setContentOffset is called, then scroll position is never set properly. This is because the actual scroll offset (0, 0) was being passed into setPendingContentOffsets, instead of the desired scroll offset. Thus, when ReactHorizontalScrollView.onLayout gets called, ReactHorizontalScrollView.scrollTo gets called with (0, 0).

Changelog:
[Android][Fixed] - Fix ReactHorizontalScrollView contentOffset

Reviewed By: bvanderhoof

Differential Revision: D34246489

fbshipit-source-id: d923f7c9f136f7275d64bd658ffd5c2cc049d392
2022-02-15 13:09:29 -08:00
Pieter De Baets 90b98efa73 Resume LockFreeEventDispatcher from onHostResume
Summary:
Found that after backgrounding `mShouldStop` would always remain true, which prevents events from being dispatched / scheduled.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D34247567

fbshipit-source-id: 63876986dc0cee5e2a73cb4f8a35d90379d9f8ea
2022-02-15 13:05:38 -08:00
fabriziobertoglio1987 7b2d8178b1 Text Component does not announce disabled and disables click functionality when disabled (#33076)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/30937 fixes https://github.com/facebook/react-native/issues/30947 fixes https://github.com/facebook/react-native/issues/30840 ([Test Case 7.1][7.1], [Test Case 7.3][7.3], [Test Case 7.5][7.5]) .
The issue is caused by:

1) The missing javascript logic on the `accessibilityState` in the Text component https://github.com/fabriziobertoglio1987/react-native/commit/6ab7ab34e56411a7e87f396feb2f7ece1c4f98dd (as previously implemented in [Button][20]).
2) The missing setter for prop `accessible` in `ReactTextAnchorViewManager` https://github.com/fabriziobertoglio1987/react-native/commit/17095c6615107695f44af262846da446868b4cd8 (More information in previous PR https://github.com/facebook/react-native/pull/31252)

Related PR https://github.com/facebook/react-native/pull/33070 PR https://github.com/callstack/react-native-slider/pull/354

[20]: https://github.com/facebook/react-native/pull/31001/files#diff-4f225d043edf4cf5b8288285b6a957e2187fc0242f240bde396e41c4c25e4124R281-R289

## Changelog

[Android] [Fixed] - Text Component does not announce disabled and disables click functionality when disabled

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

Test Plan:
[1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][1])
[2]. Text has `disabled` ([link][2])
[3]. Text has `accessibilityState={{disabled: true}}` ([link][3])
[4]. Text has `accessibilityState={{disabled:false}}` ([link][4])
[5]. Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][5])
[6]. Text has `accessibilityState={{disabled:true}}` and method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [b4cd8][10]) ([link][6])
7. Test Cases on the main branch
[7.1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][7.1])
[7.3] Text has `accessibilityState={{disabled: true}}` ([link][7.3])
[7.5] Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][7.5])
[7.6] Text has `onPress callback` and `accessibilityState={{disabled: true}}` ([link][7.6])
[7.7] Text has `accessibilityState={{disabled:true}}` and no method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [c4f98dd][11]) ([link][7.7])

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465424
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465631
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465706
[4]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465755
[5]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465813
[6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1038473783
[7.1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465874
[7.3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465961
[7.5]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033466018
[7.6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033321965
[7.7]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1038471984

[10]: https://github.com/facebook/react-native/pull/33076/commits/17095c6615107695f44af262846da446868b4cd8
[11]: https://github.com/facebook/react-native/pull/33076/commits/6ab7ab34e56411a7e87f396feb2f7ece1c4f98dd

Reviewed By: blavalla

Differential Revision: D34211793

Pulled By: ShikaSD

fbshipit-source-id: e153fb48c194f5884e30beb9172e66aca7ce1a41
2022-02-15 11:23:11 -08:00
Kunal Farmah 8c573d9336 Added fail-safe check to catch MissingWebViewPackage Exception. (#33088)
Summary:
The check implemented in PR https://github.com/facebook/react-native/issues/29089 is flawed as the exception class name and message depends on the OS version as well as the OEM. In OxygenOS running android 11, it comes out as RuntimeException and the check fails and hence the crash occurs again. But on observing closely, its clear that the exception message is consistent across OEMs with similar strings appearing in them that have been included in the if check.
Hence there is a simple fix to this issue, by checking the message instead of the exception class.

Here is the snippet:

```
private Nullable CookieManager getCookieManager() {
    if (mCookieManager == null) {
      possiblyWorkaroundSyncManager(mContext);
      try {
        mCookieManager = CookieManager.getInstance();
      } catch (IllegalArgumentException ex) {
        // https://bugs.chromium.org/p/chromium/issues/detail?id=559720
        return null;
      } catch (Exception exception) {
        String message = exception.getMessage();
        // We cannot catch MissingWebViewPackageException as it is in a private / system API
        // class. This validates the exception's message to ensure we are only handling this
        // specific exception.
        // The exception class doesn't always contain the correct name as it depends on the OEM
        // and OS version. It is better to check the message for clues regarding the exception
        // as that is somewhat consistent across OEMs.
        // For instance, the Exception thrown on OxygenOS 11 is a RuntimeException but the message contains the required strings.
        // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#348
       if (exception.getClass().getCanonicalName().contains("MissingWebViewPackageException") ||
            (message!=null && (message.contains("WebView provider") ||
               message.contains("No WebView installed")))){
            return null;
        } else {
          throw exception;
        }
      }
    }

    return mCookieManager;
  }
```

## Changelog

[General] [Added] - A fail proof check to catch any crash involving webview:
if (exception.getClass().getCanonicalName().contains("MissingWebViewPackageException") || (message!=null && (message.contains("WebView provider") || message.contains("No WebView installed"))))
[General] [Removed] - Flawed check to catch WebViewProvider crash:
if (message != null && exception.getClass().getCanonicalName().contains("MissingWebViewPackageException"))

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

Test Plan:
This code has been tested rigorously on OnePlus Nord CE 5G (Oxygen OS 11.0) and Realme X (Realme UI 2.0) both running on Android 11 and reproducing the crash on a hybrid (Native android + ReactNative) app that showed this crash in production being dependent on WebViews. I have implemented an entire patched fork of 0.67.2 to fix this issue in our app.

How to test:

Launch any app that has a webview.
Go to settings->apps->Android System Webview -> disable.
Resume/Restart the app.

In this fix:
Open a webview and notice that the app will not crash.

In current version:
App crashes on startup as the exception escapes the catch block.
Even if it survives startup (did on Realme X), it will crash once you try to open a webview.

Reviewed By: rh389

Differential Revision: D34240097

Pulled By: cortinico

fbshipit-source-id: 0f1f9a3b078c0ad3074c7841392892cb70b427eb
2022-02-15 04:50:51 -08:00
David Vacca 2b845d5585 Integrate DeviceConfig into ReactNativePanelApps
Summary:
This diff integrates DeviceConfig into ReactNativeConfig used by ReactNativePanelApps. The goal is to be able to control Fabric MCs using GKs and QEs in RN VR apps

I did an audit of the MCs that were used by RNPanelApps:

```
"react_fabric:enabled_android_fabric_logs": -> will get data from GK (disabled by default)
"react_fabric:disable_virtual_node_preallocation": -> does not exist in code anymore
"react_fabric:enable_early_event_emitter_update": -> will get data from MC (disabled using static value)
"react_fabric:enable_background_executor_android": -> does not exist in code anymore
"react_fabric:enable_props_forwarding_android": -> does not exist in code anymore
"react_fabric:remove_outstanding_surfaces_on_destruction_android":  -> will get data from MC static value (ENABLED using static value)
"react_fabric:enable_large_text_measure_cache_android":  -> will get data from MC default value (ENABLED by default)
```

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D33898210

fbshipit-source-id: 0ea1e0e2fc15929bec328f7dcc9410efa9925b34
2022-02-14 11:19:01 -08:00
Dark Knight 8b24ce6720 Revert D34149878
Summary:
This diff is reverting D34149878 (https://github.com/facebook/react-native/commit/9bc6c0f8a5cb779b9df394893cc097605dea37f6)
D34149878 (https://github.com/facebook/react-native/commit/9bc6c0f8a5cb779b9df394893cc097605dea37f6) is making the following tests to fail and this revert diff is either the revert of the blame diff or the revert of the stack of diffs that need to be reverted to revert the blame diff
Tests affected:
- https://www.internalfb.com/intern/test/281475012591721/
Multisect link:
https://www.internalfb.com/intern/testinfra/multisect/725030

Reviewed By: mdvacca

Differential Revision: D34163348

fbshipit-source-id: 697b42474aec6168c916c1271678d11ae1c4b749
2022-02-11 13:33:07 -08:00
Paige Sun f9fa385eb1 Log softerror when attempting to use ReactInstanceManager in Bridgeless Mode
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D34060026

fbshipit-source-id: 41441c0b16c4ef0248957eae11d9c9bc642f6d34
2022-02-10 15:00:50 -08:00
Joshua Gross 9bc6c0f8a5 Fix UIManager detection in touch event emitter
Summary:
Certain events (practically always touch events probably?) will not be correctly emitted to JS in Fabric if there is no View underneath the touch - if there is no touch target besides the ReactRootView.

We can just rely on the UIManagerType annotation on the Event, which is correct and reliable.

Instead, what we do today is derive UIManagerType from ViewTag, which is correct UNLESS the viewtag is the same as the SurfaceId, in which case we may incorrectly detect that the touch is on a non-Fabric View when in fact it is on a Fabric ReactRootView.

ViewTag is not a reliable way to detect Fabric vs non-Fabric /when looking at the RootView/, where ViewTag is the same as SurfaceId. Ironically, only Fabric RootViews have a SurfaceId at all.

Practically, this won't change anything since events emitted to ReactRootView don't go anywhere (they don't have EventEmitters). So this is a pretty low-stakes fix, but is still technically correct.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D34149878

fbshipit-source-id: f01da556865eb597a50cd49e9787316a0ed56f70
2022-02-10 14:07:24 -08:00
Gabriel Donadel Dall'Agnol 6b61995647 build(deps): Bump android Appcompat to 1.4.1 (#33072)
Summary:
Currently we are using Appcompat in version 1.0.2 which is almost 4 years old now, this PR updates it to version 1.4.1.

Using Appcompat 1.0.2 was also causing a crash on RNTester due to an error where FontFamily's method was not found (Related to https://github.com/facebook/react-native/issues/33065)

Closes https://github.com/facebook/react-native/issues/31620

## Changelog

[Android] [Changed] - Bump android Appcompat to 1.4.1

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

Test Plan: Use `./scripts/test-manual-e2e.sh` to test both RNTester and a new app

Reviewed By: cortinico

Differential Revision: D34107105

Pulled By: ShikaSD

fbshipit-source-id: 966e4687b09ae50a88ee518622f073d72e8c6550
2022-02-10 09:52:59 -08:00
Ian Childs 172f990dcf exported and provided dep should be exported_provided_dep
Reviewed By: astreet

Differential Revision: D34108185

fbshipit-source-id: 72a6c9fb3654d674df405faac49dfbe67fe193b7
2022-02-10 07:47:52 -08:00
Samuel Susla e47e869a00 Remove gating for react_fabric.enableV2AsynchronousEventBeat
Summary:
changelog: [internal]

enableV2AsynchronousEventBeat is shipped, let's remove gating

Reviewed By: javache

Differential Revision: D34108109

fbshipit-source-id: 0264c85cf01f011ab368d56e12f79cc978f9e106
2022-02-10 06:53:20 -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
Kuba Holuj 9ed2df628d Fix StatusBar on Android API 30 (#33058)
Summary:
In https://github.com/facebook/react-native/issues/32975 I implemented the new `insetsController#setSystemBarsAppearance` interface, but I found that on Android 11 (API 30) it doesn't appear to work which I missed in earlier testing. It works correctly on Android 12 and the deprecated `systemUiVisibility` interface still works fine on Android 11, so I'm having Android 11 use the deprecated mechanism.

## Changelog

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

[Android] [Fixed] - Fix StatusBar on Android API 30

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

Test Plan: Tested in `rn-tester` on simulators using Android 9, 10, 11, 12, and on an Android 9 device.

Reviewed By: lunaleaps

Differential Revision: D34050025

Pulled By: ShikaSD

fbshipit-source-id: ad80fae1446aca368b09df810785a1cc38383450
2022-02-10 05:31:30 -08:00
Ian Childs f7e7e89335 provided_dep does not need to be a dep too
Differential Revision: D34108108

fbshipit-source-id: b31d2e87c8dcbe5a9b2ad9d74c54958cf1571026
2022-02-09 16:21:55 -08:00
Xin Chen fc7eb91f56 Add RedBoxSurfaceDelegate to DevSupportManagerBase to abstract surface logic to show RedBox
Summary:
This diff adds `RedBoxSurfaceDelegate` to replace existing logic in `DevSupportManagerBase` to abstract how we show/hide the RedBox surface. The delegate will wrap a RedBoxDialog instance, which is used to show/hide the dialog for default behavior (when there is no surface delegate for redbox got provided).

I also updated the interface for delegate to accomodate new use cases:
- Add `isShowing` for the `SurfaceDelegate`
- Add a list of getters for `DevSupportManager` for data access in the delegate
- (Update 2/7) Separate Dialog from `RedBoxDialog`, and re-named it to `RedBoxContentView`. This is to make it clear that the delegate is responsible to provide actual surface implementation (Dialog). The content view is meant to be shared.

Changelog:
[Android][Internal]

Reviewed By: javache

Differential Revision: D33987835

fbshipit-source-id: 57c20648e7f2ec8238963feca27ccd5518e7931d
2022-02-09 15:16:22 -08:00
Hamid 5341ad8962 use root locale when converting string case (#33028)
Summary:
Not setting locale for language/country neutral operation may cause bug depending on the default locale.
See https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#ROOT

Note: I am just searching for toLowerCase() and toUppercase() in my project's dependencies and send the same PR, in order to just be considered. Although I've seen the lack of explicit locale has caused issues for us, I am not sure if react-native is actually affected. I haven't checked for `String.format()` yet.

Example related issue: joltup/rn-fetch-blob#573

## Changelog

[Android] [Fixed] - Use root locale when converting string case.

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

Reviewed By: ShikaSD

Differential Revision: D33943446

Pulled By: cortinico

fbshipit-source-id: d5be9392ea7c21a33436acac5b5e8c50b7c7e31e
2022-02-09 14:06:34 -08:00
Aniket Mathur 4f42f4d18f Revert D34084935: Fix analysis errors with the FBCODE platform
Differential Revision:
D34084935 (https://github.com/facebook/react-native/commit/216ac27aa361b22c847878feb38ad84f6d9f5692)

Original commit changeset: 8199b0b16b6b

Original Phabricator Diff: D34084935 (https://github.com/facebook/react-native/commit/216ac27aa361b22c847878feb38ad84f6d9f5692)

fbshipit-source-id: b5d725854c92282b2e5eddeff48d6b57b2318c1f
2022-02-09 13:16:07 -08:00
Aniket Mathur 216ac27aa3 Fix analysis errors with the FBCODE platform (#33073)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33073

Differential Revision: D34084935

fbshipit-source-id: 8199b0b16b6b390a09138cf30b4056c578d2354f
2022-02-09 12:43:29 -08:00
David Vacca eafa5bcb38 Log timestamp in ReactMarker.logFabricMarker method
Summary:
Ensure we always log a timestamp in ReactMarker.logFabricMarker

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D34006699

fbshipit-source-id: 79ff1005ba1f0ed44bf319e50a80dbdebd1ec24f
2022-02-09 10:03:34 -08:00
David Vacca 97064ae1fb Fix DarkMode for DatePickerDialogFragment
Summary:
Fix DarkMode for DatePickerDialogFragment

changelog: [Android][Fixed] Fix DarkMode on Calendar DateTimePicker

Reviewed By: JoshuaGross

Differential Revision: D34092084

fbshipit-source-id: 4fbe3484bc7101c4b7d244671d7d46cae1c23bec
2022-02-08 20:46:58 -08:00
Genki Kondo bb435a2b11 Support AnimatedColor.setValue for platform colors
Summary:
In order to support AnimatedColor.setValue for platform colors, we need to pass the platform color object to the native animated node which will then resolve and apply the color.

Thus, the approach is:
- Add a new API updateAnimatedNodeConfig to NativeAnimatedModule
- [JS] On AnimatedColor.setValue, if the value is a platform color, then we call updateAnimatedNodeConfig
- [Android] We introduce AnimatedNodeWithUpdateableConfig interface with a method updateConfig. On ColorAnimatedNode.java, we use updateConfig to resolve and apply the color

Changelog:
[Internal][Fixed] - Use context from view when resolving platform color

Reviewed By: javache, mdvacca

Differential Revision: D34025193

fbshipit-source-id: 8b368f6b7cb2cf7cebe8b66461cd4185cbadd44c
2022-02-08 16:31:14 -08:00
Genki Kondo 1a044123fc Use context from view when resolving platform color if activity doesn't exist
Summary:
There are cases where the activity may not exist (such as for VRShell panel apps). In this case we will search for a view associated with a PropsAnimatedNode to get the context.

Changelog:
[Internal][Fixed] - Use context from view when resolving platform color if activity doesn't exist

Reviewed By: javache

Differential Revision: D34022882

fbshipit-source-id: c316935af1034ea770f3ef9334f77d6dc783fb27
2022-02-08 11:42:27 -08:00
Andrei Shikov ebc856b2de Check if view exists before skipping CREATE command
Summary:
Updates early return in the CREATE command codepath that checks if the view already exists before allocating it. Normally the view state is expected to be created only if the view is preallocated, but empty view state is also created for the flattened nodes when they create an event emitter.

By checking the view existence, we can ensure that view was indeed preallocated before, and skip for optimization purposes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D34050884

fbshipit-source-id: 489fc1052fec9f71712ea729121ac8ef3e3f3d4e
2022-02-08 08:41:35 -08:00
Xin Chen 97ce240a27 Update RedBoxDialog to separate content view and dialog
Summary:
This diff separates the content view creation logic from existing `RedBoxDialog` logic. After the change, `RedBoxDialog` is no longer a subclass of `Dialog`, but behaves like a dialog with forwarding pattern to delegate dialog API to internal member. This will keep the APIs consistent with dependent components.

The motivation of the change is to make the content view reusable. This is important in VR surface where we don't have activities and necessary implementations for Dialog to show.

Changelog:
[Android][Internal]

Reviewed By: javache

Differential Revision: D34016503

fbshipit-source-id: 261594bda9f6fb2d83764a1e5ec2e9e60d8d39a3
2022-02-07 15:31:15 -08:00
Xin Chen 99890bfacf Move RedBoxHandler interface to the proper interfaces directory
Summary:
We put the `:interfaces` target on the dependencies list for `:devsupport` target in the [BUCK file](https://fburl.com/code/lrr1c0pn). In the following diffs I will need to put the interface [`/devsupport/RedBoxHandler`](https://fburl.com/code/v53euvps) on to [`/devsupport/interfaces/DevSupportManager`](https://fburl.com/code/k8gwxa0f). This violates the dependency rule.

Since `RedBoxHandler` is an interface, I moved it to the interfaces list in this diff to unblock.

Changelog:
[Android][Internal]

Reviewed By: yungsters

Differential Revision: D33987834

fbshipit-source-id: 77a1ee14bd10c6bbaac2ee465ae7050e99ed0399
2022-02-07 13:43:49 -08:00
Samuel Susla 731429ebcf Enable RuntimeScheduler::callExpiredTasks on Android
Summary:
changelog: [internal]

In order to call `RuntimeScheduler::callExpiredTasks`, we need to pass it to `Scheduler` through context container.

Reviewed By: javache

Differential Revision: D34042293

fbshipit-source-id: 62d18507fb107c5be2ac9d003f63735aab6a09ac
2022-02-07 10:06:08 -08:00
Genki Kondo be260b9f47 Fix ScrollView contentOffset
Summary:
When setting ScrollView's contentOffset, if the ScrollView hasn't been laid out yet when ReactScrollViewManager.setContentOffset is called, then scroll position is never set properly. This is because the actual scroll offset (0, 0) was being passed into setPendingContentOffsets, instead of the desired scroll offset. Thus,
when ReactScrollView.onLayout gets called, ReactScrollView.scrollTo gets called with (0, 0).

Also updates out of date comments,

Changelog:
[Android][Fixed] - Fix ScrollView contentOffset

Reviewed By: ryancat

Differential Revision: D34015853

fbshipit-source-id: 84141a663fdb0ace2be7cef61f14944cb08125d1
2022-02-04 16:28:54 -08:00
David Vacca 7cc7e66564 Update javadoc of ReactRoot.getState()
Summary:
Update javadoc of ReactRoot.getState() since the task was fixed and the API remained the same

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D33981298

fbshipit-source-id: 0136a640b884a787b0a20162781735630c1fa1c7
2022-02-04 10:34:52 -08:00
Nicola Corti fa85417179 Do not bundle libhermes.so or libjsc.so inside the React Native Android AAR (#33038)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33038

While rolling out RN 0.68.x we noticed that `libhermes.so` and `libjsc.so` were included
inside the final .aar we publish to NPM. This forced users (on both old or new arch) to
specify a `pickFirst` directive inside their packaging option (which is unpractical and
risky as the two .so might not be compatible each other if they're coming from
different Hermes/JSC versions).

Changelog:
[Android] [Fixed] - Do not bundle libhermes.so or libjsc.so inside the React Native Android AAR

Reviewed By: ShikaSD

Differential Revision: D33979107

fbshipit-source-id: 0b71d59f210b8bc9903cd0f30ed6e2120aab99e0
2022-02-03 08:44:53 -08:00
Samuel Susla 4cbcb7a13a Abandon mc react_fabric.enable_event_emitter_wrapper_raw_pointer
Summary:
changelog: [internal]

Remove gating.

Reviewed By: philIip

Differential Revision: D33944220

fbshipit-source-id: bba076a2166f8d676119d5c069a3894e3d547285
2022-02-03 04:50:04 -08:00
Genki Kondo 08faa130dd Delete ReactFeatureFlags.enableRoundedCornerPostprocessing
Summary:
Rounded corner postprocessing has been disabled for 2 months now, and [metrics neutral](https://www.internalfb.com/intern/qe2/react_fabric_marketplace_home_android_universe/react_fabric_disable_rounded_corner_postprocess_android/setup/config). Removing the flag and associated codepaths.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33953645

fbshipit-source-id: b0e5a6068114d74292f17450a22816f19cae6f15
2022-02-02 15:55:54 -08:00
Andrei Shikov 48318b1542 Cleanup OSS proguard rules and add @DoNotStripAny
Summary:
title

Changelog: [Changed][Android] - Added DoNotStripAny proguard rules

Reviewed By: cortinico

Differential Revision: D33921797

fbshipit-source-id: 93628d6222c74976b40efc2507a482d8a6a4fe1b
2022-02-02 12:54:34 -08:00
John Porto 1bf84a63d8 Make automatic SampleProfiling registration optional.
Summary:
This change makes automatic sample profiling registration opt in. This is in preparation for an upcoming change where hermes
will enforce that the sampling profiler must be destroyed on
the same thread it was created.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D33826992

fbshipit-source-id: 89843b5fc5b936f674a8d0a470e92af0cd8f6125
2022-02-02 10:52:56 -08:00
Andrei Shikov 65df2f30a5 Support view allocation counters with Venice
Summary:
Venice uses `SurfaceHandler` abstraction which start/stops surfaces independently from `Binding.cpp`, so previous `onSurfaceStart/Stop` callback would not be triggered.

On Android, each surface is used exactly once at the time of writing, so we can use `register/unregister` callbacks to create/clear remembered views for the surface.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33845685

fbshipit-source-id: 8de4204c7498176fdbe8d44fbc5f2e4079212a1c
2022-02-02 09:17:56 -08:00
Genki Kondo cb42049e0a Support platform color with AnimatedColor on Android
Summary:
Adds support for platform colors in AnimatedColor.
Passes the processed native color object to the native ColorAnimatedNode via the native config; ColorAnimatedNode then uses ColorPropConverter.getColor to resolve the resource path.

Note: setting a platform color via setValue on an existing AnimatedColor is not supported yet

Changelog:
[Android][Added] - Support platform color with AnimatedColor

Reviewed By: yungsters

Differential Revision: D33922266

fbshipit-source-id: 04d39a5ce0872b31d06ffbd4639d2f2213cf3314
2022-02-01 16:12:30 -08:00
Felipe Perez 3552ff0562 Back out "Delete RuntimeScheduler yielding mobile config"
Summary:
D33740360 (https://github.com/facebook/react-native/commit/16ed62a850dd81bd9cc7f77ab3e77f42ed64b177) 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
Pieter De Baets 79975d146e Fix display metric used for scrollview snapping
Summary:
Similarly to D29864944 (https://github.com/facebook/react-native/commit/6d4fff2e5ccaffb6b0255a139f2ae8e009278948) we want to use `getWindowDisplayMetrics` instead of `getScreenDisplayMetrics`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33916223

fbshipit-source-id: cae07b1f0c1498745f28d0b9f860edcc55bde5ed
2022-02-01 10:58:25 -08:00
Keshav Kolur 554b35daf4 Revert D33852709: Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android
Differential Revision:
D33852709 (https://github.com/facebook/react-native/commit/dc507be4d9a9d3edce4b2a0b2b7a0cbbcd0cffd0)

Original commit changeset: 1ff3a1225e68

Original Phabricator Diff: D33852709 (https://github.com/facebook/react-native/commit/dc507be4d9a9d3edce4b2a0b2b7a0cbbcd0cffd0)

fbshipit-source-id: 10db2d1bda1ea69b9a0226041493af06b78c16c4
2022-01-31 14:15:36 -08:00
Keshav Kolur dc507be4d9 Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android
Summary: Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android

Reviewed By: alexmalyshev

Differential Revision: D33852709

fbshipit-source-id: 1ff3a1225e681d0924ec04e955b0039724182b1c
2022-01-31 13:41:23 -08:00
Kuba Holuj 50c8e973f0 Update StatusBar for Android 11+ (#32975)
Summary:
Android 11 (API 30) introduced a new interface for changing the appearance of the status bars with [`WindowInsetsController#setSystemBarsAppearance`](https://developer.android.com/reference/kotlin/android/view/WindowInsetsController#setsystembarsappearance) and deprecated using the `WindowManager#systemUiVisibility` properties.

Apparently, once you call `setSystemBarsAppearance` Android will no longer respect `systemUiVisibility` and if anyone, such as the Android 12 Splash Screen library, happens to call it, it will break status bars.

This PR augments the RN StatusBarModule to use the new interface on Android 11+.

Also updated the rn-tester app, see video.

https://user-images.githubusercontent.com/1124321/151321561-8202e237-cf7d-45ce-b957-18b5bafd17c4.mov

## 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] - Use new StatusBar API on Android 11 (API 30)+

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

Reviewed By: cortinico

Differential Revision: D33814853

Pulled By: ShikaSD

fbshipit-source-id: c0f2651015dddb4871a3e3b26642f76a46da2a76
2022-01-31 11:32:51 -08:00
Elias Nahum 6239e2f5ce Android: Fix crash when WindowInsets is null on ReactRootView (#32989)
Summary:
Fixes a potential crash was introduced by https://github.com/facebook/react-native/issues/30919 that aimed to get the keyboard height on devices with a Notch. The problem is that it considers that any ReactRootView will have an insets available.

When using [react-native-navigation](https://github.com/wix/react-native-navigation) and assigning a Navigation button to the TopBar as a component, the component gets registered as a RootView but won't have any insets attach to the view.

[getRootWindowInsets()](https://developer.android.com/reference/android/view/View#getRootWindowInsets()) in fact return a `WindowInset` only available if the view is attached, so when executing `checkForKeyboardEvents` method from ReactRootView, is trying to access the `DisplayCutout` of a null object, leading to a crash.

## Changelog

[Android] [Fixed] - Fix potential crash if ReactRootView does not have insets attached.

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

Test Plan:
Without the code change: Notice how the second screen being push contains a React Component on the top right of the navigation bar, and when component is unmounted (going back) the app crashes.

https://user-images.githubusercontent.com/6757047/151558235-39b9a8b5-be73-4c31-8053-02ce188637b8.mp4

crash log
```
2022-01-28 10:27:52.902 15600-15600/com.mattermost.rnbeta E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mattermost.rnbeta, PID: 15600
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayCutout android.view.WindowInsets.getDisplayCutout()' on a null object reference
        at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.checkForKeyboardEvents(ReactRootView.java:778)
        at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.onGlobalLayout(ReactRootView.java:769)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:1061)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3214)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2143)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8665)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
        at android.view.Choreographer.doCallbacks(Choreographer.java:845)
        at android.view.Choreographer.doFrame(Choreographer.java:780)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7839)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
```

After applying the patch which is only a null check validation and does not change any previous behavior

https://user-images.githubusercontent.com/6757047/151558429-9ff1a608-abb6-4168-8db9-df0c3c71d79e.mp4

Reviewed By: cortinico

Differential Revision: D33844955

Pulled By: ShikaSD

fbshipit-source-id: ed5579ad3afeed009c61cc1851eee45c70087cf5
2022-01-31 07:58:28 -08:00
Genki Kondo 3f49e6763e Support color animation with native driver for Android
Summary:
Adds support for Animated.Color with native driver for Android. Reads the native config for the rbga channel AnimatedNodes, and on update(), converts the values into an integer (0xaarrggbb)

Followup changes will include support for iOS and platform colors.

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

Reviewed By: javache

Differential Revision: D33833600

fbshipit-source-id: 2bf05c9715b603cf014ace09e9308b2bfd67f30a
2022-01-29 13:51:41 -08:00
Paige Sun 79ae50f3e9 Remove Static View Configs from bridge mode
Summary:
Changelog: [Internal]

Remove all the MCs that enable SVCs in Fabric, because we'll only test SVCs in Bridgeless mode to simplify rollout. There were complications with enabling SVCs in Fabric at a previous rollout.

Reviewed By: RSNara

Differential Revision: D33861243

fbshipit-source-id: fdbfedce77f8bd1bab2a807237017787ae8bf7c1
2022-01-28 23:39:38 -08:00
Paige Sun b4b5c59645 Add ComponentNameResolverManager to make UIManager.hasViewManagerConfig() work on Venice
Summary: Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D33860658

fbshipit-source-id: 41079b13acef531877c82dc0b2063dbe2b42edcf
2022-01-28 18:46:04 -08:00
Kudo Chien 384e1a0c7b Add missing sources jar into published android artifacts (#32982)
Summary:
when migrated to `maven-publish` in https://github.com/facebook/react-native/issues/31611, the sources jar is not included by default from `maven-publish`. so react-native 0.66 / 0.67 doesn't include sources jar in npm published artifacts. it's not ideal for debug or tracing code.

this pr added the sources jar into the published artifact.

## Changelog

[Android] [Fixed] - Add missing sources jar into published android artifacts

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

Test Plan:
make sure sources jar is included in artifact.

```
$ ./gradlew :ReactAndroid:installArchives
$ find android -name '*sources.jar*'
```

Reviewed By: ShikaSD

Differential Revision: D33842979

Pulled By: cortinico

fbshipit-source-id: f99ad46ce0cca0cfc2ab1d5c5a4fcb40a02683e7
2022-01-28 06:17:12 -08:00