Commit Graph

5872 Commits

Author SHA1 Message Date
Gijs Weterings 24dbb5df0a Back out "Migrate packages to not eager initialize view managers"
Summary:
Original commit changeset: fd172fc664d6

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

Reviewed By: huntie

Differential Revision: D43843828

fbshipit-source-id: af977dd51135505e1823c440e3cbaf9d4ea02545
2023-03-06 10:29:45 -08:00
Lulu Wu d7eb3bfcb3 Migrate packages to not eager initialize view managers
Summary:
Migrate packages need for Catalyst app to use lazy view manager initialisation

Changelog:
[Android][Changed] - Migrate packages to not eager initialize view managers

Reviewed By: javache

Differential Revision: D43711708

fbshipit-source-id: fd172fc664d68fb7ee1d5a980516cdf48e30a979
2023-03-06 03:28:32 -08:00
Xin Chen ec99ba1413 Add android app start time implementation
Summary:
This diff adds the android `appStartTime` implementation for `ReactMarker`.

Changelog:
[Android][Internal] - Add the android `appStartTime` implementation for `ReactMarker`

Reviewed By: rshest

Differential Revision: D43523607

fbshipit-source-id: 9dc95db30e36e7c1bfb262c74598f0ac249522f2
2023-03-02 22:40:12 -08:00
Nick Gerleman 02e29abead Improve handling of invalid DimensionValue usage (#36346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36346

1. Remove Paper native assertions for converting DimensionValue string to Yoga unit, and fix a case where Fabric could throw on invalid value.
2. Move DimensionValue types in TypeScript to use template literal types, to show malformed strings in-editor, during typechecking. Update min TS version to allow this (in conformance with the min TS version used by DefinitelyTyped).

Changelog:
[General][Added] - Improve handling of invalid DimensionValue usage

Reviewed By: javache

Differential Revision: D43153075

fbshipit-source-id: db4e813df6e81cbd3158edad7c07c7a90c009803
2023-03-02 20:23:08 -08:00
Xin Chen c1023c73b0 Add performance.reactNativeStartupTiming API
Summary:
This diff adds the `performance.reactNativeStartupTiming` API to the performance global object for RN. This property does not exist in web, and we are free to make up our own list of properties in the startup metrics to track RN app startup process. In our case, we have the following six properties to begin with (we may extend and add more to this list in the future):

```
- `(start|end)Time`: The time ‘zero’ for the startup timing and the end of app startup. RN has no knowledge of app start time, which will be provided by the platform. The `endTime` will be the time when the first JS bundle finishes executing (Note that RN supports multiple JS bundles, which can be loaded async)
  - `executeJavaScriptBundleEntryPoint(Start|End)`: The time for RN to execute the JS entry point (and finish all sync job)

```

Changelog:
[General][Added] - Add new JS performance API to support getting RN app startup timings

Reviewed By: rshest

Differential Revision: D43326564

fbshipit-source-id: 7b4c7cae70ff64ba1714a1630cd5e183df6c06b0
2023-03-02 20:04:42 -08:00
Nicola Corti ab55e123da Expose UnstableReactLegacyComponentDescriptor inside rrc_legacyviewmanagerinterop
Summary:
This adds the `UnstableReactLegacyComponentDescriptor`, part of the Fabric Interop Layer for Android.

Summary of the changes are:
* Expose a new `rrc_legacyviewmanagerinterop` native module via prefab
* Extend default App Cmake setup so `rrc_legacyviewmanagerinterop` is exposed by default
* Add a sample legacy component inside RN Tester

Changelog:
[Internal] [Changed] - Expose UnstableReactLegacyComponentDescriptor inside react/renderer/core

Reviewed By: cipolleschi

Differential Revision: D43731219

fbshipit-source-id: ee26d7e9d7eff5ef6a3e22853f8ea363b9198567
2023-03-02 05:10:45 -08:00
Simeng Pang 851c8c671a Revert D43500868: Expose UnstableReactLegacyComponentDescriptor inside react/renderer/components/legacyviewmanagerinterop
Differential Revision:
D43500868 (https://github.com/facebook/react-native/commit/071f6d2ca697ad298f41572e3d70a238f00ae8a3)

Original commit changeset: acfcd89efc42

Original Phabricator Diff: D43500868 (https://github.com/facebook/react-native/commit/071f6d2ca697ad298f41572e3d70a238f00ae8a3)

fbshipit-source-id: bb354015b2dcc812491b0219c6dd4d9c6321dc0b
2023-03-01 23:09:13 -08:00
Nicola Corti 071f6d2ca6 Expose UnstableReactLegacyComponentDescriptor inside react/renderer/components/legacyviewmanagerinterop (#36344)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36344

This adds the `UnstableReactLegacyComponentDescriptor`, part of the Fabric Interop Layer,
inside the `react/renderer/components/legacyviewmanagerinterop` module so that it can be included by the user externally.

If we wish to place it somewhere else, I'm more than happy to move it around.

Changelog:
[Internal] [Changed] - Expose UnstableReactLegacyComponentDescriptor inside react/renderer/components/legacyviewmanagerinterop

Reviewed By: mdvacca, cipolleschi

Differential Revision: D43500868

fbshipit-source-id: acfcd89efc42ff7a4ee6cb0a1cbd71d69f79721f
2023-03-01 17:58:07 -08:00
Pieter De Baets a49446b5b5 Fix Java 6 build breakage (#36338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36338

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D43694918

fbshipit-source-id: bf80cb1147dddc1c5e18d9cb8a5a805a33833de1
2023-03-01 06:44:40 -08:00
Pieter De Baets a1f6b4d0ef Synchronize access to ViewManagerRegistry
Summary:
Found that we may do multiple allocations of the same ViewManager instance since ViewManagers are both accessed from the UI thread (mounting views) and from the Fabric background thread (for measuring Text), which could lead to multiple instances of the same ViewManager to be created.

As far as I can tell, this issue was harmless since our ViewManager constructors don't have side-effects, but not ideal.

Changelog: [Internall]

Reviewed By: rshest

Differential Revision: D43661306

fbshipit-source-id: 37ef82d41d43c334fdc6cfbeffb225bba87c668e
2023-03-01 04:37:05 -08:00
Pieter De Baets 729dcf6b29 Fix more warnings on bridge invalidation
Summary:
Looked at the top soft exceptions firing from this codepath. Most of these should use `getReactApplicationContext` instead of `getReactApplicationContextIfActiveOrWarn` to do their cleanup on invalidation.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D43661307

fbshipit-source-id: 27094a6e8dfcf4748eb916531c4998f1c9ee8713
2023-03-01 04:37:05 -08:00
Pieter De Baets 848ac0c3be Remove eager view manager preinit support
Summary:
Pre-initializing ViewManagers is not as valuable now that we've rolled out StaticViewConfigs on the new architecture. This was primarily used to pre-allocate constants and the `preInitializeViewManagers` was already deprecated.

Changelog: [Android][Removed] UIManager.preInitializeViewManagers

Reviewed By: rshest

Differential Revision: D43661304

fbshipit-source-id: 391c5207ec876a70ddd4bda30a58267090da3ff1
2023-03-01 04:37:05 -08:00
fabriziobertoglio1987 a0adf57e50 Add TYPE_VIEW_HOVER_ENTER to AccessibilityNodeInfo sendAccessibilityEvent (#34969)
Summary:
- Adds `AccessibilityEvent.TYPE_VIEW_HOVER_ENTER` to AccessibilityNodeInfo sendAccessibilityEvent
- Adds an example implementation.

fixes https://github.com/facebook/react-native/issues/30860 fixes https://github.com/facebook/react-native/issues/30097
Related Documentation https://github.com/facebook/react-native-website/pull/3438

## Changelog

[Android] [Added] - Add TYPE_VIEW_HOVER_ENTER to AccessibilityNodeInfo sendAccessibilityEvent

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

Test Plan:
Android: https://github.com/facebook/react-native/pull/34969#issuecomment-1320225358 https://github.com/facebook/react-native/pull/34969#issuecomment-1329779921
iOS: https://github.com/facebook/react-native/pull/34969#issuecomment-1329780545 https://github.com/facebook/react-native/pull/34969#issuecomment-1330984202

Reviewed By: christophpurrer

Differential Revision: D42613990

Pulled By: lunaleaps

fbshipit-source-id: 8c8950610799dcc74067d2b47b44d4ff030f66e5
2023-02-28 20:57:35 -08:00
David Vacca 22ba1e45c5 Remove code only used by Android API level < 21
Summary:
Min Android API level is 21, this diff is removing code for Android API level < 21

changelog: [RN][Android] removing code for Android API level < 21

Reviewed By: cortinico, RSNara

Differential Revision: D43544497

fbshipit-source-id: 1ece1143a37a038826361b55ff08a8160f03108d
2023-02-28 16:11:05 -08:00
fabriziobertoglio1987 cbe934bcff 1/2 TextInput accessibilityErrorMessage (Talkback, Android) (#33468)
Summary:
**Android**: The functionality consists of calling the [AccessibilityNodeInfo#setError][10] and [#setContentInvalid][13] method to display the error message in the TextInput.

**Fixes [https://github.com/facebook/react-native/issues/30848][51] - Adding an accessibilityErrorMessage prop to the TextInput Component**:
**Android**: The prop accessibilityErrorMessage triggers the AccessibilityNodeInfo method [setError][10] which automatically sets the correct properties on the AccessibilityNodeInfo that will inform screen readers of this state. The method calls setContentInvalid(true) and setError(youErrorString) on the AccessibilityNodeInfo.

**Fixes [https://github.com/facebook/react-native/issues/30859][52] -  Detecting changes in the Error state (text inputs)**
**Fabric - Android** - Adding accessibilityErrorMessage to field AndroidTextInputState.
ReactTextInputManager and ReactEditText receive state updates both from [Javascript][32] and [cpp (fabric)][34].
- accessibilityErrorMessage is added to the fabric AndroidTextInputState field
- The updates are received in the ReactAndroid API with method updateState from ReactTextInputManager
- After updating the TextInput text with onChangeText, the update of the accessibilityErrorMessage is triggered with method maybeSetAccessibilityError which triggers [setError][10].

More info:
- An explanation of [state updates between fabric and ReactAndroid for the TextInput component][34]
- [ReactNative renderer state updates][35]

**Paper - Android** - Adding accessibilityErrorMessage to ReactTextInputShadowNode to trigger updates in Paper renderer when accessibilityErrorMessage is changed within the onChange callback.

Related Links (Android):
- [In this diff I'm shipping and deleting mapBufferSerialization for Text measurement][101]
- [This diff implement and integrates Mapbuffer into Fabric text measure system][39]
- [Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism][100]
- [TextInput: support modifying TextInputs with multiple Fragments (Cxx side)][24]
- [TextInput: keep C++ state in-sync with updated AttributedStrings in Java][23]
- [AccessibilityNodeInfo#setError][11]
- [Explanation on how TextInput calls SET_TEXT_AND_SELECTION in Java API][32]
- [Fabric: convertRawProp was extended to accept an optional default value][27]
- [understanding onChangeText callback][31]
- [Editable method replace()][12]
- [Change of error state from onChangeText show/hides a TextInput error][30]
- [AndroidTextInput: support using commands instead of setNativeProps (native change)][25]
- [TextInput: support editing completely empty TextInputs][26]
- [[Android] Fix letters duplication when using autoCapitalize https://github.com/facebook/react-native/issues/29070][40]
- [Support optional types for C++ TurboModules][28]
- [discussion on using announceForAccessibility in ReactEditText][36]
- [ fix annoucement delayed to next character][61]
- [Announce accessibility state changes happening in the background][29]
- [Refactor MountingManager into MountingManager + SurfaceMountingManager][37]

iOS Functionalities are included in separate PR https://github.com/facebook/react-native/pull/35908
Documentation PR https://github.com/facebook/react-native-website/pull/3010

Next PR [2/2 TextInput accessibilityErrorMessage (VoiceOver, iOS) https://github.com/facebook/react-native/issues/35908](https://github.com/facebook/react-native/pull/35908)
Related https://github.com/facebook/react-native-deprecated-modules/pull/18

## Changelog

[Android] [Added] - Adding TextInput prop accessibilityErrorMessage to announce with TalkBack screenreaders

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

Test Plan:
**Android - 20 Jan 2023**
https://github.com/facebook/react-native/pull/33468#issuecomment-1398228674

**iOS - 20 Jan 2023**
https://github.com/facebook/react-native/pull/33468#issuecomment-1398249006

<details><summary>CLICK TO OPEN OLD VIDEO TEST CASES</summary>
<p>

**PR Branch - Android and iOS 24th June**
[88]: Android - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event (Fabric) ([link][88])

**PR Branch - Android**
[1]. Test Cases of the functionality (Fabric) ([link][1])
[2]. Test Cases of the functionality (Paper) ([link][2])

**Main Branch**
[6]. Android - Runtime Error in main branch when passing value of 1 to TextInput  placeholder prop ([link][6])

**Issues Solved**
[7]. TalkBack error does not clear error on the next typed character when using onChangeText ([link][7])
**Other Tests**
[8]. Setting the TextInput errorMessage state with setTextAndSelection Java API from JavaScript ([link][8])
[9]. Setting the TextInput errorMessage state from fabric TextInput internal state to Java ReactTextUpdate API ([link][9])

</p>
</details>

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1072101477 "Test Cases of the functionality (Android - Fabric)"
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1105964322 "Test Cases of the functionality (Android - Paper)"
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1116329282 "Test Cases of the functionality (iOS - Fabric)"
[6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1087020844 "Runtime Error in main branch when passing value of 1 to TextInput  placeholder prop"
[7]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1096086753 "TalkBack error announcement done on next typed character with onChangeText"
[8]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1082594363 "setting the TextInput errorMessage state with setTextAndSelection Java API from JavaScript"
[9]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1082598745 "Setting the TextInput errorMessage state from fabric TextInput internal state to Java ReactTextUpdate API"

[10]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setError(java.lang.CharSequence) "AOSP setError"
[11]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setError(java.lang.CharSequence) "AccessibilityNodeInfo#setError"
[12]: https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/text/Editable.java#L28-L52 "Editable method replace"
[13]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setContentInvalid(boolean) "setContentInvalid"

[20]: https://github.com/facebook/react-native/commit/60b6c9be8e811241039a6db5dc906a0e88e6ba82 "draft implementation of android_errorMessage "
[21]: https://github.com/facebook/react-native/commit/012d92d0b7e5de2436f186cdbff32ba128e537d5 "add errorMessage to ReactTextUpdate and maybeSetAccessibilityError"
[22]: https://github.com/fabriziobertoglio1987/react-native/commit/cad239bded5748753cee2266c27809e24c6199fb "rename android_errorMessage to errorMessageAndroid"
[23]: https://github.com/fabriziobertoglio1987/react-native/commit/0bae47434ef79eb606c453c5be8105b8df00783a "TextInput: keep C++ state in-sync with updated AttributedStrings in Java"
[24]: https://github.com/fabriziobertoglio1987/react-native/commit/0556e86d09404105dc7ff695686b8b7c01911c5c "TextInput: support modifying TextInputs with multiple Fragments (Cxx side)"
[25]: https://github.com/fabriziobertoglio1987/react-native/commit/7ab5eb4cafdea695c4c53ce2a737f6302afd6380 "AndroidTextInput: support using commands instead of setNativeProps (native change)"
[26]: https://github.com/fabriziobertoglio1987/react-native/commit/b9491b7c5104066b2714045cd7710f995458c9e9 "TextInput: support editing completely empty TextInputs"
[27]: https://github.com/fabriziobertoglio1987/react-native/commit/7f1ed6848f89bdccc7f7a5cc76019eec67e76b2f "Fabric: convertRawProp was extended to accept an optional default value"
[28]: https://github.com/facebook/react-native/commit/6e0fa5f15eef71abcfb47750eb3669065ba2ab7d "Support optional types for C++ TurboModules"
[29]: https://github.com/fabriziobertoglio1987/react-native/commit/baa66f63d8af2b772dea8ff8eda50eba264c3faf "Announce accessibility state changes happening in the background"

[30]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1071989570 "Change of error state from onChangeText show/hides a TextInput error"
[31]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1074827746 "understanding onChangeText callback"
[32]: https://github.com/facebook/react-native/issues/29063#issuecomment-658189938 "Explanation on how TextInput calls SET_TEXT_AND_SELECTION in Java API"
[33]: https://github.com/facebook/react-native/pull/33468#discussion_r835036889 "Explanation of TextInput state management with fabric C++ and JAVA API"
[34]: https://github.com/facebook/react-native/pull/33468#discussion_r835036889 "state updates between fabric and ReactAndroid for the TextInput component"
[35]: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates "ReactNative renderer state updates"
[35]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1080144483 "Analysis on how AndroidTextInputState.cpp sends updates to ReactTextInputManager"
[36]: https://github.com/facebook/react-native/pull/33468#discussion_r848162849 "discussion on using announceForAccessibility in ReactEditText"
[37]: https://github.com/fabriziobertoglio1987/react-native/commit/29eb632f1cb2ef5459253783eac43e5d7e999742 "Refactor MountingManager into MountingManager + SurfaceMountingManager"
[38]: https://github.com/fabriziobertoglio1987/react-native/commit/733f2285067de401b925195266f4cec84c3f7fef "Diff C++ props for Android consumption"
[39]: https://github.com/fabriziobertoglio1987/react-native/commit/91b3f5d48aa1322046b8c5335f8e2e1a5e702b67 "This diff implement and integrates Mapbuffer into Fabric text measure system"

[40]: https://github.com/facebook/react-native/pull/29070 "[Android] Fix letters duplication when using autoCapitalize https://github.com/facebook/react-native/issues/29070"

[50]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12  "Notes from work on iOS/Android: Text input error for screenreaders https://github.com/facebook/react-native/issues/12"
[51]: https://github.com/facebook/react-native/issues/30848 "iOS/Android: Text input error for screenreaders https://github.com/facebook/react-native/issues/30848"
[52]: https://github.com/facebook/react-native/issues/30859 "Android: Error state change (text inputs) https://github.com/facebook/react-native/issues/30859"

[61]: https://github.com/facebook/react-native/pull/33468/commits/eb33c933c8bcb9a8421a6acdb7a51f261121be45 "fix annoucement delayed to next character"

[70]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1116966512 "iOS - Paper renderer does not update the accessibilityValue"
[71]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1124631221 "Test Cases of the functionality (Fabric) after removing changes to .cpp libs"
[72]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1124892802 "Test Cases of the functionality (Paper) after removing changes to .cpp libs"
[73]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1132830758 "iOS - announcing error onChangeText and screenreader focus"
[74]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1150657065 "iOS - The screenreader announces the TextInput value after the errorMessage is cleared"
[75]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1152285978 "iOS - Exception thrown while executing UI block: - [RCTTextView setOnAccessibiltyAction:]: unrecognized selector sent to instance (Paper) (main branch)"
[76]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158790381 "iOS - announce lastChar (not entire text) onChangeText and avoid multiple announcements (Fabric)"
[77]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158794863 "iOS - announces or does not announce the accessibilityError through Button onPress (not onChangeText) (Fabric)"
[78]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158797801 "iOS - the error is announced with accessibilityInvalid true and does not clear after typing text (onChangeText) (Fabric)"
[79]: https://github.com/facebook/react-native/issues/30848#issuecomment-1162799299 "iOS - Exception thrown while executing UI block: - RCTUITextView setAccessibilityErrorMessage:]: unrecognized selector sent to instance (iOS - Paper on main branch)"

[80]: https://github.com/fabriziobertoglio1987/react-native/commit/e13b9c6e49480e8262df06b7c1e99caab74e801f "RCTTextField was spliited into two classes"
[81]: https://github.com/fabriziobertoglio1987/react-native/commit/ee9697e5155aa972564d5aac90ceeb9db100750d "Introducing RCTBackedTextInputDelegate"
[82]: https://github.com/fabriziobertoglio1987/react-native/commit/2dd2529b3ab3ace39136a6e24c09f80ae421a17e "Add option to hide context menu for TextInput"
[83]: https://github.com/fabriziobertoglio1987/react-native/blob/343eea1e3150cf54d6f7727cd01d13eb7247c7f7/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm#L48-L72 "RCTParagraphComponentAccessibilityProvider accessibilityElements"
[84]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L613 "RCTTextInputComponentView method _setAttributedString"
[85]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L146 "RCTTextInputComponentView method updateProps"
[86]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/Libraries/Text/TextInput/RCTBaseTextInputView.m#L150 "RCTBaseTextInputView setAttributedText"
[87]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165395361 "iOS - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event"
[88]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165398153 "Android - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event"
[89]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165413245 "iOS - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event (Fabric)"

[100]: https://github.com/fabriziobertoglio1987/react-native/commit/110b191b14e3cb692bb6a33f0f129b4f0215f9a6 "Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism"
[101]: https://github.com/fabriziobertoglio1987/react-native/commit/22b6e1c8ec0e69700e9142cf5c9c1ab1e6a84b78 "In this diff I'm shipping and deleting mapBufferSerialization for Text measurement"

Reviewed By: blavalla

Differential Revision: D38410635

Pulled By: lunaleaps

fbshipit-source-id: cd80e9a1be8f5ca017c979d7907974cf72ca4777
2023-02-28 16:05:57 -08:00
Nicola Corti 4b8b9cc838 AGP to 7.4.2
Summary:
This is just a minor bump before 0.72 and it brings AGP up to date
with the latest stable.

allow-large-files

Changelog:
[Internal] [Changed] - AGP to 7.4.2

Reviewed By: cipolleschi

Differential Revision: D43659180

fbshipit-source-id: d57ea8fb6ae902412b542e0125d3b15168d0e123
2023-02-28 08:39:21 -08:00
Birkir Gudjonsson c18566ffdb Appearance.setColorScheme support (revisited) (#36122)
Summary:
Both Android and iOS allow you to set application specific user interface style, which is useful for applications that support both light and dark mode.

With the newly added `Appearance.setColorScheme`, you can natively manage the application's user interface style rather than keeping that preference in JavaScript. The benefit is that native dialogs like alert, keyboard, action sheets and more will also be affected by this change.

Implemented using Android X [AppCompatDelegate.setDefaultNightMode](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)) and iOS 13+ [overrideUserInterfaceStyle](https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle?language=objc)

```tsx
// Lets assume a given device is set to **dark** mode.

Appearance.getColorScheme(); // `dark`

// Set the app's user interface to `light`
Appearance.setColorScheme('light');

Appearance.getColorScheme(); // `light`

// Set the app's user interface to `unspecified`
Appearance.setColorScheme(null);

Appearance.getColorScheme() // `dark`
 ```

## Changelog

[GENERAL] [ADDED] - Added `setColorScheme` to `Appearance` module

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

Test Plan:
Added a RNTester for the feature in the Appearance section.

Three buttons for toggling all set of modes.

Reviewed By: lunaleaps

Differential Revision: D43331405

Pulled By: NickGerleman

fbshipit-source-id: 3b15f1ed0626d1ad7a8266ec026e903cd3ec46aa
2023-02-28 05:28:38 -08:00
Nicola Corti 81dd3afe0b Bump Gradle to 8.x (#36269)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36269

This bumps our project to build on Gradle 8.x
All the necessary issues have already been resolved so everything should be green.
Gradle version has been bumped also inside the template and RNGP.

Changelog:
[Android] [Changed] - Bump Gradle to 8.x

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D43534184

fbshipit-source-id: ca1fd6799ff6d776743de2b2d809fc54bc533440
2023-02-27 13:47:09 -08:00
Nicola Corti de4ed0ddfc Reduce breaking changes with DefaultReactActivityDelegate (#36310)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36310

As part of the preparation for 0.72, this reduces the amount of breaking changes we expose in the template for the user.
Specifically it re-introduces the 4 param ctor for `DefaultReactActivityDelegate` and marking it with Deprecated,
so the build log and the IDE will instruct the user to move away from it (if they forgot to follow the upgrade helper).

Changelog:
[Internal] [Changed] - Reduce breaking changes with DefaultReactActivityDelegate

Reviewed By: cipolleschi

Differential Revision: D43619184

fbshipit-source-id: a98f7c67201a2860e7c2221e646f45f1ebec4678
2023-02-27 09:26:58 -08:00
Ruslan Shestopalyuk b108cbbff8 Use emitDeviceEvent in core ReactAndroid code (#36280)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36280

[Changelog][Internal]

As a follow-up to adding `ReactContext.emitDeviceEvent` (D43534174 (https://github.com/facebook/react-native/commit/a8f0a4dc626508ba3f1e629df5f9a24e43b6e150)) this makes it used in the OSS part of RN.

Reviewed By: NickGerleman

Differential Revision: D43494167

fbshipit-source-id: c3d56bde53fb1ce1297a48597b97470ff10f4dc0
2023-02-27 07:34:15 -08:00
Ruslan Shestopalyuk a8f0a4dc62 Ability to directly emit device events on Android/Java side (#36279)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36279

[Changelog][Internal]

To have a symmetry with the [corresponding C++ API for TurboModules](https://www.internalfb.com/code/fbsource/[929870c905c8fe68cb330ce96bda7eb703bb6ae6]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h?lines=90), this adds a helper method `ReactContext.emitDeviceEvent`, which allows to send device events to JS (`RCTDeviceEventEmitter.emit`).

This also allows for less boilerplate code and better discoverability.

See the next diff in stack for the application.

## Changelog

[Android][Added] ReactContext now has a method emitDeviceEvent, which can be used to send device events to RCTDeviceEventEmitter on the JavaScript side

Reviewed By: NickGerleman

Differential Revision: D43534174

fbshipit-source-id: 229f45575bf0c505af4a3baa8f7337821c70cc1c
2023-02-27 03:34:50 -08:00
Nicola Corti e79500e6a7 Add TraceUpdateOverlayComponentDescriptor to CoreComponentsRegistry (#36282)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36282

RN Tester is currently red as `TraceUpdateOverlay` is not registered in the Fabric Core Component Registry.

Changelog:
[Internal] [Changed] - Add TraceUpdateOverlayComponentDescriptor to CoreComponentsRegistry

Reviewed By: cipolleschi

Differential Revision: D43567915

fbshipit-source-id: ceb4b9b674a969f260caf810eade30ae23ce2ce8
2023-02-24 05:02:32 -08:00
Riccardo Cipolleschi 25d10f564a Back out "Replace callback for lambdas"
Summary:
We don't support Lambda in OSS yet, Lambdas were introduced as root of a stack of diffs, so we need to revert the whole stack

## Changelog:
[internal] - revert changes that broke CircleCI

Reviewed By: GijsWeterings

Differential Revision: D43566129

fbshipit-source-id: feae3c3065ed83463c9d887d7ff488c29993e0ae
2023-02-24 03:03:52 -08:00
Riccardo Cipolleschi e36fe691a1 Back out "Fix logic of removal of TMs cache"
Summary:
We don't support Lambda in OSS yet, Lambdas were introduced as root of a stack of diffs, so we need to revert the whole stack

## Changelog:
[internal] - revert changes that broke CircleCI

Reviewed By: GijsWeterings

Differential Revision: D43566121

fbshipit-source-id: 5c4fe8272ca220d8914eb64b3ab395589c007198
2023-02-24 03:03:52 -08:00
Riccardo Cipolleschi e969079216 Back out "Fix lints warnings in RN Android"
Summary:
We don't support Lambda in OSS yet, Lambdas were introduced as root of a stack of diffs, so we need to revert the whole stack

## Changelog:
[internal] - revert changes that broke CircleCI

Reviewed By: GijsWeterings

Differential Revision: D43566086

fbshipit-source-id: 95b8ed404edd6f711fbbb5ae3913010c653a2c28
2023-02-24 03:03:52 -08:00
David Vacca c1304d938d Fix lints warnings in RN Android
Summary:
Fix lints warnings in RN Android

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D43544495

fbshipit-source-id: 046cf00a99a443a2a515540e0029a19997247eb6
2023-02-23 19:04:03 -08:00
David Vacca 64835590ca Fix logic of removal of TMs cache
Summary:
While looking into  android code i noticed a bug removing the incorrect key from a map.

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D43544499

fbshipit-source-id: 15224e90cc46af358fb822e85accfae9aa9f7d11
2023-02-23 19:04:03 -08:00
David Vacca 32b8b49be4 Replace callback for lambdas
Summary:
We can now use Java 8, this diff i'm replacing old callbacks by lambdas

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D43544498

fbshipit-source-id: 4c5ab8473b3d9d512853c02e81652fdce1838a48
2023-02-23 19:04:03 -08:00
Genki Kondo 9718c17da6 Fix EventAnimationDriverMatchSpec to match non-bubbling pointer events
Summary:
Changelog:
[Android][Internal] - Fix EventAnimationDriverMatchSpec to match against the view that generated the event for non-bubbling pointer events. This should have no effect if you are not using PointerEvents

Reviewed By: mdvacca

Differential Revision: D43413771

fbshipit-source-id: 31ac751b3d3d55eb44d3a9ab54e5fb387dcaa9b3
2023-02-22 16:57:58 -08:00
Nicola Corti a18bad4555 Re-add repositories{} block to allow for build-from-source
Summary:
I've just tested the nightly and the build from source is broken as the `repositories{}` block is missing.

Normally RNGP will take care of setting repositories for everyone, but this is triggered by the app-module.
When building from source, the app module of the user is isolated from the included build of React Native,
therefore the repositories{} definitions are not passed over.

Without this, the build fails with:
```
Cannot resolve external dependency ... because no repositories are defined
```

Changelog:
[Internal] [Changed] - Re-add repositories{} block to allow for build-from-source

Reviewed By: cipolleschi

Differential Revision: D43501011

fbshipit-source-id: b41c56c62839163ad210e7e303940dec0a9001da
2023-02-22 09:18:32 -08:00
Pieter De Baets 31a8e92cad Fix TextView alignment being reset on state updates
Summary: Changelog: [Android][Fixed] Resolved bug with Text components in new arch losing text alignment state.

Reviewed By: mdvacca

Differential Revision: D34108943

fbshipit-source-id: 3992e9406345be919b5e3595fc1f9e61cf67a699
2023-02-22 03:17:24 -08:00
Genki Kondo bc749a1623 Early exit during matching in EventAnimationDriverMatchSpec
Summary:
Simple optimization to exit before iterating through the hit path if the event name doesn't match.

Changelog:
[Android][Internal] - Optimization for natively-driven Animated PointerEvents to early exit during matching in EventAnimationDriverMatchSpec. This should have no effect if you are not using PointerEvents

Reviewed By: lunaleaps

Differential Revision: D43400457

fbshipit-source-id: fe8d811d371c78622cd4f3f9cd469cff9ccce585
2023-02-21 16:17:30 -08:00
Pieter De Baets 753bccc47a Forward dynamic values where possibe
Summary: Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D42961391

fbshipit-source-id: d07f8627a59d43e762bddb0641b3961806e9a7ec
2023-02-21 05:46:37 -08:00
Pieter De Baets 726a40ce28 Fix catalyst instance lifecycle warnings on shutdown
Summary:
Callling `getReactApplicationContextIfActiveOrWarn` from `invalidate` will always warn because the context is deactivated, which is preventing us from cleaning up these listeners.

Changelog: [Internal]

Reviewed By: jehartzog

Differential Revision: D43352929

fbshipit-source-id: f29564a290a6c93b2304865d445829f5e486d84f
2023-02-21 02:46:18 -08:00
Ruslan Shestopalyuk b77841d991 Improvements in ReadableNativeMap locking mechanism (a follow up to D43398416)
Summary:
[Changelog][Internal]

A follow-up, based on javache comments on D43398416 (https://github.com/facebook/react-native/commit/9aac13d4dc95925b57f03e7964fc7add6834e518) (post-land) - just some minor potential improvements for locking efficiency.

Reviewed By: javache

Differential Revision: D43438414

fbshipit-source-id: 0cf807a045a1f132d5481d3f6115a97869e93d65
2023-02-20 09:57:32 -08:00
Ruslan Shestopalyuk 9aac13d4dc Fix race condition in ReadableNativeMap (#36201)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36201

[Changelog][Internal]

Guard call to the C++ ReadableNAtiveMap.importValues with a lock.

Note that all the occurrences in this class (together with importTypes) already were protected by a lock, except of this one, which with the very high chance caused crashes in T145271136.

My corresponding comment from the task,  for justification:
> If callstack to be trusted, the crash happens on the C++ side, in ReadableNativeMap::importValues().
It throws ArrayIndexOutOfBoundsException, which, looking at the code, seems to be only possible due to a corrupted data or race conditions.

> Now, looking at the Java side of ReadableNativeMap, and the particular call site... it's very dodgy, since all other occurrences of calling to native importTypes/importValues are guarded by locks, but the one crashing isn't.

NOTE: A couple of `importKeys()` instances appears to suffer from the same problem as well.

Reviewed By: javache

Differential Revision: D43398416

fbshipit-source-id: 0402de5dc723a2fba7d0247c8ad4aeff150d8340
2023-02-17 15:19:44 -08:00
Ana Margarida Silva 1d51032278 fix: border rendering problem in Android (#36129)
Summary:
Fixes https://github.com/facebook/react-native/issues/36036

The problem was in `ReactViewBackgroundDrawable.java` that was not accounting for adjacent borders that add width set to 0.

## Changelog

[Android] [Fixed] - Fix border rendering issue when bottom borders has no width

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

Test Plan:
| Previously | Now with the fix  |
| --------------- | --------------- |
| <img width="417" alt="image" src="https://user-images.githubusercontent.com/25725586/218149384-00e2145c-3c84-4590-87be-3258574489e5.png"> | <img width="414" alt="image" src="https://user-images.githubusercontent.com/25725586/218148215-a8d37158-0feb-47ae-874b-cba2f422d792.png">  |

Reviewed By: cipolleschi

Differential Revision: D43303228

Pulled By: javache

fbshipit-source-id: cf9d30fe12a5740d9ee8974a66904fd0850e7606
2023-02-16 08:09:22 -08:00
Samuel Susla e665a0f995 Use std::shared_mutex instead of folly::shared_mutex
Summary:
changelog: [internal]

C++17 has implementation of shared_mutex in standard library. Let's use it instead of folly.

Reviewed By: cipolleschi

Differential Revision: D43275493

fbshipit-source-id: d766251226aa230110011aca94b4e697fe0d31a1
2023-02-16 06:25:26 -08:00
Nicola Corti 8486e191a1 Address New Architecture performance regressions by properly setting NDEBUG (#36172)
Summary:
It looks like we're not properly setting `NDEBUG` for "non debug" builds with CMake (the name is terrible but that's what Buck uses originally).

This configures `NDEBUG` correctly so that is set only for release variants, so that also `REACT_NATIVE_DEBUG` is set correctly (and we don't fire asserts on release builds).
This should address several performance regression we saw for New Architecture on some release scenarios (credits to sammy-SC for spotting it).

## Changelog

[ANDROID] [FIXED] - Address New Architecture performance regressions by properly setting NDEBUG

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

Test Plan:
I've tested this by checking the ninja output for the debug/release builds for the `YogaLayoutableShadowNode.cpp` file

### Debug (does not contain `-DNDEBUG`)

```
build ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o: CXX_COMPILER__rrc_view_Debug /Users/ncor/git/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp || cmake_object_order_depends_target_rrc_view
  DEFINES = -Drrc_view_EXPORTS
  DEP_FILE = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o.d
  FLAGS = -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -g  -fno-limit-debug-info -fPIC -Wall -Werror -std=c++17 -fexceptions -frtti -Wpedantic -Wno-gnu-zero-variadic-macro-arguments -DLOG_TAG=\"Fabric\" -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1
  INCLUDES = -I/Users/ncor/git/react-native/ReactCommon -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/folly/. -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/glog/exported -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/double-conversion/. -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_76_0 -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/fmt/include -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/fbgloginit/. -I/Users/ncor/git/react-native/ReactCommon/jsi -I/Users/ncor/git/react-native/ReactCommon/logger/. -I/Users/ncor/git/react-native/ReactCommon/react/renderer/graphics/platform/android -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/fb/include -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni -I/Users/ncor/git/react-native/ReactCommon/yoga/. -isystem /Users/ncor/.gradle/caches/transforms-3/ebdfaf25aad9044f80de924d25488688/transformed/fbjni-0.3.0/prefab/modules/fbjni/include
  OBJECT_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir
  OBJECT_FILE_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir
  TARGET_COMPILE_PDB = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/
  TARGET_PDB = /Users/ncor/git/react-native/ReactAndroid/build/intermediates/cxx/Debug/193k1y15/obj/arm64-v8a/librrc_view.pdb
```

### Release (does contain `-DNDEBUG`)

```
build ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o: CXX_COMPILER__rrc_view_RelWithDebInfo /Users/ncor/git/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp || cmake_object_order_depends_target_rrc_view
  DEFINES = -Drrc_view_EXPORTS
  DEP_FILE = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o.d
  FLAGS = -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -O2 -g -DNDEBUG -fPIC -Wall -Werror -std=c++17 -fexceptions -frtti -Wpedantic -Wno-gnu-zero-variadic-macro-arguments -DLOG_TAG=\"Fabric\" -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1
  INCLUDES = -I/Users/ncor/git/react-native/ReactCommon -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/folly/. -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/glog/exported -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/double-conversion/. -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_76_0 -I/Users/ncor/git/react-native/ReactAndroid/build/third-party-ndk/fmt/include -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/fbgloginit/. -I/Users/ncor/git/react-native/ReactCommon/jsi -I/Users/ncor/git/react-native/ReactCommon/logger/. -I/Users/ncor/git/react-native/ReactCommon/react/renderer/graphics/platform/android -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/fb/include -I/Users/ncor/git/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni -I/Users/ncor/git/react-native/ReactCommon/yoga/. -isystem /Users/ncor/.gradle/caches/transforms-3/ebdfaf25aad9044f80de924d25488688/transformed/fbjni-0.3.0/prefab/modules/fbjni/include
  OBJECT_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir
  OBJECT_FILE_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir
  TARGET_COMPILE_PDB = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/
  TARGET_PDB = /Users/ncor/git/react-native/ReactAndroid/build/intermediates/cxx/RelWithDebInfo/53pv2v65/obj/arm64-v8a/librrc_view.pdb
```

Reviewed By: sammy-SC, cipolleschi

Differential Revision: D43344120

Pulled By: cortinico

fbshipit-source-id: e0567aec2742c5dab2d008cdcf198f34d5626b65
2023-02-16 06:03:01 -08:00
Nicola Corti 40c687c132 Allow for Android offline mirrors to be executed on developer's laptops
Summary:
Before this change, the only way to update the offline mirror was to run it on a devmachine
(OD won't work either due to network restriction).

Developer's laptop also won't work as they would download AAPT2 for MacOS.
In the offline mirror instead we need AAPT2 for Linux as that's Sandcastle runner type.

This relaxes this requirement so the next time a developer has to update the offline
mirror they will see the message on the diff with the command to execute, and they should
be able to run the command locally (or on their devbox).

Changelog:
[Internal] [Changed] - Allow for Android offline mirrors to be executed on developer's laptops

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D43344651

fbshipit-source-id: 3e91adb2db45cf94d3f947aaab501d98580dc43d
2023-02-16 04:38:36 -08:00
Felipe Perez 8232c47dcf Make JSONArguments accept Long values
Summary:
This util class was introduced in D42978852 (https://github.com/facebook/react-native/commit/611f9c615ebad7d53c1eb1274fe82e36d915165e), but the Long type was not ported over. Not sure if this was intentional or not, but this is used from return values from DeviceConfig, where number values are encoded as Long types.

Changelog:
[Internal] - internal

Differential Revision: D43323851

fbshipit-source-id: 6a8a27b75b1738f2f87dd56ee814316af323c258
2023-02-15 14:04:52 -08:00
Moti Zilberman e328fc2e24 Reduce use of Java exceptions in prop parsing (#36160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36160

Changelog:
[Android][Fixed] - Invalid prop values no longer trigger Java exceptions in the legacy renderer

## Context

We are changing React Native to behave more like a browser in the sense that **bad style values are not runtime errors**. (See e.g. D43159284 (https://github.com/facebook/react-native/commit/d6e9891577c81503407adaa85db8f5bf97557db0), D43184380.) The recommended way for developers to ensure they are passing correct style values is to use a typechecker (TypeScript or Flow) in conjunction with E2E tests and manual spot checks.

## This diff

This change is similar to D43184380, but here we target the legacy renderer on Android by (1) replacing exceptions with logging calls, (2) adding fallback values (equivalent to resetting the respective props to `null`) where needed, and (3) replacing `null` checks in `ReactProp` converters with `instanceof` checks.

Leaving the logging call sites in place (as opposed to deleting them) will be helpful if we decide that we want to repurpose these checks for a new, more visible diagnostic (though we would likely only build such a diagnostic in Fabric at this point).

Reviewed By: javache

Differential Revision: D43274525

fbshipit-source-id: 9d1e7ca3b6299dd827e8667e3d542433ec896c0e
2023-02-15 13:06:36 -08:00
Tomek Zawadzki 3418f65d88 Expose rrc_root via prefab (#36166)
Summary:
The `rrc_root` was not exposed via prefab. I'm adding it to make possible for Reanimated to integrate on top of React Native via prefab. Based on https://github.com/facebook/react-native/issues/35643.

## Changelog

[ANDROID] [CHANGED] - Expose `rrc_root` via prefab.

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

Reviewed By: cipolleschi

Differential Revision: D43304302

Pulled By: cortinico

fbshipit-source-id: 1c4a7013a33b48a8a7a445a78430630542420f4d
2023-02-15 06:04:52 -08:00
Ramanpreet Nara 11570e71a2 Deprecate LazyReactPackage.getReactModuleInfoProviderViaReflection
Summary:
There are two different ways of getting the ReactModuleInfoProvider from LazyReactPackage:
1. static LazyReactPackage.getReactModuleInfoProviderViaReflection(LazyReactPackage)
2. LazyReactPackage.getReactModuleInfoProvider()

The first way calls into codegen that only works within Meta's infra. This code-path is *now* dead. Therefore, this diff deprecates the first path, to make LazyReactPackage less confusing.

This diff simplifies the implementation to return an empty ReactModuleInfoProvider for the v0.72 cut.

In the v0.73 cut, we'll just outright delete this method.

Changelog: [Android][Changed] - Deprecate LazyReactPackage.getReactModuleInfoProviderViaReflection()

Reviewed By: sshic

Differential Revision: D43066800

fbshipit-source-id: 2145c3265ff2bd24e6828b193577ba1f500bce49
2023-02-14 14:31:52 -08:00
Xin Chen 611f9c615e Create util class for parsing JSONObject and JSONArray to ReadableMap and ReadableArray
Summary:
This diff pays the duty in T126215968 where we should move the util methods to a shareable place. ~~I cannot find a good util namespace so I created on under `com.facebook.react.panelapp`.~~ This lives under `com.facebook.react.bridge` next to the `Arguments` class.

- Create ~~`ReadableDataParser.java`~~ `JSONArguments.java`
- Reuse in multiple places within `react-panellib`

Changelog:
[Internal] - Code refactor on JSON and ReadableMap conversion

Reviewed By: javache

Differential Revision: D42978852

fbshipit-source-id: e00a5c4cefcf6114d9a5d947cb00e3ff7f0dccaa
2023-02-14 13:41:32 -08:00
Xin Chen 6ac88a4378 Add TraceUpdateOverlay native component to render highlights on trace updates
Summary:
This diff adds `TraceUpdateOverlay` native component to render highlights when trace update is detected from React JS. This allows a highlight border to be rendered outside of the component with re-renders.

- Created `TraceUpdateOverlay` native component and added to the `DebugCorePackage`
- Added to C++ registry so it's compatible with Fabric
- Added to `AppContainer` for all RN apps when global devtools hook is available

Changelog:
[Android][Internal] - Add trace update overlay to show re-render highlights

Reviewed By: javache

Differential Revision: D42831719

fbshipit-source-id: 30c2e24859a316c27700270087a0d7779d7ad8ed
2023-02-13 21:55:33 -08:00
Vincent Riemer bf3656b758 - Ensure move tracking is applied to pressed moves
Summary: Changelog: [Internal] - Ensure pointer move tracking is applied to movement while the pointer is pressed

Reviewed By: javache

Differential Revision: D42977052

fbshipit-source-id: 2d48c35a908449d0b2338c33273fb75a430bc393
2023-02-13 14:52:38 -08:00
aleqsio f7e35d4ef7 Fix invalid context cast in ReactRootView (#36121)
Summary:
Hi 👋

I'm one of the  Expo contributors. When upgrading the Stripe dependency in Expo for SDK48 release on Android, we noticed the following error:
```java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity```

With Kudo we narrowed it down to an underlying issue in the following cast in `ReactRootView` done during checking for keyboard events:
```((Activity) getContext())```

The `getContext()` is actually a `ContextThemeWrapper` for `ExperienceActivity`, so we should not cast it to an `Activity` directly - instead, we unwrap it using `getBaseContext()`.

Implementing the following fix into the Expo fork fixed the crash for us:
https://github.com/expo/react-native/commit/0e2c9cada120a3709e8285ab4bcdaa1c5c446732

## Changelog

[ANDROID] [FIXED] - Fixed crash occurring in certain native views when handling keyboard events.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan:
Tested manually by comparing two builds before and after this change. The main branch build crashes when the [Stripe 0.23.1](https://github.com/stripe/stripe-react-native) Card Element from the example app is mounted on screen. Applying the change fixed the issue.

Happy to make a more isolated reproduction if necessary.

 ---
Full stack trace:
```
         AndroidRuntime  D  Shutting down VM
                         E  FATAL EXCEPTION: main
                         E  Process: host.exp.exponent, PID: 8849
                         E  java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
                         E      at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.checkForKeyboardEvents(ReactRootView.java:937)
                         E      at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.onGlobalLayout(ReactRootView.java:913)
                         E      at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:1061)
                         E      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3352)
                         E      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2286)
                         E      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8948)
                         E      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
                         E      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
                         E      at android.view.Choreographer.doCallbacks(Choreographer.java:899)
                         E      at android.view.Choreographer.doFrame(Choreographer.java:832)
                         E      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
                         E      at android.os.Handler.handleCallback(Handler.java:942)
                         E      at android.os.Handler.dispatchMessage(Handler.java:99)
                         E      at android.os.Looper.loopOnce(Looper.java:201)
                         E      at android.os.Looper.loop(Looper.java:288)
                         E      at android.app.ActivityThread.main(ActivityThread.java:7898)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
```

Reviewed By: cortinico

Differential Revision: D43186530

Pulled By: javache

fbshipit-source-id: 2143495f6b0c71f342eba6d5abb2bfa4a529fbdd
2023-02-13 11:55:05 -08:00
Nicola Corti e168db4c3b Add missing retention policy on EventCategoryDef annotation
Summary:
This annotation is missing it's retention policy which should be `SOURCE` as it's an IntDef and not used at runtime.

Changelog:
[Internal] [Changed] - Add missing retention policy on EventCategoryDef annotation

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

Reviewed By: cipolleschi

Differential Revision: D43187398

fbshipit-source-id: d00bc3a5cf74d2eb983fa7369905e2260db80142
2023-02-13 07:37:04 -08:00
Nicola Corti 7f20deb428 Use namespace for ReactAndroid and hermes-engine
Summary:
Our first party modules are still using `namespace`. This cleans this up.
The Manifest file for ReactAndroid is also not needed anymore. The one
from hermes-engine can also be removed from facebook/hermes in a separate diff.

Changelog:
[Internal] [Changed] - Use namespace for ReactAndroid and hermes-engine

Reviewed By: cipolleschi

Differential Revision: D43198514

fbshipit-source-id: d988cfa81ecc4484b6b2add4ae2c1d9376febc3e
2023-02-13 05:24:00 -08:00