Commit Graph

38536 Commits

Author SHA1 Message Date
Vincent Riemer 6172988f45 Add dispatchEvent API to EventEmitter that accepts an EventPayload directly (and use it for Pointer Events) (#38301)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38301

Changelog: [Internal] - Add dispatchEvent API to EventEmitter that accepts an EventPayload directly

This diff adds a deeper overload of dispatchEvent to EventEmitter which accepts a caller-provided EventPayload subclass, and modifies TouchEventEmitter's dispatchPointerEvent method to use it so that the typed PointerEvent is actually sent through the event pipeline.

Reviewed By: NickGerleman

Differential Revision: D47351851

fbshipit-source-id: a6fdabbfc9b8287c564252f5cc7296fa75044a1e
2023-07-12 13:22:57 -07:00
Samuel Susla c3f07d85a9 Add option to enable setNativeProps in Fabric for animated components (#38317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38317

changelog: [internal]

Reviewed By: javache

Differential Revision: D47402598

fbshipit-source-id: cb780bde309d968c71677f9717b55485ae72540f
2023-07-12 13:22:20 -07:00
Ramanpreet Nara fb64a5ff75 Interop: Implement RCTBridgeProxy registerSegmentWithId (#38299)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38299

Bridgeless mode replaces RCTCxxBridge registerSegmentWithId with RCTHost registerSegmentWithId.

This diff implements RCTBridgeProxy registerSegmentWithId.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D47349027

fbshipit-source-id: b87c395f65ebc8db23ca8e614341227d96435ece
2023-07-12 12:12:39 -07:00
Samuel Susla 55628acbdc Remove debug only code (#38128)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38128

changelog: [internal]

This is debug code that should not have been committed. It is harmless but still should be removed.

Reviewed By: NickGerleman

Differential Revision: D47127817

fbshipit-source-id: 6a13cbf0bf678ef5b7c5e8148e28ce78fba7d6de
2023-07-12 10:13:19 -07:00
Nick Gerleman 777907ca1f C++ 17 style nested namespaces (#38304)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38304

X-link: https://github.com/facebook/yoga/pull/1326

For better readability

Reviewed By: christophpurrer

Differential Revision: D47384926

fbshipit-source-id: 2f60d50a185331b3624d45d1fc45f98d504b3034
2023-07-12 09:38:40 -07:00
Nick Gerleman 6d6fb09c5e Target C++ 17 (#38303)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38303

X-link: https://github.com/facebook/yoga/pull/1327

This bumps Yoga to C++ 17 for a few reasons:
1. New versions of C++ may introduce behavior changes (e.g. evaluation order) and deprecations. Keeping the version closer to the version of large users helps avoid that.
2. C++ 17 unblocks some new bits I have wanted to use at times, like `std::optional`, `std::variant`, `if constexpr`, `[[nodiscard]]`.
3. There are already changes in C++ 20 that would be directly useful to Yoga, like `std::bit_cast` to avoid `memcpy` style type punning.

There has been some contention around C++ versions before, but by the time the next stable version of Yoga is out, it will have been more than 6 years (~2 C++ versions) since a stable version of Clang/LLVM with C++ 17 support. I would not like to go back further than n-2.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D47383922

fbshipit-source-id: eb95d4853f2168b68d6df5fddb797236eac55870
2023-07-12 09:38:40 -07:00
Sunbreak faa85f84ce set NDEBUG properly (#38314)
Summary:
`CMAKE_BUILD_TYPE` is `RelWithDebInfo` while `./gradlew :package:react-native:ReactAndroid:bundleReleaseAar`

## Changelog:

[ANDROID] [FIXED] - Fix `CMAKE_BUILD_TYPE` match condition from https://github.com/facebook/react-native/issues/36172

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

Test Plan:
### Release (does contain two `-DNDEBUG`)

```
build ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o: CXX_COMPILER__rrc_view_RelWithDebInfo /Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/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 = -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -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 -DNDEBUG
  INCLUDES = -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/folly/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/glog/exported -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/double-conversion/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_76_0 -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/fmt/include -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/fbgloginit/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/jsi -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/logger/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/react/renderer/graphics/platform/android -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/yoga/yoga/.. -isystem /Users/sunbreak/.gradle/caches/transforms-3/a52d8ada161ee9f7b900e2f4d7543a45/transformed/fbjni-0.4.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 = /Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/intermediates/cxx/RelWithDebInfo/394f413f/obj/arm64-v8a/librrc_view.pdb
```

Reviewed By: sammy-SC

Differential Revision: D47399115

Pulled By: cortinico

fbshipit-source-id: 8fc7c32f61d1085e6f357beef91726899e0ed6cf
2023-07-12 06:58:41 -07:00
Matt Oakes 72abed2c96 Fix window.requestIdleCallback not firing on iOS (#29895)
Summary:
Fixes https://github.com/facebook/react-native/issues/28602

When creating a `RCTFrameUpdate`, ensure it is created with the correct unix timestamp in seconds. This is needed to match the `NSTimeInterval` type defined in the header.

Previously, it was using the `CADisplayLink`'s `timestamp` property, which is not an `NSTimeInterval` but is instead a `CFTimeInterval` (note the different class prefix). This is the host time converted to seconds, which is the number of seconds since the device was turned on and therefore not a unix timestamp as expected.

This was causing issues with the `window.requestIdleCallback` timers as the timer code was expecting this `timestamp` property to be a unix timestamp in seconds which was causing the calculations to be done incorrectly and for the callbacks to never be called. The code does this calculation is here:

https://github.com/facebook/react-native/blob/4d920fe7c991eaec61d229a71df30b0f6c446d38/React/CoreModules/RCTTiming.mm#L262

As one of these is a valid unix timestamp and the other is a much smaller number (number of seconds since device turn on), the `if` statement following this calculation never passes and the callbacks are never called.

This regression seems to have been introduced with this pull request: https://github.com/facebook/react-native/pull/26114

## Changelog

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

[iOS] [Fixed] - Fixed window.requestIdleCallback not firing on iOS

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

Test Plan: I have tested this by patching my React Native code and testing that idle callbacks are correctly called. There is a reproduction case of the issue in the linked issue.

Reviewed By: NickGerleman

Differential Revision: D47381404

Pulled By: sammy-SC

fbshipit-source-id: fd166741889b0084e1def8dedf6e4018adfd570f
2023-07-12 04:27:06 -07:00
Intl Scheduler 13a160eab6 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907916994239
Sandcastle Job Instance ID: 22517999126744070
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47391350

fbshipit-source-id: d063242b0a1102782df6ba3b465692073649b21e
2023-07-11 23:55:17 -07:00
Vincent Riemer 9ab27e8895 Make PointerEvent a subclass of EventPayload (#38279)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38279

Changelog: [Internal] - Make PointerEvent a subclass of EventPayload

This is another refactor diff in preparation of intercepting events in UIManagerBinding to accomplish the Pointer Capture APIs (and more) by making the PointerEvent struct implement EventPayload. Now that this struct will be passed to the event pipeline itself we'll be able to determine in UIManagerBinding that the event is a PointerEvent by dynamic casting and access the event's properties without converting to/from JSI values.

Reviewed By: NickGerleman, sammy-SC

Differential Revision: D47300801

fbshipit-source-id: 4d80378803af0c31dca068ef2b99e34fab426d84
2023-07-11 16:41:04 -07:00
Vincent Riemer ffc68ffa7e Refactor event pipeline to accept typed event payloads (#38276)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38276

Changelog: [Internal] Refactor Fabric event pipeline to accept typed event payloads

As a first step towards my project of managing the Pointer Capture API by intercepting events in UIManagerBinding I need infrastructure to be able to safely & efficently read the properties of the event payload which is what this diff lays the ground work of addressing.

Currently the events are passed from the EventEmitter all the way to UIManagerBinding with only a ValueFactory (std::function lambda) which is called to produce the jsi::Value. My diff introduces a new virtual base class, EventPayload, which provides the same functionality but in a member function, asJSIValue. To ease the transition to this new paradigm I also introduce the first concrete subclass of EventPayload: ValueFactoryEventPayload — which simply stores and calls a ValueFactory so that we can incrementally migrate to typed events (or frankly, continue to be used for events that we don't *need* to be typed, as the only real use-case in the beginning will be for Pointer Events).

This diff notably does not change any behavior and should behave the exact same way it did before — it is in later diffs where I will begin applying this to the pointer events.

Reviewed By: NickGerleman

Differential Revision: D47299631

fbshipit-source-id: d31d95a5fe09c3404800dd0da0322b198948a851
2023-07-11 16:41:04 -07:00
Christoph Purrer 856931b11b rn-tester > Use code-generated Turbo Module name constants (#38297)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38297

Continuation of https://github.com/facebook/react-native/pull/38295

Changelog:
[Internal] [Changed] - Use code-generated Turbo Module name constants

Reviewed By: shwanton

Differential Revision: D47376344

fbshipit-source-id: 62bd63b83d2aa47ef05ee7073e8c20bfdf192e44
2023-07-11 15:33:48 -07:00
Roy Berger f396067cca Add module name constant to class for downstream use (#38295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38295

Move constant to class instance so customers can use strongly typed name, feedback from D46159001

Changelog:
[Internal] [Changed] - Add module name constant to codegen'd class for downstream use

Reviewed By: christophpurrer

Differential Revision: D47095993

fbshipit-source-id: 741d0d837bf912d6b32e5f12c5df871563d46686
2023-07-11 13:03:17 -07:00
Nicola Corti 8e9062849e Re-alings soloader version to 0.10.5 (#38289)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38289

I'm just making sure all the dependencies use the same version fo SoLoader that React Native is using: 0.10.5
See https://github.com/facebook/react-native/blob/50f620a1ad8e925a46d2aa8e6439d5ce6f4f2ce4/packages/react-native/ReactAndroid/gradle.properties#L22

Changelog:
[Internal] [Changed] - Re-alings soloader version to 0.10.5

Reviewed By: javache, mdvacca

Differential Revision: D47331908

fbshipit-source-id: e4a5a11669193763371048343cd2f8283e9124e0
2023-07-11 12:25:57 -07:00
Ramanpreet Nara 99e332e5b2 Introduce jest-e2e test for TurboModule Interop (#38206)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38206

This test will ensure that the TurboModule interop layer works in Catalyst.

It will navigate to the sample legacy module screen, and ensure that all methods work.

Steps:
1. Open up Catalyst
2. Navigate to the Legacy Native Module example
3. Click "Run all tests"
4. Validate that all tests match expectations.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D46917689

fbshipit-source-id: 071f9324fa3719648c1a390bde4ba00a4e687e44
2023-07-11 11:42:43 -07:00
zerosrat 5ba8de05b5 fix(ios): set top of perf monitor to statusbar height (#38262)
Summary:
Update RCTPerfMonitor.mm

Change the top offset of perf monitor component. As it is overlapped by dynamic island of iPhone 14 Pro series.

Before:
<img width="437" alt="image" src="https://github.com/facebook/react-native/assets/8179987/3c993c1b-6370-4cee-b5b1-e50e3f191dac">

After:
<img width="437" alt="image" src="https://github.com/facebook/react-native/assets/8179987/8be83e73-36e7-4075-9b74-64829b242020">

## Changelog:

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

[iOS] [Fixed] - Change the top of perf monitor component.

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

Test Plan: noop

Reviewed By: javache

Differential Revision: D47325450

Pulled By: NickGerleman

fbshipit-source-id: 6108db752945712e6cb770f5dd49e71df87d3f52
2023-07-11 10:33:51 -07:00
Lorenzo Sciandra 6f853cc445 add 0.72.2 changelog (#38286)
Summary:
Adds changelog for new patch.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - add changelog entry for 0.72.2

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

Test Plan: N/A

Reviewed By: cortinico, GijsWeterings

Differential Revision: D47364735

Pulled By: rshest

fbshipit-source-id: 8c884915aedb13929949a1a8bd72c389aa83d102
2023-07-11 07:04:28 -07:00
Pieter De Baets 6c10b0143e Fix implementation of Element#reference (#38288)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38288

This wasn't compiling since we need to cast to the (unshared) base component type.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D47362923

fbshipit-source-id: 2116c16eb90ee9efbd9d0ec45655220c0f7fed9c
2023-07-11 06:51:12 -07:00
Rob Hogan 0f85be8f66 Sync RN-Metro Babel Flow lib defs (#38287)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38287

Enable automatic (within Meta) sync checks between these duplicated definitions across the RN and Metro repositories, by using a common naming convention.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D47361815

fbshipit-source-id: bb55e5a1c21bf44be9016150a56a9eaa3b33078b
2023-07-11 06:19:20 -07:00
Nicola Corti 823839bcc1 Fresco to 3.0.0 (#38275)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38275

This bumps the version of Fresco to the latest major.
I add to add a couple of changes:
1. Some of the infra has been moved to a different package called `middleware` which I had to add
2. Flipper Fresco plugin has changed ownership, so I had to use the new coordinates.

Changelog:
[Android] [Changed] - Fresco to 3.0.0

Reviewed By: mdvacca

Differential Revision: D47337443

fbshipit-source-id: 1df78e624bcbf0200145fbee5780e2a1697fcb16
2023-07-11 04:04:10 -07:00
Pieter De Baets 52698e758d Revert D47015785: Wrap NullPointerExceptions when thrown and throw new Error in dispatchViewManagerCommand for readability
Differential Revision:
D47015785

Original commit changeset: 33e0b8fbc7dc

Original Phabricator Diff: D47015785

fbshipit-source-id: 479aeb038635fbeccdea6fab252205d3d5a001b3
2023-07-11 01:34:42 -07:00
Tim Yung 3ff0160139 RN: Adopt Indexed Access Types in EventEmitter (#38243)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38243

Adopts [Indexed Access Types](https://flow.org/en/docs/types/indexed-access/) in `EventEmitter`.

Changelog:
[Internal]

Reviewed By: gkz, SamChou19815

Differential Revision: D47298095

fbshipit-source-id: bc8e2fe1292533dd11ada22f50aaea8621adcdca
2023-07-10 15:42:46 -07:00
Nicola Corti e6f77112a7 Gradle to 8.2.1 (#38271)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38271

This is our usual bump to the latest stable of Gradle

Changelog:
[Internal] [Changed] - Gradle to 8.2.1

Reviewed By: yungsters

Differential Revision: D47335295

fbshipit-source-id: 36bbc1aca19b3b37852e19d3a8536f1a6c4b736a
2023-07-10 15:16:10 -07:00
Lulu Wu 43f7781c87 Avoid duplicate destroy on same thread (#38233)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38233

When call ReactHost.destroy multiple times on same thread, the synchronization we have now can not protect us from concurrent issues such as ```ConcurrentModificationException```, to avoid this case this diff checks if ReactInstance has been reset, if so it means an early destroy has been called and we should not destroy again.

Changelog:
[Android][Changed] - Avoid duplicate destroy on same thread

Reviewed By: fkgozali

Differential Revision: D47276191

fbshipit-source-id: 2291b89cb980ca762abddb835e703abd095a93b3
2023-07-10 13:37:34 -07:00
David Vacca d491674201 Update oncall field (#38274)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38274

Update oncall field on all of the react native android BUCK files

The goal is to prevent lint warnings

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D47338271

fbshipit-source-id: 757a915458a2370dabe122fd3f4936409f8aef95
2023-07-10 13:23:54 -07:00
David Vacca 1e63d1939a Remove package comment from JSCExecutor (#38255)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38255

Remove package comment from JSCExecutor
This class was made public as part of D30346032, seems it's safe for it to be public

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D47309285

fbshipit-source-id: 061aeb3a803ded73cad7d45909ab22fe7489c811
2023-07-10 13:23:54 -07:00
David Vacca d37cdec070 Fix lint warn (#38252)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38252

Fix lint warn

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D47307051

fbshipit-source-id: b09bea3b598c5a5ac2595ccde5fc5756bb718eab
2023-07-10 13:23:54 -07:00
Rob Hogan 9022c59820 Update Yargs flow lib def to allow .fail(false) (#38273)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38273

Update Flow types for Yargs `.fail()` to match [Yargs docs](https://github.com/yargs/yargs/blob/v17.6.2/docs/api.md#failfn--boolean).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D47337206

fbshipit-source-id: 693bf8ba81a20e1860d6b271182e3c839ff6028b
2023-07-10 13:09:01 -07:00
Intl Scheduler 69e10a89c7 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907915988952
Sandcastle Job Instance ID: 36028798009950559
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47342077

fbshipit-source-id: d2dc674d5e29202b23e4c184a9f034cd2c2d7e13
2023-07-10 11:55:45 -07:00
Pranav Yadav 28dfdb22eb Auto close issue if version is too old (#38041)
Summary:
*Auto-close* an issue when the version of React Native specified is **TOO OLD**.
Applies `Type: Too Old Version` label and closes such issues using `actOnLabel` workflow.

## Changelog:

[GENERAL] [ADDED] - Auto close issue if version is too old.

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

Test Plan: - Should *auto-close* an issue with `Type: Too Old Version` label

Reviewed By: NickGerleman

Differential Revision: D47331471

Pulled By: cortinico

fbshipit-source-id: 516468299d6923ce72e073a3b7b8b8715d15d6e0
2023-07-10 08:17:16 -07:00
Harry Yu 0519c11acd Wrap NullPointerExceptions when thrown and throw new Error in dispatchViewManagerCommand for readability (#38060)
Summary:
### Motivation

I had a crash-causing error in our error reporting console (Bugsnag) that was extremely hard to debug due to the lack of specificity in the thrown error.

```
java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
        at com.facebook.react.bridge.ReadableNativeArray.getDouble(ReadableNativeArray.java:92)
        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:64)
        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:60)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:356)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
        at com.facebook.jni.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:214)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:919)
```

I noticed that `invoke` in `JavaMethodWrapper` tacks on the JS method name on other errors, so wanted to change this to handle NullPointerExceptions more gracefully too.

This helps make it easier to debug issues like https://github.com/facebook/react-native/issues/23126, https://github.com/facebook/react-native/issues/19413, https://github.com/facebook/react-native/issues/27633, https://github.com/facebook/react-native/issues/23378, https://github.com/facebook/react-native/issues/29250, https://github.com/facebook/react-native/issues/28262, https://github.com/facebook/react-native/issues/34001 and likely many more.

### After adding NullPointerException

Even after adding the NullPointerException, I got errors like this:

```
com.facebook.react.bridge.NativeArgumentsParseException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference (constructing arguments for UIManager.dispatchViewManagerCommand at argument index 0) with parameters [null, 4.0, []]
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
        at com.facebook.jni.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:1012)
```

This helped, but still didn't help me easily find which library calling `dispatchViewManagerCommand` was causing this.

## Changelog:

[ANDROID] [CHANGED] - Wrap NullPointerExceptions when thrown by native code called from JS for readability
[GENERAL] [CHANGED] - Throw Error in dispatchViewManagerCommand when non-numeric tag is passed for easier debugging

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

Test Plan:
Test change on our app via a beta release.

With these changes, we got better stacktraces like these:

### Java stacktrace

```
com.facebook.react.bridge.NativeArgumentsParseException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference (constructing arguments for UIManager.dispatchViewManagerCommand at argument index 0) with parameters [null, 4.0, []]
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
        at com.facebook.jni.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:1012)
```

### JS stacktrace (after dispatchViewManagerCommand change)

```
Error dispatchViewManagerCommand: found null reactTag with args []
    node_modules/react-native/Libraries/ReactNative/PaperUIManager.js:120:21 dispatchViewManagerCommand
    node_modules/react-native-maps/lib/MapMarker.js:68:67 _runCommand
    node_modules/react-native-maps/lib/MapMarker.js:60:24 redraw
    templates/Components/MapViewWithMarkers/PlaceMarker.tsx:88:32 anonymous
    (native) apply
    node_modules/react-native/Libraries/Core/Timers/JSTimers.js:213:22 anonymous
    node_modules/react-native/Libraries/Core/Timers/JSTimers.js:111:14 _callTimer
    node_modules/react-native/Libraries/Core/Timers/JSTimers.js:359:16 callTimers
    (native) apply
    node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:427:31 __callFunction
    node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:25 anonymous
    node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:10 __guard
    node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:16 callFunctionReturnFlushedQueue
```

Reviewed By: javache

Differential Revision: D47015785

Pulled By: cortinico

fbshipit-source-id: 33e0b8fbc7dc6a88d4c3383630126f99d2cf6098
2023-07-10 06:12:05 -07:00
Kun Wang 177d97d8ea For targeting SDK 34 - Added RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support in DevSupportManagerBase (#38256)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38256

Add RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support to DevSupportManagerBase for Android 14 change. See
https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported for details.

Without this fix, app crashes during launch because of :
```SecurityException: {package name here}: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts```

Changelog:
[Targeting SDK 34] Added RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support in DevSupportManagerBase

Reviewed By: javache

Differential Revision: D47313501

fbshipit-source-id: 12e8299559d08b4ff87b4bdabb0a29d27763c698
2023-07-10 05:53:21 -07:00
Alex Hunt dc6845739e Remove run Metro hook from Xcode build, remove launchPackager scripts (#38242)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38242

See proposal: https://github.com/react-native-community/discussions-and-proposals/discussions/681

**Removed script files**

I searched GitHub (and specifically `react-native-windows/macos`) to confirm these files are not referenced:

- `scripts/launchPackager.bat`
- `scripts/launchPackager.command`
- `scripts/.packager.env`

Interestingly, React Native CLI refers to a `.packager.env` at a different location (`node_modules/.bin/`), and includes modified copies of `launchPackager.command/bat`. This PR removes duplication with these.

Changelog: [iOS][Breaking] Metro will no longer be started when running builds via Xcode

Reviewed By: cortinico

Differential Revision: D47297469

fbshipit-source-id: 06c3602d58b21ed693c3daa763d99947a70bfc5a
2023-07-10 05:49:00 -07:00
Pieter De Baets 20dba39dab Rollout TurboModuleBinding::Prototype (#38220)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38220

We ran an experiment to test different implementations of TurboModules HostObjects, as the current one has various inefficiencies, such as re-creating HostFunctions on every property access. The strategy we found to be most efficient and flexible longer-term is to represent the TurboModule with a plain JavaScript object and use a HostObject as its prototype. Whenever a property is accessed through the prototype, we cache the property value on the plain object, so it can be efficiently resolved by the VM for future accesses.

Changelog: [General] TurboModules are now exposed to JS as the prototype of a plain JS object, so methods can be cached

Reviewed By: sammy-SC

Differential Revision: D47258286

fbshipit-source-id: 4562ac5316164daaf673e713b35cb31315ff9652
2023-07-10 04:44:05 -07:00
Intl Scheduler c82f2e9f68 translation auto-update for Apps/Wilde/scripts/intl-config.json on master
Summary:
Chronos Job Instance ID: 1125907915940452
Sandcastle Job Instance ID: 27021598752726192
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47331778

fbshipit-source-id: 31717b660c1188e5b722e87c1471b236f53c57d8
2023-07-10 04:16:15 -07:00
David Vacca 50f620a1ad Delete ArrayUtils from codebase (#38251)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38251

I'm deleting ArrayUtils from codebase, this file is not used neither internally or externally (as analyzed in github source)

I believe it's very safe to delete without following any deprecation process

changelog: [Android][Deleted] Delete ArrayUtils from codebase

Reviewed By: christophpurrer

Differential Revision: D47306287

fbshipit-source-id: 1f36ca46db107e21dc55191528cacf6f81cf63ed
2023-07-08 16:10:15 -07:00
David Vacca e58add29a0 Mark ReactJsExceptionHandler to require UnstableReactNativeAPI (#38250)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38250

This diff marks ReactJsExceptionHandler to require UnstableReactNativeAPI annotation

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D47304094

fbshipit-source-id: 93f39422b21925770b99fcf41e004b47d6649c14
2023-07-08 16:10:15 -07:00
David Vacca c9e448f132 Migrate ReactJsExceptionHandler to Kotlin (#38249)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38249

Quick migration of ReactJsExceptionHandler to Kotlin.

It will documented in the next diffs of the stack (might rename it as well)

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D47300786

fbshipit-source-id: ea15b4180c22f5759d327e43af1b7a5c077ea9f8
2023-07-08 16:10:15 -07:00
David Vacca 683e279dfe Move ReactJsExceptionHandler -> interfaces package (#38241)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38241

In this diff I'm moving the ReactJsExceptionHandler interface into the react.interfaces package.
This bring consistence with the rest of bridgeless APIs

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D47277572

fbshipit-source-id: ad17b19de3571df4ea1545f45d5998912deac072
2023-07-08 16:10:15 -07:00
David Vacca b3c369c35c Complete TaskInterface interface (#38232)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38232

In this diff I'm completing the TaskInterface interface with subset methods from Task that should be exposed

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D47267970

fbshipit-source-id: 8a51f94e3c42a1d396e002f75547665f320c3962
2023-07-08 16:10:15 -07:00
Intl Scheduler 612096fef5 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907914621957
Sandcastle Job Instance ID: 22517999124686611
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47317293

fbshipit-source-id: f2070919b53c047a088f0afbc6db48b19ef995cc
2023-07-08 14:27:34 -07:00
Intl Scheduler 1706066533 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907914134600
Sandcastle Job Instance ID: 31525198380675390
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47297526

fbshipit-source-id: 5b395d0a8135d55b0b3a8641b24fd716636e57a6
2023-07-07 10:12:23 -07:00
Alex Hunt a991ff3837 Create dev-middleware package (#38194)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38194

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

Inits the `react-native/dev-middleware` package. Contains an initial implementation of `/open-debugger`, migrated from https://github.com/react-native-community/cli/commit/2535dbe2346a390b2c5034acf0b348347fce0b73.

## Attribution

This implementation is greatly inspired by `expo/dev-server`: https://github.com/expo/expo/blob/1120c716f35cb28d88800e8f5d963d2b2ac94705/packages/%40expo/dev-server/src/JsInspector.ts#L18

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D46283818

fbshipit-source-id: 7b38ad2f6d7346366a7c599d16e289e04b7bd88d
2023-07-07 09:22:09 -07:00
Pieter De Baets 8431509407 Guard against stopped surface in FabricUIManager.getColor (#38239)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38239

In D46840717 I made SurfaceMountingManager reset its context on stop as the Context may be keeping various other objects alive and was causing memory leaks.

This does cause a race condition if JS is still rendering at this time, as it needs to access to context to support things like PlatformColor.

Changelog: [Android] Fix crash on teardown in new architecture

Reviewed By: rshest

Differential Revision: D47290581

fbshipit-source-id: ef83c1d110d1156e39f2491fb62c82ec41c3b8e1
2023-07-07 09:00:55 -07:00
Samuel Susla e075a3f424 Back out "Fix TextInput vertical alignment issue when using lineHeight prop on iOS (Paper - old arch)" (#38235)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38235

changelog: [internal]

Original commit changeset: faece0940b15

Original Phabricator Diff: D46086661

This PR broke 50 diffs. Let's back it out.

I will communicate this to the PR owner with an example of what went wrong.

This causes a slight difference in text render:

 {F1043017930}

Reviewed By: javache

Differential Revision: D47284841

fbshipit-source-id: 29d28f62d3997740b2186bd60b327a0d009c4a6b
2023-07-07 05:44:24 -07:00
Samuel Susla c9fee896a1 Remove feature flag disableTransactionCommit (#38234)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38234

changelog: [internal]

Fully roll out disableTransactionCommit.

Reviewed By: javache

Differential Revision: D47284803

fbshipit-source-id: a33555d0426c33c0a1538fc18b5d9580ba0dea95
2023-07-07 05:24:47 -07:00
Riccardo Cipolleschi 8d2eec367d Update when view are added to the ViewRegistry (#38223)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38223

Before this change, the InteropLayer was adding the view to the registry right before invoking a command and right after the command was invoked. This model was too strict as some view commands may have async behaviors that make the lookup in the registry fail.

After this change, we are going to register the view when it's created and we are going to remove it when the view is deallocated.

## Changelog:
[iOS][Changed] - Update logic to add and remove views in the view registry for the interop layer.

Reviewed By: sammy-SC

Differential Revision: D47262664

fbshipit-source-id: 503f4e29e03bfc7ad861c1502129822b383ffcc0
2023-07-07 03:46:53 -07:00
Kudo Chien 0ccbd65581 add InitializeCore in getModulesRunBeforeMainModule (#38207)
Summary:
the `IntializeCore` is critical to react-native for setup polyfills. without this, we would have some erros like undefined `global.performance`. since the effort is now proposing `react-native/metro-config` as universal metro-config, it is better to have the `IntializeCore` in it.

we ran into issues when using expo-cli in bare react-native projects. it happens when using [the default metro config](https://github.com/facebook/react-native/blob/5f84d7338f42fe9b1d5bf2a9b1c8321b59551f15/packages/react-native/template/metro.config.js) and starting metro server without the react-native-community-cli.

### Why the issue does not happen on `yarn react-native start`?

when using `yarn react-native start`, the react-native-community-cli will merge its internal metro-config with the `InitializeCore` ([https://github.com/facebook/react-native/issues/1](https://github.com/react-native-community/cli/blob/5d8a8478cd104adf4a4dd34c09c2e256325ae61d/packages/cli-plugin-metro/src/commands/start/runServer.ts#L56), [https://github.com/facebook/react-native/issues/2](https://github.com/react-native-community/cli/blob/e8e7402512da8c3fbbc58a195284ef0008c7491f/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#L51-L61)). that's why the issue doesn't happen on react-native-community-cli.

## Changelog:

[GENERAL][FIXED] - `global.performance` in undefined when starting metro from Expo CLI

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

Test Plan:
```sh
$ npx react-native init RN072 --version 0.72
$ cd RN072
$ yarn add expo
$ npx expo run:ios
# then it hits the exception because the global.performance is undefined.
```

Reviewed By: rshest

Differential Revision: D47257439

Pulled By: huntie

fbshipit-source-id: ae294e684047e503d674f0c72563b56d1803ba36
2023-07-07 02:20:16 -07:00
Intl Scheduler f071616994 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907913776822
Sandcastle Job Instance ID: 22517999123508136
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47283309

fbshipit-source-id: d5a4f1ad496852ba7a897cc32be02606625fe73b
2023-07-06 21:42:10 -07:00
Intl Scheduler 76e8353af2 translation auto-update for i18n/creatorstudio.config.json on master
Summary:
Chronos Job Instance ID: 1125907913776822
Sandcastle Job Instance ID: 22517999123508136
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D47283319

fbshipit-source-id: 88e6927fa7c83053a2ea7e298c1e6cee50d96554
2023-07-06 21:42:10 -07:00