Commit Graph

38536 Commits

Author SHA1 Message Date
Alex Hunt 87ff232a6b Exclude platform specific files from public-api-test (#45727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45727

All instances mirror types which are already defined in the platform-independent base module. See snapshot changes.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D60286148

fbshipit-source-id: 30665252ff5e449a2c10ff3a3e76d9337daecb80
2024-07-26 07:16:59 -07:00
Nicola Corti 6ced6fe1b5 Move react_codegen_* + react_nativemodules_* libraries to static linking (#45639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45639

There is a circular dependency between libreactnative.so and libreact_codegen_rncore.so which I'm breaking here.

Changelog:
[Internal] [Changed] - Move react_codegen_* + react_nativemodules_* libraries to static linking

Reviewed By: cipolleschi

Differential Revision: D55799200

fbshipit-source-id: 53f814636f016a8c93f40b0456686228dfb46888
2024-07-26 07:00:32 -07:00
Nicola Corti a9932f27a2 Move react_featureflags and react_render_consistency inside libreactnative.so (#45640)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45640

Other two libraries that don't need to be dynamic libraries but can just be exposed via libreactnative.so

Changelog:
[Internal] [Changed] -  Move react_featureflags and react_render_consistency inside libreactnative.so

Reviewed By: cipolleschi

Differential Revision: D55796945

fbshipit-source-id: be40b1523a560b2783fc7b6312326e20dc8cf595
2024-07-26 07:00:32 -07:00
Nicola Corti 52de8c70f2 Move several libs from default App CMake setup to static linking (#43909)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43909

As we're moving towards a single `libreactnative.so` file, we need to remove several of our prefab targets. Here I'm cleaning up those that are not having an OnLoad.cpp file which needs to be loaded from SoLoader.

This is breaking for libraries using native dependencies via Prefab (i.e. search for `ReactAndroid::` in CMakeLists.txt files for your project).

If so, the CMakeLists.txt files should be updated as follows:

```diff
- ReactAndroid::react_render_debug
+ ReactAndroid::reactnative
```

This applies to every prefab dependencies (the example is just for `react_render_debug`

Changelog:
[General] [Breaking] - Remove several libs from default App CMake setup

Reviewed By: cipolleschi

Differential Revision: D55751683

fbshipit-source-id: 3aca7897852b5f323d60ede3c5036cae2f81e6c3
2024-07-26 07:00:32 -07:00
Nicola Corti 68453a1f90 Create the libreactnative.so dependency (#43908)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43908

This creates a new dynamic library that we want to be the only .so that is loaded from apps/libraries.

Changelog:
[Internal] [Changed] - Create the libreactnative.so dependency

Reviewed By: cipolleschi

Differential Revision: D55751682

fbshipit-source-id: 50f4167dc2f9953a8673b28dba3357e19fe88d6b
2024-07-26 07:00:32 -07:00
Jakub Urban 9bddcdef85 chore: migrate assertions in all unit tests in PrepareBoostTaskTest from jUnit to AssertJ. (#45718)
Summary:
https://github.com/facebook/react-native/issues/45596

Migrated all the assertions to use `assertThat()` function from AssertJ.
Also updated the `prepareBoostTask_withMissingConfiguration_fails` test to use `assertThatThrownBy` to check if the tested task throws a given exception.

## Changelog:
Migrate tests to assertj in these files:

- `packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt`

[INTERNAL] [CHANGED] - Migrated PrepareBoostTaskTest from junit.Assert to assertj.core.api.Assertions.

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

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

Test Plan:
All tests pass when `./gradlew -p packages/gradle-plugin test` command is ran.

<img width="454" alt="image" src="https://github.com/user-attachments/assets/9e954f7b-2208-48a9-ae15-ab642252e6da">

Reviewed By: GijsWeterings

Differential Revision: D60284566

Pulled By: cortinico

fbshipit-source-id: 11af0a0ca574f935e6aab3a7855b5daaeab1a718
2024-07-26 05:45:26 -07:00
Henrique Cicero f4435115cc chore: Migrate FileUtilsTest.kt, NdkConfiguratorUtilsTest.kt and AgpConfiguratorUtilsTest.kt to AssertJ (#45665)
Summary:
Issue: [https://github.com/facebook/react-native/issues/45596](https://github.com/facebook/react-native/issues/45596)

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

[INTERNAL] [CHANGED] - Migrated to AssertJ within files FileUtilsTest.kt, NdkConfiguratorUtilsTest.kt and AgpConfiguratorUtilsTest.kt

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: GijsWeterings

Differential Revision: D60276163

Pulled By: cortinico

fbshipit-source-id: c730acafc37606f1db8d53a61fc9443d88bccdfc
2024-07-26 05:21:33 -07:00
Nicola Corti f9ebc1d9ed Convert com.facebook.annotationprocessor.common.ProcessorBase to Kotlin (#45595)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45595

Changelog: [Internal][Changed] com.facebook.annotationprocessor.common.ProcessorBase -> Kotlin

Reviewed By: tdn120

Differential Revision: D60110313

fbshipit-source-id: 42e51927bc3bd56699c79f2f51293ba68ad7df22
2024-07-26 04:51:58 -07:00
Ruslan Lesiutin b5a5e9d51c fix[HostTargetSessionObserverTest.cpp]: call unsubscribe to cleanup resource (#45701)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45701

# Changelog: [Internal]

One weird thing is that this test actually never runs for Android, so its only compiled. I am not sure why exactly this one produces an error during execution, given that the next test is almost identical.

Nothing valuable from logcat, just a `SIGSEGV`. Since its something with memory, I've tried calling `unsubscribe`, same as in the next test to free memory before the test tear down (which should not run, because this test doesn't run).

Reviewed By: dmytrorykun

Differential Revision: D60282464

fbshipit-source-id: 2c7760f02c1128083f28651fe8ecd0f3cee27715
2024-07-26 03:36:29 -07:00
Nicola Corti ac0c5fb8b5 Update ccache key to use github.ref (#45698)
Summary:
Update ccache key to use github.ref

## Changelog:

[INTERNAL] - Update ccache key to use github.ref

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

Test Plan: CI

Reviewed By: blakef

Differential Revision: D60277122

Pulled By: cortinico

fbshipit-source-id: 10437e56a398e817fb030d505fbdb6cf7c23031a
2024-07-26 03:02:27 -07:00
Ruslan Lesiutin 9c61d9a58a Use NativeDebuggerSessionObserver in LogBox (#45578)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45578

# Changelog: [Internal]

Use previously introduced native module for managing the presence of warning notifications in LogBox:
- Don't display warnings and Fusebox migration message if there is an active debugging session
- If the session has just been started, clear warnings to hide Fusebox migration message
- If there is no active debugging session (even if there were some at some point of Host lifetime), display Fusebox migration message

See demo in test plan.

Reviewed By: huntie

Differential Revision: D59975265

fbshipit-source-id: 87d91b4d7f3c825dc795ec1b5b3073f969bc7b60
2024-07-25 11:32:08 -07:00
Ruslan Lesiutin 6fde836103 Introduce NativeDebuggerSessionObserver module (#45577)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45577

# Changelog: [Internal]

This diff adds new native module, which can be used from JavaScript.

The API includes:
1. `hasActiveSession`: returns a boolean flag, which can be used for determining if 1 or more debugging sessions are active for current HostTarget.
2. `subscribe`: receives a callback, which will be executed once the debugging state changes. To be more precise, this will only be called when state is changing from no active sessions to 1 session or the other way around. Callback should expect to receive one boolean argument, which can be used for determining  if there is an active session.

Reviewed By: huntie

Differential Revision: D59975264

fbshipit-source-id: dd095954529f573f38e9fae1792465a59e639d23
2024-07-25 11:32:08 -07:00
Dmitry Rykun 8af5e893c8 Do not send state updates for loop animations (#45670)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45670

**Motivation**

There is a special [code path](https://github.com/facebook/react-native/blob/bb23026daf1a853f4482be46d6f242712a6b7330/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java#L98) for native driven looping animations that restarts the animation in native, never calling the "animation end" callback. This was designed for and works fine with the `Animated.loop(Animated.timing(...))` animations. Unfortunately, it doesn't work well with more complex animations.
Consider an `Animated.loop(Animated.sequence(Animated.timing(...)))` animation. It doesn't trigger this code path. Instead, its nested `Animated.timing` animations are continuously rescheduled from JS by the looping `Animated.sequence` as singular native driven animations. Each time they end, they fire their "animation end" callback.

This introduces a subtle breakage when those "animation end" callbacks trigger React to update its state. This in turn restarts the rendering. In case with long transitions such looping animations can restart the rendering multiple times. In worst cases it may render the app unresponsive.

**Solution**
We don't need to tell React to update its state when running looping animations. This diff introduces a mechanism, using which `Animated.loop` can tell its nested animations that they are in a loop, and and there's no need to send state updates when they finish. This is consistent with how `Animated.loop(Animated.timing(...))` behaves.

Changelog: [General][Breaking] - Looping animations will not send React state updates.

Facebook

This diff enables this new behaviour for IGVR and FBVR, it also set up the experiment for FBiOS and FB4a.

Reviewed By: javache

Differential Revision: D59970265

fbshipit-source-id: 4832ae05b82f6cc59f92f72305b68610fa422f0a
2024-07-25 10:31:10 -07:00
Pieter De Baets 71be9be939 Fix animation glitch with looping animations (#45638)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45638

When looping a frame-based animation, we want to make sure to use the latest frame from the easing curve, which may not necessarily match `mToValue`.

Changelog: [Internal]

Differential Revision: D60143746

fbshipit-source-id: 68fa5421a958acc8291f396bc9f263fa110fdc54
2024-07-25 10:24:32 -07:00
Håkon Knutzen 8204134024 Use std::atomic for eliminating races in RCTCxxBridge (#45558)
Summary:
As explained in https://github.com/facebook/react-native/issues/45280, `TSan` picks up data races related to concurrent read/write to fields in `RCTCxxBridge`. See this report for reference:
```
WARNING: ThreadSanitizer: data race (pid=19983)
  Write of size 1 at 0x00010af1dfd8 by thread T13:
    #0 -[RCTCxxBridge _flushPendingCalls] <null> (RNTesterUnitTests:arm64+0x42b484)
    https://github.com/facebook/react-native/issues/1 __53-[RCTCxxBridge executeSourceCode:withSourceURL:sync:]_block_invoke <null> (RNTesterUnitTests:arm64+0x426050)
    https://github.com/facebook/react-native/issues/2 decltype(std::declval<void () block_pointer __strong&>()()) std::__1::__invoke[abi:ue170006]<void () block_pointer __strong&>(&&, decltype(std::declval<void () block_pointer __strong&>()())&&...) <null> (RNTesterUnitTests:arm64+0x456298)
    https://github.com/facebook/react-native/issues/3 std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x455c6c)
    https://github.com/facebook/react-native/issues/4 std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x3ce2e4)
    https://github.com/facebook/react-native/issues/5 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x3cdfd0)
    https://github.com/facebook/react-native/issues/6 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x4af18c)
    https://github.com/facebook/react-native/issues/7 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x51595c)
    https://github.com/facebook/react-native/issues/8 facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1::operator()() const <null> (RNTesterUnitTests:arm64+0x529df0)
    https://github.com/facebook/react-native/issues/9 decltype(std::declval<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) <null> (RNTesterUnitTests:arm64+0x529b54)
    https://github.com/facebook/react-native/issues/10 void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) <null> (RNTesterUnitTests:arm64+0x529978)
    https://github.com/facebook/react-native/issues/11 std::__1::__function::__alloc_func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()[abi:ue170006]() <null> (RNTesterUnitTests:arm64+0x5298dc)
    https://github.com/facebook/react-native/issues/12 std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x524518)
    https://github.com/facebook/react-native/issues/13 std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x3ce2e4)
    https://github.com/facebook/react-native/issues/14 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x3cdfd0)
    https://github.com/facebook/react-native/issues/15 invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) <null> (RNTesterUnitTests:arm64+0x515384)
    https://github.com/facebook/react-native/issues/16 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ <null> (CoreFoundation:arm64+0x8dc0c)
    https://github.com/facebook/react-native/issues/17 __NSThread__start__ <null> (Foundation:arm64+0x645c60)

  Previous read of size 1 at 0x00010af1dfd8 by main thread:
    #0 -[RCTCxxBridge isLoading] <null> (RNTesterUnitTests:arm64+0x43236c)
    https://github.com/facebook/react-native/issues/1 -[RCTBridge isLoading] <null> (RNTesterUnitTests:arm64+0x3c0170)
    https://github.com/facebook/react-native/issues/2 -[RCTComponentPropsTests setUp] <null> (RNTesterUnitTests:arm64+0xe6f34)
    https://github.com/facebook/react-native/issues/3 __70-[XCTestCase _shouldContinueAfterPerformingSetUpSequenceWithSelector:]_block_invoke.134 <null> (XCTestCore:arm64+0x540d8)

  Location is heap block of size 384 at 0x00010af1de80 allocated by main thread:
    #0 calloc <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x4fc30)
    https://github.com/facebook/react-native/issues/1 _malloc_type_calloc_outlined <null> (libsystem_malloc.dylib:arm64+0xf488)
    https://github.com/facebook/react-native/issues/2 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc540)
    https://github.com/facebook/react-native/issues/3 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc124)
    https://github.com/facebook/react-native/issues/4 -[RCTComponentPropsTests setUp] <null> (RNTesterUnitTests:arm64+0xe6b3c)
    https://github.com/facebook/react-native/issues/5 __70-[XCTestCase _shouldContinueAfterPerformingSetUpSequenceWithSelector:]_block_invoke.134 <null> (XCTestCore:arm64+0x540d8)

  Thread T13 (tid=11290378, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x2bee4)
    https://github.com/facebook/react-native/issues/1 -[NSThread startAndReturnError:] <null> (Foundation:arm64+0x6458f0)
    https://github.com/facebook/react-native/issues/2 -[RCTBridge setUp] <null> (RNTesterUnitTests:arm64+0x3bf748)
    https://github.com/facebook/react-native/issues/3 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc540)
    https://github.com/facebook/react-native/issues/4 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc124)
    https://github.com/facebook/react-native/issues/5 -[RCTComponentPropsTests setUp] <null> (RNTesterUnitTests:arm64+0xe6b3c)
    https://github.com/facebook/react-native/issues/6 __70-[XCTestCase _shouldContinueAfterPerformingSetUpSequenceWithSelector:]_block_invoke.134 <null> (XCTestCore:arm64+0x540d8)
```

In order to fix the data races, `std::atomic` instead of primitive boolean types.

In order to reproduce my findings and verify fix:

* Clone this branch
* Run setup code as described in README
* Execute `git revert -n 11c09fdc7c442dd694909bebbbc8f21c3e69edf2`.
* Enable TSan for both RNTester and its test scheme.
* Enable Runtime issue breakpoint for TSan
* Run unit tests
* Observe the TSan breakpoint is hit (possibly other places in the codebase as well) when accessing `_loading`, `_moduleRegistryCreated`, and `_valid`.. Continue execution if other breakpoints are hit before this breakpoint.
* Execute git revert --abort
* Run the tests again and observe the TSan breakpoint does not hit said code again.

NB! While this will fix data races, it will not fix potential race conditions. I have not encountered bugs related to race conditions in `RCTCxxBridge`, but given the nature of how it is made use of concurrently, it is, in my opinion, plausible.

## Changelog:

[iOS][Fixed] Use std::atomic for eliminating races in RCTCxxBridge.

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

Test Plan: I believe there are existing Unit tests in place for verifying this fix.

Reviewed By: cipolleschi

Differential Revision: D60233758

Pulled By: dmytrorykun

fbshipit-source-id: 8aa124a0521ad43a5e17b42e0ce6d22ae6b4e667
2024-07-25 10:22:56 -07:00
Andrew Datsenko ffa68094ee Remove xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewHierarchyDumper.java (#45671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45671

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D60233475

fbshipit-source-id: 3c8e73296f9f46f98d18938d91ea7692d261a462
2024-07-25 10:20:02 -07:00
Thomas Nardone 193117c988 Nullsafe react/common/build (#45652)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45652

Results of arc nn on the module

Changelog: [Internal]

Reviewed By: arushikesarwani94

Differential Revision: D60188665

fbshipit-source-id: d5322ed15e55a367dc1854177cd533fed90226ee
2024-07-25 08:49:04 -07:00
Nicola Corti 3df2a86a24 Update ccache path (#45674)
Summary:
The correct path for ccache storage dir is actually `/github/home/.cache/ccache`

## Changelog:

[INTERNAL] - Update ccache path

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

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D60236560

Pulled By: cortinico

fbshipit-source-id: bbce9081e6647e660c3f80d61d791268de5b75d1
2024-07-25 08:43:19 -07:00
Nicola Corti eae2240bfc Adding ccache for Android builds (#45662)
Summary:
This adds `ccache` on the Android build to speedup the building process.

## Changelog:

[INTERNAL] - Adding ccache for Android builds

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

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D60229625

Pulled By: cortinico

fbshipit-source-id: bc7e416f4ed1b4932159feb672947669bfb498d7
2024-07-25 07:33:46 -07:00
Ruslan Lesiutin ea4005bef4 Update debugger-frontend from a56e5b7...7b143e5 (#45667)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45667

Changelog: [Internal] - Update `react-native/debugger-frontend` from a56e5b7...7b143e5

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/a56e5b7065c82b37ada788333c702bf5684c5839...7b143e5d05a102c8c9cc7e282bab7b0751f75d61).

Fixes reload via RDT panel for React-heavy apps.

Reviewed By: EdmondChuiHW, hezi

Differential Revision: D60233300

fbshipit-source-id: e188135e44b016b5b0df95e4ae96482eedc85eb4
2024-07-25 07:00:17 -07:00
Riccardo Cipolleschi 949c2bbe28 Revert Refator of RuntimeScheduler to unblock CI
Summary:
A previous commit (https://github.com/facebook/react-native/pull/45616) broke the ci in OSS.

It looks like that JSI is not working well in objective-c++ files when frameworks is enabled.

We need to look into it further but we need to have green CI

## Changelog:
[Internal] - Unblock CI

Reviewed By: blakef

Differential Revision: D60232011

fbshipit-source-id: b02ae163258786ce43cc11bc94420682661a6dd0
2024-07-25 05:21:26 -07:00
Nicola Corti 9d9a8d2df6 Remove unnecessary git config --global --add safe.directory (#45663)
Summary:
`git config --global --add safe.directory` is no longer necessary because is done inside the Docker container.

## Changelog:

[INTERNAL] - Remove unnecessary git config --global --add safe.directory

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

Test Plan: CI

Reviewed By: blakef

Differential Revision: D60229662

Pulled By: cortinico

fbshipit-source-id: aa817ff27adaab3e3105ab22af74a871b377295b
2024-07-25 04:13:16 -07:00
yakupozbaydar a9f5b3cacc chore: ☂️ Migrate UIManagerModuleConstantsHelperTest.kt to AssertJ (#45648)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[INTERNAL] [CHANGED] - Migrate UIManagerModuleConstantsHelperTest.kt to AssertJ testing library

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

Test Plan: Run ./gradlew -p packages/gradle-plugin test

Reviewed By: christophpurrer

Differential Revision: D60178766

Pulled By: cortinico

fbshipit-source-id: 480e2d9d4bab2ca4e46b05cda0b107ab9e024136
2024-07-25 02:25:49 -07:00
Jan Jaworski 6b9e96d63b chore: migrate tests to assertj (DialogModuleTest, ReactModuleInfoTest, FabricUIManagerTest.kt) (#45644)
Summary:
https://github.com/facebook/react-native/issues/45596

https://github.com/facebook/react-native/issues/45596#issuecomment-2247801893

## Changelog:

Migrate tests to assertj in these files:
- `packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.kt`
- `packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/model/ReactModuleInfoTest.kt`
- `packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/FabricUIManagerTest.kt`

Pick one each for the category and type tags:

[INTERNAL] [CHANGED] - Migrated `DialogModuleTest.kt`,`ReactModuleInfoTest.kt`, and `FabricUIManagerTest.kt`

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

Test Plan:
Run tests and verify if they pass

<img width="317" alt="image" src="https://github.com/user-attachments/assets/21a4feba-4221-4cdb-967e-e8d864ad6e93">

<img width="292" alt="image" src="https://github.com/user-attachments/assets/2947a473-6221-4b7e-84d0-9fbf0ba6adc0">

<img width="289" alt="image" src="https://github.com/user-attachments/assets/3f14cb7f-9a21-4f94-a677-a1b84ddea4b9">

Reviewed By: javache

Differential Revision: D60172126

Pulled By: cortinico

fbshipit-source-id: ffe37bae3555fc916a71e02208fc56707be6417d
2024-07-25 01:42:44 -07:00
Miguel Daipré 053865bd80 feat: migrate BuildCodegenCLITaskTest and PrepareGlogTaskTest to AssertJ (#45649)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[ANDROID] [CHANGED] - Migrated `BuildCodegenCLITaskTest`, `PrepareGlogTaskTest` from junit.Assert to assertj.core.api.Assertions.

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: christophpurrer

Differential Revision: D60178114

Pulled By: cortinico

fbshipit-source-id: f0cfe9da945829a2bada8e9807eb1877240d93d6
2024-07-25 01:33:28 -07:00
Ömer Esmer e553acaf1e chore: ☂️ Migrate InteropUiBlockListenerTest.kt to AssertJ #45610 (#45635)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[INTERNAL] [CHANGED] - Migrated to AssertJ within file `InteropUiBlockListenerTest.kt`

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: realsoelynn

Differential Revision: D60183376

Pulled By: arushikesarwani94

fbshipit-source-id: 534566642e246e88367cdc72fb2284c6d1a08005
2024-07-24 18:27:51 -07:00
David Vacca 64f630df8e Delete Scheduler.reduceDeleteCreateMutationLayoutAnimation (#45628)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45628

Scheduler.reduceDeleteCreateMutationLayoutAnimation is unused, I'm deleting in this diff

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D60142585

fbshipit-source-id: 5573ca230c4007c348e64ca967604d791f69fde4
2024-07-24 16:53:53 -07:00
Kevin Gozali a634b57650 Allow passing through optional custom transform options to Metro (#45634)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45634

This allows the Android runtime to pass additional options to Metro. Each app can
decide what to send based on the needs. The use case is to send
transform.xyz=somevalue to Metro.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D60155757

fbshipit-source-id: 006d5ff2e3f14634fb39d44b390f30da479b1faa
2024-07-24 14:48:54 -07:00
Kevin Gozali 8effe781d3 Allow passing through optional custom transform options to Metro (#45621)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45621

This allows the iOS runtime to pass additional options to Metro. Each app can
decide what to send based on the needs. The use case is to send
`transform.xyz=somevalue` to Metro.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D60143663

fbshipit-source-id: 3e35a01a0ee121096d3a5cf0547e8e0ebf77f8ce
2024-07-24 14:48:54 -07:00
Alex Hunt 5cf72ca046 Fix translatability of modules using event-target-shim (#45646)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45646

As titled. This is adapted from https://github.com/facebook/react-native/pull/45056.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D60173075

fbshipit-source-id: 9ce1c96d333b7e6b84d9b7650bc4179ebf86d267
2024-07-24 14:46:39 -07:00
Miguel Daipré 7aff1b9bd8 feat: migrate DefaultNewArchitectureEntryPointTest, InteropEventEmitterTest and InteropModuleRegistryTest to AssertJ (#45623)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[ANDROID] [CHANGED] - Migrated `DefaultNewArchitectureEntryPointTest`, `InteropEventEmitterTest`, `InteropModuleRegistryTest` from junit.Assert to assertj.core.api.Assertions.

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

Test Plan: Run `./gradlew test`

Reviewed By: cortinico

Differential Revision: D60151876

Pulled By: arushikesarwani94

fbshipit-source-id: c8b82fbfc7aae54e2524e7d8e876ee9ffbc10b9b
2024-07-24 14:38:49 -07:00
Joe Vilches ee17ca881a Let inset shadows have rounded corners (#45624)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45624

Must have forgot to add this functionality in, since it was just using a Rect for the clear region. This uses the proper rounded path.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60147035

fbshipit-source-id: 3eebb2c4a56e4dfc957213e54f3d2de2c966082b
2024-07-24 14:00:05 -07:00
Joe Vilches 6fc3d359b5 Use needsInvalidateLayer, not _needsInvalidateLayer for filter and box shadow (#45622)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45622

The rest of these props setters opts to use `needsInvalidateLayer`, not `_needsInvalidateLayer` the latter of which is a instance variable. This change no effect since we set `_needsInvalidateLayer` to the or of both below, but we should be consistent with the rest of the logic here.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60144215

fbshipit-source-id: b4b863d964a688c1cb9f6fada626d390681d1542
2024-07-24 14:00:05 -07:00
Joe Vilches e42533294b Don't invalidate layer for mix blend mode (#45620)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45620

This does not really depend on anything in the layer. It is just a prop on the layer itself, so we can just set it in place. This pattern already happens for things like transform: https://fburl.com/code/0bhsdlcy

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60142154

fbshipit-source-id: 52ee0e1e6eacf3bba005a727a5a4325a5cc6d338
2024-07-24 14:00:05 -07:00
Joe Vilches 7ba801b7f0 Fix issue where shadows were not being cleaned up (#45613)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45613

We had a bug where box shadows were not getting cleaned up. The fix here is easy - just call `[_boxShadowLayer removeFromSuperView]`. Previously we were just setting this layer to nil, which does not do the job.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60137528

fbshipit-source-id: 310df944f63ffc73ee5fe938cfb5a48674f997ab
2024-07-24 14:00:05 -07:00
Jack Su f9ac5b737a Fixed race condition issue which caused Bloks page not loading issue
Summary:
## Context

During TW Bloks testing, I frequently encounter the issue of a page not loading. After investigating further, I discovered that for one XOCReactNativeHost, there are multiple instances of ReactInstanceManager created. One of them is properly initialized with XOCLoginActivity, while the other one is not initialized and its activity is null.

When calling ReactContext onHostResume, there is a small chance that the ReactInstanceManager with a null activity will be used, resulting in a "no activity" issue.

After analyzing the construction call stack of ReactInstanceManager, it appears that there is a race condition in the function of ReactNativeHost.getReactInstanceManager https://fburl.com/code/kh6o84m9.
I noticed that two threads are calling this function simultaneously, which can lead to the creation of two instances despite the `mReactInstanceManager == null check`, as it is not within a synchronized statement.

An example of one ReactNativeHost with multiple ReactInstanceManagers can be found at https://fburl.com/code/kh6o84m9.

{F1768111631}

The following are the call stack to create the ReactInstanceManagers, the line number may have slightly shift from the prod code because of debugging info.

P1490866855
P1490869412

## About this diff
Added synchronized lock to the checking of `mReactInstanceManager == null` and make  mReactInstanceManager as volatile to avoid creating duplicated instance.

## Changelog:
[Android] [Fixed] - Made several methods in ReactNativeHost.java thread-safe to avoid race conditions

bypass-github-export-checks

Reviewed By: javache

Differential Revision: D60088120

fbshipit-source-id: a4c1970bb54c7395dbfc3282d02bd66d9dc95df9
2024-07-24 13:47:40 -07:00
Nicola Corti cb6ea49123 Fix warning on scripts/releases-ci/__tests__/publish-updated-packages-test.js (#45643)
Summary:
This just fixes a warning in scripts/releases-ci/__tests__/publish-updated-packages-test.js that the CI is firing on every PR

## Changelog:

[INTERNAL] - Fix warning on scripts/releases-ci/__tests__/publish-updated-packages-test.js

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

Test Plan: CI

Reviewed By: blakef

Differential Revision: D60170227

Pulled By: cortinico

fbshipit-source-id: 5889f7dd530cc00651d683001e1f2624bd79c27e
2024-07-24 12:41:00 -07:00
Oskar Kaczmarzyk 4cc46e3ca6 chore: tests migration to assertj (KotlinStdlibCompatUtilsTest, ModelAutolinkingDependenciesJsonTest, PathUtilsTest, DependencyUtilsTest, ProjectUtilsTest) (#45606)
Summary:
https://github.com/facebook/react-native/issues/45596

## Changelog:

Migrated to AssertJ within files:
- `KotlinStdlibCompatUtilsTest.kt`,
- `ModelAutolinkingDependenciesJsonTest.kt`,
- `PathUtilsTest.kt`,
- `DependencyUtilsTest.kt`,
- `ProjectUtilsTest.kt`.

[INTERNAL] [CHANGED] - Migrated `KotlinStdlibCompatUtilsTest`, `ModelAutolinkingDependenciesJsonTest`, `PathUtilsTest`, `DependencyUtilsTest`, `ProjectUtilsTest` from `junit.Assert` to `assertj.core.api.Assertions`.

## Test Plan

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

Reviewed By: javache

Differential Revision: D60166231

Pulled By: cortinico

fbshipit-source-id: 5092e7d0d4c8d0a8737183962bda62ed1f54ccda
2024-07-24 09:44:45 -07:00
Dan Melnic 2052a1dfa3 Fix warning C4100: 'rt': unreferenced formal parameter (#45633)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45633

Changelog: [Internal]
Fix warning C4100: 'rt': unreferenced formal parameter

Differential Revision: D60152935

fbshipit-source-id: 9fe4b934721d38e7edf5c3329c40f5c0595a2897
2024-07-24 09:28:18 -07:00
Ramanpreet Nara 842c382773 Refactor: RuntimeScheduler: Make error handlers configurable (#45616)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45616

We want to eventually route all js error handling through JsErrorHandler in bridgeless.

This will help with that.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D60138415

fbshipit-source-id: de62edfe75066ba135225e24543628306aa5f4a0
2024-07-24 08:57:31 -07:00
Jakub Piasecki dc8c8ebc5b Disable JS batching when animation batch is finished on Android (#45563)
Summary:
When an animation using the native driver [is started](https://github.com/facebook/react-native/blob/c82edec62e2149a746627c6b474d4d413f545128/packages/react-native/Libraries/Animated/animations/Animation.js#L89), all animated operations are [queued](https://github.com/facebook/react-native/blob/c82edec62e2149a746627c6b474d4d413f545128/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js#L115). The queue is then flushed as part of [a single batch](https://github.com/facebook/react-native/blob/c82edec62e2149a746627c6b474d4d413f545128/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js#L173-L181). The problem here is that when a batch is executed, on the native side a [flag is flipped](https://github.com/facebook/react-native/blob/c82edec62e2149a746627c6b474d4d413f545128/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java#L543) and it assumes that JS will take control of the batching operation from that point onward, which is not the case. Operations are queued with the current batch number but are never executed, since the new "batch" is never finished. The case which let to figuring it out is the creation of `AnimatedInterpolation` in the [sticky header component](https://github.com/facebook/react-native/blob/c82edec62e2149a746627c6b474d4d413f545128/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js#L215).

This PR changes this by returning to the default behavior when the batch is completed.

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

## Changelog:

[ANDROID] [FIXED] - Fix scheduled animated operations not being executed in some cases

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

Test Plan: Tested on Animated examples in RNTester and on the reproducer app from the issue

Reviewed By: cipolleschi

Differential Revision: D60108049

Pulled By: dmytrorykun

fbshipit-source-id: 9c14d116b0df2c78fbbb00cf7224bddd09ae5796
2024-07-24 06:09:45 -07:00
Janic Duplessis 19cffab383 Fix legacy view interop apis not available in view method (#45609)
Summary:
When trying to use the legacy view interop with `stripe/stripe-react-native` there is an issue with the `CardField` component because it tries to access module registry inside the `view` method (https://github.com/stripe/stripe-react-native/blob/master/ios/CardFieldManager.swift#L7).

The problem is that we attach the legacy view apis after creating view, so they are not available in that method.

To fix this we can change the order of the methods and attach the apis first. Note that we also need to use the `manager` method instead of `bridgelessViewManager` since `bridgelessViewManager` is not initialized otherwise, it is initialized lazily in the `manager` method.

## Changelog:

[IOS] [FIXED] - Fix legacy view interop apis not available in view method

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

Test Plan: Tested in an app that legacy interop apis (`moduleRegistry`) is available in the `view` method in an app using RN 0.74 with bridgeless mode enabled.

Reviewed By: cipolleschi

Differential Revision: D60165191

Pulled By: dmytrorykun

fbshipit-source-id: 60187556fb36d342bb1ef084a093132bdb0496bd
2024-07-24 06:08:45 -07:00
Dong-Hwan Kim 1dcbf41725 fix: add missing submitBehavior prop type and mark blurOnSubmit prop as deprecated in typescript declaration file of TextInput (#45588)
Summary:
Hi, I just found out that https://github.com/facebook/react-native/pull/33653 adds a new prop in `TextInput` that enables multiline `TextInput` be able to submit without blurring.

It does that by adding a new prop called `submitBehavior` which accepts `'submit' | 'blurAndSubmit' | 'newline'`:
https://github.com/facebook/react-native/blob/700b403e06fdcbcde2a4ade9570eb572431487ea/packages/react-native/Libraries/Components/TextInput/TextInput.js#L195

https://github.com/facebook/react-native/blob/700b403e06fdcbcde2a4ade9570eb572431487ea/packages/react-native/Libraries/Components/TextInput/TextInput.js#L910-L928

It also marks `blurOnSubmit` prop as deprecated since it can now be handled from `submitBehavior`:
https://github.com/facebook/react-native/blob/700b403e06fdcbcde2a4ade9570eb572431487ea/packages/react-native/Libraries/Components/TextInput/TextInput.js#L896-L908

However, that PR doesn't update `TextInput.d.ts` file which results Typescript to complain that the type doesn't exist:
<img width="760" alt="text_input_error" src="https://github.com/user-attachments/assets/2235cb36-1e4e-4ec9-a8b0-c09728a3336f">

So this PR adds and updates the types in declaration file to support them in Typescript
<img width="520" alt="fixed" src="https://github.com/user-attachments/assets/a7a3a0c4-9f3e-4644-bfac-ae60ac21d0f7">

## Changelog:

[GENERAL] [FIXED] - add missing `submitBehavior` prop and mark `blurOnSubmit` prop as deprecated in Typescript declaration file of `TextInput`

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

Test Plan:
Before:
<img width="295" alt="before" src="https://github.com/user-attachments/assets/90ed0cd1-c127-4667-bf72-6b5317ea4dd6">

After:
<img width="589" alt="after1" src="https://github.com/user-attachments/assets/826002a4-45dc-4f97-882d-7622238ac766">

<img width="833" alt="after2" src="https://github.com/user-attachments/assets/467eeecd-4b0b-4740-ac78-253e3c7aa901">

Reviewed By: christophpurrer

Differential Revision: D60107516

Pulled By: dmytrorykun

fbshipit-source-id: ce79e41aefc1ef39dc1d44179405cf6a8d5e12de
2024-07-24 02:25:08 -07:00
Blake Friedman cab905bb57 Allow cache reaper to skip failing cache removal request (#45593)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45593

I'm guessing either there is a race condition between Github removing cache entries when we're over budget OR there is an eventual consistency issue between reported cache entries and their removal.  Either way, this job is best efforts.  If a entry targetted for removal isn't there, great.

This change prevents the job from stopping if an entry no longer exists.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D60106847

fbshipit-source-id: 252bba7bb0bbb91d279f06a39301491332cd5ace
2024-07-24 00:45:05 -07:00
bufgix d25249442d chore: ☂️ Migrate BlobModuleTest.kt to AssertJ (#45610)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[INTERNAL] [CHANGED] - Migrated to AssertJ within file `BlobModuleTest.kt`

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

Test Plan: `Run ./gradlew -p packages/gradle-plugin test`

Reviewed By: mdvacca

Differential Revision: D60138457

Pulled By: cortinico

fbshipit-source-id: 8dcbede98130c24da2d81525d6596a8e4b4aa402
2024-07-24 00:14:28 -07:00
gustavoabel 7829de6221 chore: ☂️ migrate BackwardCompatUtilsTest to AssertJ (#45607)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

Migrated to AssertJ within file:
- ```BackwardCompatUtilsTest.kt```

Changelog:
[Internal] [Changed] -  chore: ☂️ migrate BackwardCompatUtilsTest to AssertJ

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

Test Plan: Run ```./gradlew -p packages/gradle-plugin test```

Reviewed By: mdvacca

Differential Revision: D60137770

Pulled By: cortinico

fbshipit-source-id: 883b2abee430ce45018808fa934a7949ae23fcaf
2024-07-24 00:08:49 -07:00
Miguel Daipré e7881c2f45 feat: migrate JsonUtilsTest, OsTest and TaskUtilsTest to AssertJ (#45608)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

Note:

The formatting changes have been altered by Android Studio. `Code -> Format Code`

## Changelog:

[INTERNAL] [CHANGED] - Migrated `JsonUtilsTest`, `OsTest`, `TaskUtilsTest` from junit.Assert to assertj.core.api.Assertions.

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: mdvacca

Differential Revision: D60137234

Pulled By: cortinico

fbshipit-source-id: 236dc46dd04ad1f62a5e11fd77cf2c63bec99cff
2024-07-23 16:56:59 -07:00
Rubén Norte 010c004d75 Rename track for performance.mark / measures without custom tracks as Web Performance: Timings to align with Chrome (#45597)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45597

Changelog: [internal]

Minor change to align with the Chrome DevTools performance panel.

Reviewed By: sammy-SC

Differential Revision: D60115147

fbshipit-source-id: bfd7b071fc76e226783ef41bd3f13d941acccec5
2024-07-23 14:23:03 -07:00
Rubén Norte 4caf9ec7a0 Migrate CoreFeatures::enableReportEventPaintTime to new feature flags system (#45585)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45585

Changelog: [internal]

Just migrates the flag to the new system.

Reviewed By: sammy-SC

Differential Revision: D60050005

fbshipit-source-id: 4da39446ecdb6cd86ccf7ee75a0d489764c37be6
2024-07-23 14:23:03 -07:00
D N bb23026daf chore: ☂️ Migrate a ClipboardModuleTest test to AssertJ (#45600)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[Internal] [Changed] - Migrate ClipboardModuleTest to Assertj

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

Reviewed By: zeyap

Differential Revision: D60120117

Pulled By: cortinico

fbshipit-source-id: 39720d81e0abad978515b8429f559df817303cd9
2024-07-23 09:47:43 -07:00