Commit Graph

8193 Commits

Author SHA1 Message Date
Tim Yung
29a0d7c3b2 RN: Feature Flag to Disable InteractionManager in Batchinator (#47690)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47690

Creates a feature flag to evalute the impact of disabling `InteractionManager` in `Batchinator` and synchronously invoking callbacks after the timeout.

This also deletes the `dispose` arguments in `Batchinator` that were unused.

Changelog:
[Internal]

Reviewed By: bvanderhoof

Differential Revision: D66139643

fbshipit-source-id: d17bab0cd25c0c69779686cb435c063f707255e4
2024-11-18 23:12:15 -08:00
David Vacca
fbe4c0ed34 Remove jsBundleLoader from DefaultReactHost.getDefaultReactHost (#47684)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47684

jsBundleLoader parameter was added into DefaultReactHost.getDefaultReactHost but we decided to revert this change.
We want to keep DefaultReactHost.getDefaultReactHost as simple as possible and we don't want to include this change in 0.77

changelog: [Android][Breaking] Remove jsBundleLoader from DefaultReactHost.getDefaultReactHost()

Reviewed By: shwanton

Differential Revision: D66131197

fbshipit-source-id: 7451bb55d7953d3282b23d23ad15e91bae71ff24
2024-11-18 17:34:59 -08:00
Ramanpreet Nara
cc5f17d5a2 Make NativeModules.foo also load turbo modules (#47598)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47598

## Changes
Now:
- in bridgeless, NativeModules.foo will also return turbo modules. And, global.__turboModuleProxy no longer exists.
- in bridge, nothing changes.

| **JS API**                               | **Bridge**             | ***[Before]* Bridgeless**   | ***[Before]* Bridgeless w/ Interop**| ***[After]* Bridgeless**
| global.__turboModuleProxy |  turbo modules      | turbo modules                     | turbo modules                                     |**deleted**
| global.nativeModuleProxy    |  legacy  modules   | error                                      | legacy modules                                  | turbo + legacy modules

## Justification
This reduces the cost for adopting the new architecture:
- Prior, you had to migrate the module itself, **and** all its callsites: NativeModules.foo -> NativeFoo
- Now, you have to migrate the module itself **only**.

This simplifies the interop layer logic in bridgeless: all modules come from the same thing.

Changelog: [General][Breaking] Bridgeless: Make NativeModules.foo load turbomodules (unset turboModuleProxy in bridgeless).

Reviewed By: javache

Differential Revision: D65896934

fbshipit-source-id: 10883c292b78759fceac5bd984e0cdf8a679fc67
2024-11-18 17:22:51 -08:00
Rob Hogan
d1b0e9a30b dev-middleware: Use serverBaseUrl for local->server fetches (#47653)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47653

## Context

Currently, when `nativeSourceCodeFetching == false`, `inspector-proxy` attempts to pre-fetch source maps, given the URL from a `Debugger.scriptParsed` event, and embeds them into `Debugger.scriptParsed`'s `sourceMapURL` using a data URI.

This was originally to support frontends that did not perform HTTP requests or were blocked (eg by CORS), but we're retaining it for the moment because it's more performant than lazy loading the source map.

Similarly, we perform middleware->server fetches to respond to `Debugger.getScriptSource` events.

To make these fetches for URLs that target `10.0.2.2` (ie, addressable from within an Android emulator) (etc), we rewrite `10.0.2.2`->`localhost` and perform a `fetch` from the Node process running dev-middleware.

## The problem

Consider a setup where:
 - Metro is running on a remote server, listening on `8081`.
 - Dev machine tunnels `localhost:8082` -> remote `8081`.
 - An app is running on an Android emulator on the dev machine, with bundle URL configured to `10.0.2.2:8082`.

In this case, we'll rewrite `10.0.2.2:8082` to `localhost:8082`, which *is* reachable and correct from the dev machine, but *not* from the machine where Metro is running, so the `fetch` of a source map from the inspector proxy will fail.

## Motivation

This might seem like a niche case, but it's part of fixing a series of unsafe assumptions that currently prevent us from running DevTools on an arbitrary port.

## This fix

Preserve the current behaviour (simple `10.0.2.2`<=>`localhost`) for URLs sent to the frontend, but construct a separate, server-relative URL, using the configured `serverBaseUrl`, for `fetch` calls within dev-middleware.

Changelog:
[General][Fixed] RN DevTools: Fix fetching sources and source maps when the dev-server is remote and not tunnelled via the same port+protocol.

Reviewed By: huntie

Differential Revision: D65993910

fbshipit-source-id: a0cdcf1644e97a2af3d8583f2da2aaa51276f68c
2024-11-18 16:23:53 -08:00
Rob Hogan
da62721061 dev-middleware: refactor tests to use undici.request (#47675)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47675

Use `request` over `fetch` in `dev-middleware`'s tests.

This is required by the next diff in the stack to spoof the `Host` header for testing purposes, which isn't permitted by the `fetch` spec.

The return type is a bit different (eg `statusCode` vs `status`, no `ok` prop), but the modifications needed are pretty straightforward.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D66005427

fbshipit-source-id: f311b0188d6d0ec220a037774fca78df5373163a
2024-11-18 15:14:02 -08:00
Rob Hogan
acf384a72e dev-middleware: Redefine "serverBaseUrl" as server-relative, '/json/list' by requestor (#47628)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47628

`serverBaseUrl` is currently documented as:

> The base URL to the dev server, as addressible from the local developer machine

This is problematic in general because `dev-middleware` on a server doesn't necessarily know about where clients might be reaching it from, how tunnels or port-forwards are set up, etc., and this can change over the lifetime of the server and vary between clients.

Indeed, our own use of `serverBaseUrl` from both `community-cli-plugin` and internally simply sets it to the host and port the dev server is listening on - ie it's the address of the dev server accessible *from the server*.

This PR changes the docs, redefining `serverBaseUrl`, to match the way we currently specify it.

One usage where we *do* want the previously documented behaviour is in responses to `/json/list` (`getPageDescriptions`) where the URLs in the response should be reachable by a browser requesting `/json/list`.

Here, we use the request (host header, etc.) to attempt to get working base URL.

History:
It should be mentioned that this is the latest in a series of changes like this:
 - https://github.com/facebook/react-native/pull/39394
 - https://github.com/facebook/react-native/pull/39456

Learning from those:
 - This change does *not* break Android emulators, which routes `10.0.2.2` to localhost, or other routed devices, because `/open-debugger` still uses server-relative URLs, and now formally delegates to `BrowserLauncher` to decide what to do with those URLs (internally, VSCode / `xdg-open` handles port forwarding)
 - Middleware configuration is no longer required to specify how it is reachable from clients.

This sets up some subsequent changes for more robust handling of tunnelled connections.

Changelog:
[General][Breaking] dev-middleware: Frameworks should specify `serverBaseUrl` relative to the middleware host.

Reviewed By: huntie

Differential Revision: D65974487

fbshipit-source-id: 1face8fc7715df387f75b329e80932d8543ee419
2024-11-18 13:46:50 -08:00
Rob Hogan
ca9c56329f dev-middleware: Fix reliance on adb reverse when loading sources on Android (#47652)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47652

## Background
When the `nativeSourceCodeFetching` capability is disabled, `inspector-proxy` rewrites URLs exchanged over CDP between device and frontend so that URLs are addressable from CDT - in particular, when using an Android emulator `10.0.2.2` (host's address from within the emulator) is rewritten to and from `localhost` (the equivalent address reachable from the host).

Previously - before we implemented `Network.loadNetworkResource`, or on old frontends that don't attempt to use that method -  this worked reasonably well. A `fetch` from CDT to Metro would succeed on the rewritten URL.

## Problem
Since we implemented `Network.loadNetworkResource`, but disabled the `nativeSourceCodeFetching` capability, source fetching is broken under Android emulators. We're rewriting URLs to be frontend-relative, but then attempting to fetch them through the device, because as far as CDT is aware, `Network.loadNetworkResource` should still be tried first.

When `Network.loadNetworkResource` responds with a CDP *error*, CDT falls back to a local fetch (which would work), but when it responds with a CDP *result* of `success: false`, there is no fallback.

## Fix
This diff adds an interception guarded behind `nativeSourceCodeFetching == false`, which rejects any calls to `Network.loadNetworkResource` with a CDP error. This restores the previous behaviour from before `Network.loadNetworkResource` was implemented at all.

NOTE: An alternative approach would be to rewrite URLs back to device-relative for `Network.loadNetworkResource`, but IMO it's more correct for the frontend to respect that the device is asserting that it doesn't have that capability, and not to try to use it.

Changelog:
[Android][Fixed] RN DevTools: Fix source loading when using an Android emulator connecting to a dev server on the host.

Reviewed By: huntie

Differential Revision: D66074731

fbshipit-source-id: f2050c014cd5cfa546bff5e9d0412413a5daff35
2024-11-18 12:19:19 -08:00
Edmond Chui
8507204b53 fix /open-debugger failing after relaunching Metro/target app (#47623)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47623

Changelog:
[iOS][Fixed] - "Reconnect DevTools" button not working sometimes

Hotfix for "Reconnect DevTools" button not working:

* T206141946 / [WP: Reconnecting dev tools does not work after restarting the app](https://fb.workplace.com/groups/rn.debugger.feedback/posts/1107620434125533)
* T206754760 / [WP: Can't launch DevTools from Metro sometimes](https://fb.workplace.com/groups/rn.debugger.feedback/posts/1112235073664069/)

Basically, this dialog will keep reappearing like a bad dream:

 {F1960030622}

# Repro

Part 1 (Fixed in base stack D65973309)
1. Do NOT have Metro ready.
1. Build and run RNTester/FB Wilde
1. They should be using the local bundled version. App may prompt you to start Metro.
1. Start Metro
1. Go to the device Dev Menu (rage shake) and select Reload
1. Press `r` or `d` in Metro

Expected: Reload and Dev Menu work accordingly
Actual: Metro fails with `No apps connected`:

 {F1960039703}

Part 2 (Fixed in this diff)
1. Open React Native DevTools via Metro `j` key or Dev Menu (rage shake)
1. Kill Metro
1. The RN DevTools should show the "disconnected" dialog
1. Start Metro
1. Click "Reconnect DevTools" in RN DevTools

Expected: reconnects
Actual: dialog reappears with an error in Metro:
{F1960043097}

Interestingly, the `r` and `d` keys from Metro works.

# Root cause(s)
Part 1: See D65973309
Part 2:
The error indicates the target/device failed to call `/inspector/device` to register itself. The subsequent calls to `/json/list` returns empty and `/open-debugger` throws.

1. But because `r` & `d` (heh) works, we can observe that there is some kind of auto-reconnect mechanism:

https://www.internalfb.com/code/fbsource/[cfe1706a60b2]/xplat/js/react-native-github/packages/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m?lines=77-82

1. We do have auto-reconnect for `j` too:

https://www.internalfb.com/code/fbsource/[cfe1706a60b2]/xplat/js/react-native-github/packages/react-native/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp?lines=246-254

But unfortunately it only tries once. A long-term fix would be calling reconnect recursively like the Objective-C impl above, e.g.

Edit: the long-term fix ! See V3

```
  delegate_->scheduleCallback(
      [weakSelf = weak_from_this()] {
        auto strongSelf = weakSelf.lock();
        if (strongSelf && !strongSelf->closed_) {
          strongSelf->reconnectPending_ = false;
          strongSelf->connect();

          // Keep trying. Never. Give. Up.
          if (!strongSelf->isConnected()) {
            strongSelf->reconnect();
          }
        }
      },
      RECONNECT_DELAY);
```

Edit: I snuck in some time during React Native London Conf and got the long-term fix going! ✌️

{gif:7iyrns4l}

~~It appears that the current impl of `isConnected()` is not a true reflection of the web socket state. My time box for this task ran out, so we'll do a hot fix for the short-term: since we know `r` & `d` reliably reconnects, we'll piggy-back on its lifecycle to attempt reconnection. This works. I'm going on PTO for the year, so the follow-up task is up for grabs here: T207775935.~~

# PS

1. If you start the app with Metro running in step 1, this bug is not present. This is the reason why FB Wilde/Marketplace/Quantum engineers run into this more often (because its custom menu changes the JS URL after start up)
2. This auto-reconnect does not mean the RN DevTools frontend will dismiss the dialog automatically. This is only about the `Metro <> Device` in `Frontend <> Metro <> Device`.
    1. Current impl in Metro/Inspector Proxy means that whenever the `Metro <> Device` connection is terminated, the `Frontend <> Metro` connection is killed.
    1. This diff helps restore the `Metro <> Device` connection.
    1. The `Frontend <> Metro` connection does not currently get reconnected. We can make the Frontend do so, with consideration of preserving logs/states, etc.

Reviewed By: robhogan

Differential Revision: D65952134

fbshipit-source-id: 3abd16f6a7b7ed50e8acdb7c753cc4fbd3317236
2024-11-18 11:30:23 -08:00
Rubén Norte
3986eefed1 Clean up feature flag allowRecursiveCommitsWithSynchronousMountOnAndroid (#47665)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47665

Changelog: [Android][Fixed] Fixes some deadlocks when doing commits and state updates synchronously from the UI thread (e.g.: from reanimated).

This removes the gating for the fix to allow recursive commits with synchronous mount on Android.

See https://github.com/facebook/react-native/pull/44725#issuecomment-2427579065 and https://github.com/software-mansion/react-native-reanimated/issues/6418#issuecomment-2296107100.

Reviewed By: sammy-SC

Differential Revision: D66095539

fbshipit-source-id: 63b8c4d9161a40159601b8e3b45f7e5c7cdd83e4
2024-11-18 08:13:17 -08:00
Riccardo Cipolleschi
95fc906930 Pass the RCTAppDependencyProvider to the RCTAppDelegate (#47651)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47651

## This Change:

This change uses in the App's AppDelegate the newly generated `RCTAppDependencyProvider`, passing it to the `RCTAppDelegate`.

This change needs to be applied also to the template, when this stack lands.

## Context

React Native has a last temporal dependency on Codegen in the React-RCTAppDelegate pod.

The RCTAppDelegate has the responsibility to provide various dependencies to react native, like third party components and various modules. ReactCodegen is generated when the user create the project, while React-RCTAppDelegate eists in React Native itself.

This dependency means that we cannot prepare prebuilt for iOS for React Native because when we would have to create prebuilds, we would need the React Codegen, but we can't create a React codegen package that will fit all the apps, because React Codegen can contains App Specific modules and components and apps might have different dependencies.

## Changelog:
[iOS][Added] - Pass the `RCTAppDependencyProvider` to the `RCTAppDelegate`

Reviewed By: dmytrorykun

Differential Revision: D66074475

fbshipit-source-id: 93bf500fe37f115352ebd49d3d56955cbaeeea72
2024-11-18 08:06:13 -08:00
Riccardo Cipolleschi
41c2502b36 Generate RCTAppDependencyProvider for apps (#47650)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47650

## This Change:

This change generates the `RCTAppDependencyProvider` for the apps, so that the amount of changes required by the users is minimal.

## Context

React Native has a last temporal dependency on Codegen in the React-RCTAppDelegate pod.

The RCTAppDelegate has the responsibility to provide various dependencies to react native, like third party components and various modules. ReactCodegen is generated when the user create the project, while React-RCTAppDelegate eists in React Native itself.

This dependency means that we cannot prepare prebuilt for iOS for React Native because when we would have to create prebuilds, we would need the React Codegen, but we can't create a React codegen package that will fit all the apps, because React Codegen can contains App Specific modules and components and apps might have different dependencies.

## Changelog:
[iOS][Added] - Introduce the RCTAppDependencyProvider to minimize the changes required y the users

Reviewed By: dmytrorykun

Differential Revision: D66074456

fbshipit-source-id: 073022e66da53eca6bf948aeda01f17ad85793ff
2024-11-18 08:06:13 -08:00
Riccardo Cipolleschi
b91626af26 Use RCTDependencyProvider in RCTAppDelegate (#47649)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47649

## This Change:

This change uses the `RCTDependencyProvider` protocol created before, breaking the dependency between the RCTAppDelegate and codegen.

## Context

React Native has a last temporal dependency on Codegen in the React-RCTAppDelegate pod.

The RCTAppDelegate has the responsibility to provide various dependencies to react native, like third party components and various modules. ReactCodegen is generated when the user create the project, while React-RCTAppDelegate eists in React Native itself.

This dependency means that we cannot prepare prebuilt for iOS for React Native because when we would have to create prebuilds, we would need the React Codegen, but we can't create a React codegen package that will fit all the apps, because React Codegen can contains App Specific modules and components and apps might have different dependencies.

## Changelog:
[iOS][Breaking] - Use the RCTDependencyProvider in the RCTAppDelegate, breaking the dependency with Codegen

Reviewed By: dmytrorykun

Differential Revision: D66074438

fbshipit-source-id: 33234411a3840598b9bd16b0b71a15f75fd3c6a7
2024-11-18 08:06:13 -08:00
Riccardo Cipolleschi
f2b3716426 Add RCTDependencyProvider protocol (#47648)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47648

React Native has a last temporal dependency on Codegen in the React-RCTAppDelegate pod.

The RCTAppDelegate has the responsibility to provide various dependencies to react native, like third party components and various modules. ReactCodegen is generated when the user create the project, while React-RCTAppDelegate eists in React Native itself.

This dependency means that we cannot prepare prebuilt for iOS for React Native because when we would have to create prebuilds, we would need the React Codegen, but we can't create a React codegen package that will fit all the apps, because React Codegen can contains App Specific modules and components and apps might have different dependencies.

This change introduces the RCTDependencyProvider protocol to invert this dependency.

## Changelog:
[iOS][Added] - Add RCTDependencyProvider protocol

Reviewed By: dmytrorykun

Differential Revision: D66074409

fbshipit-source-id: 0d3d3f707bcb44c1f34ebeb3ae019f7ea074f60f
2024-11-18 08:06:13 -08:00
Riccardo Cipolleschi
7e0bdcb780 Back out "fix(iOS): unify prefetchImageWithMetadata's signature in JS and ObjC land" (#47664)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47664

We landed the previous change in [4dd60acb7d](4dd60acb7d), but this is breaking the OSS CI because now the two signatures do not match

## Changelog:
[Internal] - Revert make the prefetchImageWithMetadata's queryRoot nullable

Reviewed By: GijsWeterings

Differential Revision: D66096759

fbshipit-source-id: b0ce87d82edd63576df7a04c58d5aec3173ad8d6
2024-11-18 07:34:43 -08:00
Pieter De Baets
fe8cc62824 Expose getCurrentReactContext on ReactDelegate (#47659)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47659

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

There's no convenient way to access the current react context when using the new architecture. Exposing `getCurrentReactContext` allows for users to migrate without forcing the check downstream.

Changelog: [Android][Added] ReactDelegate and ReactActivityDelegate#getCurrentReactContext can be used to access the current context

Reviewed By: rshest

Differential Revision: D66094540

fbshipit-source-id: 2e504f0db3eb04e0fff5a667afed875214ba54a2
2024-11-18 07:03:02 -08:00
zhongwuzw
e0df58d5c9 Fabric: Fixes image coordinator status assert crash in debug mode (#47655)
Summary:
Because we cancel the request and the callback for the request loading state occurs in a multi-threaded environment, we may still receive the callback even after canceling the request.

 The assert failed like below:
```
(lldb) bt
* thread https://github.com/facebook/react-native/issues/48, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
    frame #0: 0x0000000106d15008 libsystem_kernel.dylib`__pthread_kill + 8
    frame https://github.com/facebook/react-native/issues/1: 0x000000010581f408 libsystem_pthread.dylib`pthread_kill + 256
    frame https://github.com/facebook/react-native/issues/2: 0x000000018016c4ec libsystem_c.dylib`abort + 104
    frame https://github.com/facebook/react-native/issues/3: 0x000000018016b934 libsystem_c.dylib`__assert_rtn + 268
  * frame https://github.com/facebook/react-native/issues/4: 0x00000001073fcd64 React_Fabric`facebook::react::ImageResponseObserverCoordinator::nativeImageResponseComplete(this=0x00006000039bc838, imageResponse=0x000000016ce86970) const at ImageResponseObserverCoordinator.cpp:93:3
    frame https://github.com/facebook/react-native/issues/5: 0x00000001057c9a6c React_ImageManager`__42-[RCTImageManager requestImage:surfaceId:]_block_invoke_2(.block_descriptor=0x0000600000da21c0, error=0x0000000000000000, image=0x0000600003034ea0, metadata=0x0000000000000000) at RCTImageManager.mm:76:30
    frame https://github.com/facebook/react-native/issues/6: 0x0000000105657188 RCTImage`__140-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3(.block_descriptor=0x0000600002c90200, error_=0x0000000000000000, image=0x0000600003034ea0) at RCTImageLoader.mm:831:11
    frame https://github.com/facebook/react-native/issues/7: 0x00000001056582e8 RCTImage`__80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_2(.block_descriptor=0x000060000267b780, error=0x0000000000000000, image=0x0000600003034ea0) at RCTImageLoader.mm:933:7
    frame https://github.com/facebook/react-native/issues/8: 0x0000000105658d60 RCTImage`__80-[RCTImageLoader decodeImageData:size:scale:clipped:resizeMode:completionBlock:]_block_invoke_3.207(.block_descriptor=0x0000600002957e90) at RCTImageLoader.mm:973:13
    frame https://github.com/facebook/react-native/issues/9: 0x0000000108560ec0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame https://github.com/facebook/react-native/issues/10: 0x00000001085627b8 libdispatch.dylib`_dispatch_client_callout + 16
    frame https://github.com/facebook/react-native/issues/11: 0x00000001085655f4 libdispatch.dylib`_dispatch_queue_override_invoke + 1312
    frame https://github.com/facebook/react-native/issues/12: 0x00000001085763d4 libdispatch.dylib`_dispatch_root_queue_drain + 372
    frame https://github.com/facebook/react-native/issues/13: 0x0000000108576f7c libdispatch.dylib`_dispatch_worker_thread2 + 256
    frame https://github.com/facebook/react-native/issues/14: 0x000000010581bb38 libsystem_pthread.dylib`_pthread_wqthread + 224
```

![image](https://github.com/user-attachments/assets/7ed1997d-9d48-4631-9a02-0eef28a03cf3)

```
(lldb) bt
* thread https://github.com/facebook/react-native/issues/18, queue = 'com.meta.react.turbomodulemanager.queue', stop reason = signal SIGABRT
    frame #0: 0x0000000107ea9008 libsystem_kernel.dylib`__pthread_kill + 8
    frame https://github.com/facebook/react-native/issues/1: 0x000000010569b408 libsystem_pthread.dylib`pthread_kill + 256
    frame https://github.com/facebook/react-native/issues/2: 0x000000018016c4ec libsystem_c.dylib`abort + 104
    frame https://github.com/facebook/react-native/issues/3: 0x000000018016b934 libsystem_c.dylib`__assert_rtn + 268
  * frame https://github.com/facebook/react-native/issues/4: 0x00000001072bcae8 React_Fabric`facebook::react::ImageResponseObserverCoordinator::nativeImageResponseProgress(this=0x00006000039bd7a8, progress=-1006, loaded=1006, total=-1) const at ImageResponseObserverCoordinator.cpp:76:3
    frame https://github.com/facebook/react-native/issues/5: 0x0000000105615fb8 React_ImageManager`__42-[RCTImageManager requestImage:surfaceId:]_block_invoke.3(.block_descriptor=0x0000600000d26a30, progress=1006, total=-1) at RCTImageManager.mm:89:28
    frame https://github.com/facebook/react-native/issues/6: 0x00000001055160fc RCTImage`__64-[RCTImageLoader _loadURLRequest:progressBlock:completionBlock:]_block_invoke.192(.block_descriptor=0x0000600000cd4900, progress=1006, total=-1) at RCTImageLoader.mm:747:7
    frame https://github.com/facebook/react-native/issues/7: 0x000000010504bc4c RCTNetwork`__44-[RCTNetworkTask URLRequest:didReceiveData:]_block_invoke.22(.block_descriptor=0x00006000017e0c80) at RCTNetworkTask.mm:201:7
    frame https://github.com/facebook/react-native/issues/8: 0x0000000108a24ec0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame https://github.com/facebook/react-native/issues/9: 0x0000000108a267b8 libdispatch.dylib`_dispatch_client_callout + 16
    frame https://github.com/facebook/react-native/issues/10: 0x0000000108a2eaac libdispatch.dylib`_dispatch_lane_serial_drain + 912
    frame https://github.com/facebook/react-native/issues/11: 0x0000000108a2f7b0 libdispatch.dylib`_dispatch_lane_invoke + 420
    frame https://github.com/facebook/react-native/issues/12: 0x0000000108a3c1f0 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 324
    frame https://github.com/facebook/react-native/issues/13: 0x0000000108a3b75c libdispatch.dylib`_dispatch_workloop_worker_thread + 732
    frame https://github.com/facebook/react-native/issues/14: 0x0000000105697b74 libsystem_pthread.dylib`_pthread_wqthread + 284
```

![image](https://github.com/user-attachments/assets/524a3ba2-857e-4f3a-8757-115d3ebadb42)

## Changelog:

[IOS] [FIXED] - Fabric: Fixes image coordinator status assert crash in debug mode

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

Test Plan: Very easy to repro, just open RNTester's Image example, and then pop the page. Do this back and forth a few times.

Reviewed By: sammy-SC, rshest

Differential Revision: D66093834

Pulled By: javache

fbshipit-source-id: a2ca36147498725d38a95cc3fcc12a2c18802303
2024-11-18 05:46:49 -08:00
Henning Hall
089c87e22e feat: add disabledButtonTintColor prop in ActionSheetIOS (#46883)
Summary:
### Problem
Setting the `tintColor` prop in ActionSheetIOS also changes the tint of disabled entries. This could make them visually indistinguishable from enabled items. The degree to which they are indistinguishable depends on the tint color.

### Solution
This new prop `disabledButtonTintColor` allows customization of disabled items' tint color.

Related PR: https://github.com/facebook/react-native/pull/31972

## Changelog:

[IOS] [ADDED] - added `disabledButtonTintColor` prop to ActionSheetIOS

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

Test Plan:
Tested in RNTester project.

<table>
  <tr>
    <td align="center">
      <strong>Before</strong>
    </td>
    <td align="center">
      <strong>After</strong>
    </td>
  </tr>
  <tr>
    <td>
      <img src="https://github.com/user-attachments/assets/5ab251d9-3128-45e0-bb1f-907376422df0" alt="Screenshot Before" width="300"/>
    </td>
    <td>
      <img src="https://github.com/user-attachments/assets/96f76a08-bb8d-497a-9c89-dca0e0bdbcbb" alt="Screenshot After" width="300"/>
    </td>
  </tr>
  <tr>
    <td align="center">
      <strong>Before</strong>
    </td>
    <td align="center">
      <strong>After</strong>
    </td>
  </tr>
</table>

Reviewed By: lunaleaps

Differential Revision: D65757069

Pulled By: cipolleschi

fbshipit-source-id: 1f51ed6927bfb4fe4e21018c541303dff44b2217
2024-11-18 05:26:38 -08:00
Parsa Nasirimehr
4dd60acb7d fix(iOS): unify prefetchImageWithMetadata's signature in JS and ObjC land (#47532)
Summary:
in `prefetchImageWithMetadata`'s implementation in ObjC, the method's `queryRootName` is treated as being nullable. The image spec for it in JS (and the Codegened ObjC header that gets built on top of it) treat the field as not nullable. This change makes the field nullable in the spec to match up what we have in the implementation.

I also noticed that the method is not defined in the [Image props](https://reactnative.dev/docs/image) on the RN website, so perhaps we should add this there as well.

bypass-github-export-checks

## Changelog:

[IOS] [CHANGED] - make `prefetchImageWithMetadata`'s `queryRootName` nullable in the spec

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

Test Plan:
yarn test:
<img width="1576" alt="Screenshot 2024-11-09 at 00 36 30" src="https://github.com/user-attachments/assets/4162ff79-1388-4f6f-9576-256fd9011fcf">
It has no iOS specific tests, so nothing to run on that side

Reviewed By: javache

Differential Revision: D65761208

Pulled By: cipolleschi

fbshipit-source-id: d050950486e9f804b65dab047d93761a610a71e7
2024-11-18 04:17:39 -08:00
dominictb
e021e50d53 fix: scroll the cursor into view when focus (#46411)
Summary:
Currently in iOS, when focusing the multiline text input, the cursor is not automatically scrolled into view if it is out of view. This PR adds the small util to scroll the cursor into view when the text input focuses. This doesn't happen in Android due to [this](defb0bd137/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (L360))

Original issue: https://github.com/Expensify/App/issues/48122
Original proposal: https://github.com/Expensify/App/issues/48122#issuecomment-2320769418

## 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] [ADDED] - Scroll the cursor into view when text input is focused

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

Test Plan:
Code to reproduce in rn-tester
```
const TextInputWithFocusButton = () => {
  const inputToFocusRef = React.useRef<React.ElementRef<typeof TextInput> | null>(null);
  return (
    <View>
      <ExampleTextInput
        ref={inputToFocusRef}
        placeholder="height increases with content"
        defaultValue="React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native."
        multiline={true}
        enablesReturnKeyAutomatically={true}
        returnKeyType="go"
        style={[styles.multiline, styles.multilineExpandable]}
      />
      <Button title="Focus" onPress={() => {
        inputToFocusRef.current?.focus();
      }} />
    </View>
  );
};
```

Steps:
- Move the cursor of the input to end of the input text
- Scroll up the input
- Blur the input
- Click on `Focus` button to re-focus the input

Note that before this fix, the cursor is not scrolled into view

- In iOS

<table>
<tr>
<th>Before</th>
<th>After</th>
</tr>
<tr>
<td>

https://github.com/user-attachments/assets/de589cbf-158c-4e28-81d6-8412bf05ab23

</td>
<td>

https://github.com/user-attachments/assets/81c571f9-653b-49a5-9ecb-6eeaa2c54ec7

</td>
</tr>
</table>

Reviewed By: sammy-SC

Differential Revision: D62847985

Pulled By: cipolleschi

fbshipit-source-id: c0367a7fc0a7a16b30c4538e59f42d971d959357
2024-11-18 03:38:49 -08:00
Fouad Magdy
794154e63a fix build failure on windows in android (#47641)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
This pull request addresses a CMake configuration issue where an invalid escape character in file paths caused the build process to fail. Specifically, it resolves the issue in the React Native CMake configuration file where the path separator was incorrectly handled, leading to an error in the build system.

the issue is in [This Issue](https://github.com/expo/expo/issues/32955) and [This](https://github.com/expo/expo/issues/32957)

## 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] [FIXED] - Corrected invalid escape character in CMake path handling

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

Test Plan:
To test the changes, I performed the following steps:

1. Cloned the repository and checked out the `fix-cmake-invalid-escape-character` branch.
2. Ran the CMake build on a Windows environment where the issue was previously occurring.
3. Verified that the build process completed successfully without the "invalid character escape" error.
4. Ensured that the path handling now works correctly in CMake on Windows platforms.

Reviewed By: rshest

Differential Revision: D66073896

Pulled By: cipolleschi

fbshipit-source-id: bd2a71bb00ce5c5509ed403842c995c32f58f91d
2024-11-18 02:38:32 -08:00
Samuel Susla
89a7238acd introduce ability to flush messege queue from tests (#47646)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47646

changelog: [internal]

In order to control scheduling of tests, test setup must be separated from test running. This is because of how internal scheduling of React Native is restricted until bundle is loaded via BufferedRuntimeExecutor. This is the reason for executing tests by calling global function `$$RunTests$$`. This is not a pretty solution but it is hidden within testing infrastructure and users of our test infra are not exposed to this.

There is a new method exposed to JavaScript: flushMessageQueue. This will flush everything that is inside of message queue. This is the queue where tasks are queued whenever RuntimeScheduler enqueues something by calling `runtimeExecutor_`.

Reviewed By: christophpurrer

Differential Revision: D65951894

fbshipit-source-id: 2e8e0c10fbeb998f4a51ee6d01ef229eb5f70448
2024-11-17 03:30:31 -08:00
Samuel Susla
6f1c2a512e synchronise dispatching of view commands through RuntimeScheduler (#47604)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47604

## Changelog:

[iOS] [Fixed] - Fixed use of view commands from layout effects

Mounting of views is delayed by runtime scheduler to allow React to run layout effects. Execution of view commands must by queued together with mounting of views, otherwise it might be executed before views are mounted. When this happens, view commands are ignored.

So before, if view command was executed from layout effect (or ref function), it would get dispatched to the UI thread as quickly as possible. But mounting of views would be delayed. To fix this, both mounting of views and view commands are put on the same queue inside of RuntimeScheduler.

## What about Android?
Android employs a [retry mechanism](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java#L211) that was needed for react tag based view commands. In paper, one could send a view command to a react tag which was completely disconnected from whether a view exists or not.

iOS was built with ref commands in mind, so it doesn't have this mechanism.

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

Reviewed By: javache, cipolleschi

Differential Revision: D65909191

fbshipit-source-id: 9d2a444879bee62a7b8b7d31edde450e18339b89
2024-11-16 08:22:37 -08:00
generatedunixname89002005232357
38fb83ca86 Revert D65556000 (#47642)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47642

Reverts https://github.com/facebook/react-native/pull/47468

Changelog: [Internal]

Reviewed By: Abbondanzo

Differential Revision: D66030953

fbshipit-source-id: aea1f681e1916cc234b69bce650670451829bb55
2024-11-15 16:55:33 -08:00
David Vacca
7a5a10c95c Expose exceptionHandler as a parameter of DefaultReactHost.getDefaultReactHost() method (#47638)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47638

This diff exposes exceptionHandler as a parameter of DefaultReactHost, this is necessary becuase apps using getDefaultReactHost are not able to set an exceptionHandler

We need to revisit this API as a follow up

changelog: [Android][Added] Add exceptionHandler as a parameter of DefaultReactHost.getDefaultReactHost() method

Reviewed By: alanleedev

Differential Revision: D66011047

fbshipit-source-id: 3f36aa0d064a0b1b47e9f71df55bbe466950048a
2024-11-15 12:43:06 -08:00
Samuel Susla
84265fd3d9 move reference to RuntimeScheduler to pointer (#47605)
Some checks failed
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Keep Github Actions Cache < 10GB / cache-cleaner (push) Has been cancelled
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47605

changelog: [internal]

use a pointer to RuntimeScheduler instead of getting a reference to it from context container each time.

Reviewed By: javache, cipolleschi

Differential Revision: D65909100

fbshipit-source-id: c53c9b573777803f7f3077656af1dae0db7eee88
2024-11-15 06:33:03 -08:00
Fabrizio Cucci
6db883a56c Migrate com.facebook.react.views.text.ReactScrollViewCommandHelper to Kotlin (#47619)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47619

As per title.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65660776

fbshipit-source-id: ca238729f511a6e446dedd89515c88b26563aef8
2024-11-15 05:56:18 -08:00
Rubén Norte
4cce3b8bf6 Fix bug in ReadOnlyNode.compareDocumentPosition (#47557)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47557

Changelog: [internal]

Not published as a bugfix because this API isn't enabled in OSS yet.

Reviewed By: sammy-SC

Differential Revision: D65769326

fbshipit-source-id: 165d58304d8214c583fbc162d8888095e9f068aa
2024-11-15 03:00:17 -08:00
Edmond Chui
9a60038a40 fix r & d not working from Metro sometimes (#47624)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47624

Changelog:
[iOS][Fixed] - fix `r` & `d` not working from Metro sometimes

While investigating these bugs, I've come across some cases where `r` (Reload) & `d` (Open Dev Menu) not working in Metro.

* T206141946 / [WP: Reconnecting dev tools does not work after restarting the app](https://fb.workplace.com/groups/rn.debugger.feedback/posts/1107620434125533)
* T206754760 / [WP: Can't launch DevTools from Metro sometimes](https://fb.workplace.com/groups/rn.debugger.feedback/posts/1112235073664069/)

This is because when we
1. Start app without Metro
1. Start Metro
1. Reload from Dev Menu (rage shake)

`RCTPackagerConnection` did not get notified about the change in bundle URL. It'd stay "listening" to the commands from the local bundle instead of Metro
.

Reviewed By: robhogan

Differential Revision: D65973309

fbshipit-source-id: a67a58b405bb78dfe56b814f2ec0bbee9e530e46
2024-11-14 20:58:10 -08:00
Alan Lee
74ed831a33 com.facebook.react.modules.intent.IntentModule.java (#47603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47603

Convert Java to Kotlin

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65874900

fbshipit-source-id: 19dbce0a6d822aae8c39860f45b90d064acebd74
2024-11-14 16:28:13 -08:00
Tim Yung
1afde8bd25 RN: Improve usePressability Return Type (#47596)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47596

Improves the Flow type of `usePressability` so that if the `config` argument is non-nullable, the return value is non-nullable. This helps reduce unnecessary null checks.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D65908791

fbshipit-source-id: 77de4391d8141d698a5689e617b692b337d01ae5
2024-11-14 14:07:01 -08:00
Fabrizio Cucci
db3c1a47d5 Migrate com.facebook.react.views.text.ReactSwipeRefreshLayout to Kotlin (#47610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47610

As per title.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65661766

fbshipit-source-id: 3d56f94f90e7b70160e4ca7898aa0a49997ddb87
2024-11-14 09:27:40 -08:00
Thomas Nardone
184eb17261 ReactViewGroup - remove sHelperRect (#47588)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47588

This is unnecessary - we can pass the params directly instead of first populating them in a Rect.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D65843834

fbshipit-source-id: 92bb3faa622bba81792fe92e357bc1667894d4ef
2024-11-14 09:16:43 -08:00
Samuel Susla
e5808f2af6 add nativeId to shadow node logs (#47594)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47594

changelog: [internal]

helpful for debugging.

Reviewed By: christophpurrer

Differential Revision: D65895429

fbshipit-source-id: 51f361f00b070c2374232a375af1b17abb341a97
2024-11-14 08:10:47 -08:00
Rubén Norte
fb32d93d17 Move ReactNativeTester to react-native repo (#47515)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47515

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D65661699

fbshipit-source-id: ab28b4e04254987f5b2f5617d83b9731ee6ad95a
2024-11-14 06:20:47 -08:00
Tim Yung
316170ce8d RN: Enable useInsertionEffectsForAnimations (#47595)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47595

Enables the `useInsertionEffectsForAnimations` feature flag by default. This changes `useAnimatedProps` to enqueue updates to the `AnimatedNode` graph in `useInsertionEffect` instead of `useLayoutEffect`.

The main motivation for `useInsertionEffect` is to avoid unmounting `AnimatedNode` graphs when an `Activity` subtree becomes hidden.

Both `useInsertionEffect` and `useLayoutEffect` occur during the commit phase. Although they occur at different moments in the commit phase, the different is difficult to observe and unlikely to impact product code.

One observable impact is that with `useInsertionEffect`, animations can now be started from layout effects.

Changelog:
[General][Changed] - The `AnimatedNode` graph will not occur during the insertion effect phase, which means animations can now be reliably started during layout effects.

Reviewed By: mdvacca

Differential Revision: D65906157

fbshipit-source-id: d09b2f1b76079eecafbed8c6f5d8ee4695a1f81c
2024-11-13 16:29:32 -08:00
sammy-SC (Meta Employee)
3a41086809 Update React Native shims to use export syntax (#31426) (#47551)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47551

## Summary

I'm working to get the main `react-native` package parsable by modern
Flow tooling (both `flow-bundler`, `flow-api-translator`), and one
blocker is legacy `module.exports` syntax. This diff updates files which
are [synced to
`react-native`](https://github.com/facebook/react-native/tree/main/packages/react-native/Libraries/Renderer/shims)
from this repo.

## How did you test this change?

Files were pasted into `react-native-github` under fbsource, where Flow
validates .

DiffTrain build for [5c56b873efb300b4d1afc4ba6f16acf17e4e5800](5c56b873ef)

Test Plan: Sandcastle tests

Reviewed By: sammy-SC

Differential Revision: D65672576

Pulled By: huntie

fbshipit-source-id: 3d1f2eee0a4872d6a167cbc10e9f022e20f2bdc3
2024-11-13 14:41:10 -08:00
Oskar Kwaśniewski
177bf4d043 feat: handle negative values in enums (#47452)
Summary:
This PR adds support for negative values in enums.

Currently when we try to use an enum with negative value:

```ts
enum MyEnum {
  ZERO = 0,
  POSITIVE = 1,
  NEGATIVE = -1,
}

export interface Spec extends TurboModule {
  useArg(arg: MyEnum): void;
}

export default TurboModuleRegistry.get<Spec>('Foo');
```

It will fail:

```
Enum values can not be mixed. They all must be either blank, number, or string values.
```

This is because negative values are parsed as `UnaryExpressions` which have `-` operator in front and value as argument.

With the new approach codegen properly generates enums with negative values.

## Changelog:

[GENERAL] [ADDED] - Codegen: Support negative values in enums

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

Test Plan: I've added tests to see if everything is working properly

Reviewed By: vzaidman

Differential Revision: D65887888

Pulled By: elicwhite

fbshipit-source-id: edb25f663dc58afa68c69cb84a47cfc67fc1f7e7
2024-11-13 12:20:16 -08:00
Zeya Peng
08759121cd validate input before calling setSelection to restore selection range (#47577)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47577

Changelog: [Android][Fixed] ensure setSelection in onAttachedToWindow is within text range

Reviewed By: javache

Differential Revision: D65824906

fbshipit-source-id: 3dc7d27bf4f9a10762f11fa4a0bcae8af13c7db7
2024-11-13 11:38:02 -08:00
Edmond Chui
05367de5e6 Update debugger-frontend from ff343d8...b61aae3 (#47593)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47593

Changelog: [Internal] - Update `react-native/debugger-frontend` from ff343d8...b61aae3

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](ff343d8055...b61aae3ccc).

Reviewed By: huntie

Differential Revision: D65894096

fbshipit-source-id: e2fd4bff7d643fc56abde2ddea0ef5fab91d2b4d
2024-11-13 11:27:38 -08:00
Pieter De Baets
3da23f7093 Unbreak legacy ReactFontManager (#47585)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47585

We have two classes named ReactFontManager and during the Kotlin migration this got mixed up.

Changelog: [Android][Fixed] Fixed crash in legacy ReactFontManager

Reviewed By: fabriziocucci

Differential Revision: D65877606

fbshipit-source-id: d9dc4f29045ad377adb216216334af5501c5546e
2024-11-13 09:29:35 -08:00
Mateo Guzmán
32931466ed feat(text-input): [iOS] inputAccessoryViewButtonLabel prop (#47441)
Summary:
Fixes https://github.com/facebook/react-native/issues/29244, also mentioned in https://github.com/facebook/react-native/issues/25009

As mentioned in the linked issues, the current return key label in the input accessory view is not localized. In the code, right now the texts are hardcoded (see: [RCTTextInputComponentView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L552) and [RCTBaseTextInputView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L694)). I could not find the historical reason for this, but doing some investigation there doesn't seem to be a way of getting the translated text into the code by using the existing props. (Ref: https://stackoverflow.com/a/58190342/5415299)

The solution: adding a new property `inputAccessoryViewButtonLabel` which can be used to overwrite these defaults non-translated values. The property is optional to avoid breaking changes.

The implementation works for both Fabric and Paper.

## Changelog:

[IOS] [ADDED] - TextInput `inputAccessoryViewButtonLabel` prop

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

Test Plan:
A new example has been added under the `TextInput` examples in the RNTester. See below:

<details>
<summary>Video demonstrating how the new prop behaves</summary>

https://github.com/user-attachments/assets/b15cb8b8-494a-4f41-b434-e33eeef5d267

</details>

Reviewed By: cipolleschi

Differential Revision: D65533493

Pulled By: javache

fbshipit-source-id: d80bf501ba3e38bf3b09833170780df45a26bb61
2024-11-13 06:44:23 -08:00
Eric Rozell
fc24171416 Revert "Extra log for case where availableHeight is undefined and sizing mode != max content (#1687)" (#47581)
Summary:
X-link: https://github.com/facebook/yoga/pull/1741

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

Reverting https://github.com/facebook/yoga/pull/1687 as it appears to regress Yoga performance anywhere from 10-33%.

## Changelog

[Internal]

Reviewed By: rshest

Differential Revision: D65863569

fbshipit-source-id: e6992e05dd59ba75548a5d633cb7f5c3fa99a6e4
2024-11-13 06:29:35 -08:00
Pieter De Baets
9fa4845136 Change default for bridgeless-init related feature flags (#47567)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47567

Changelog: [Android][Changed] Invocations to JS will now invoke their callbacks immediately if the instance is ready. Surface starts will not wait for the main thread to become available to dispatch the work in JS.

Reviewed By: rshest

Differential Revision: D65661888

fbshipit-source-id: c67802bd56fac6bc6c145b96d823274e2b97de69
2024-11-13 04:00:19 -08:00
Pieter De Baets
663b5f9d19 Change feature flag default for initEagerTurboModulesOnNativeModulesQueueAndroid (#47566)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47566

Changelog: [Android][Changed] TurboModules marked as requiring eager init will now be constructed on the mqt_native thread to increase concurrency in React Native init.

Reviewed By: rshest

Differential Revision: D65661887

fbshipit-source-id: c1863ea44771de5caedc2968a325abcc7022c792
2024-11-13 04:00:19 -08:00
David Vacca
dc8c2f676e Annotate BridgeReactContext as VisibleForTesting (#47579)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47579

BridgeReactContext is public only for testing. I'm annotating it with VisibileForTesting to make it explicit

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65705093

fbshipit-source-id: d4d7c4195926e2d0397e805b4c49b0710a82a7eb
2024-11-12 23:20:52 -08:00
Rubén Norte
d3c5446a6e Clean up legacy feature flags for event loop (#47565)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47565

Changelog: [internal]

We unified the feature flags for the event loop in https://github.com/facebook/react-native/pull/47084, but we left the legacy flags defined for temporary backwards compatibility.

We don't need that anymore, so we can clean them up.

Reviewed By: fabriziocucci

Differential Revision: D65606068

fbshipit-source-id: 403c278cef2afc8eddf07592d88cadc58765f660
2024-11-12 12:43:11 -08:00
Mateo Guzmán
a0be88fd72 feat(image): [android] adding force-cache cache control option (#47426)
Summary:
This PR follows up on https://github.com/facebook/react-native/issues/47182 and https://github.com/facebook/react-native/issues/47348 by adding `force-cache`, the final missing option to align caching controls with the existing behavior on iOS.

Local caching behavior remains unchanged: if a cached image is available locally, it will be returned; otherwise, a network request will be made.

When an image request is sent over the network, the `force-cache` option sent from the sent fJS side will now use the `okhttp3.CacheControl.FORCE_CACHE` directive.

## Changelog:

[ANDROID] [ADDED] - Image `force-cache` caching control option

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

Test Plan:
New example added to the RNTester under the cache policy examples. Then inspecting that the cache control is set correctly before sending it in the `okhttp3.Request` builder.

```kt
FLog.w("ReactNative", "fetching uri: %s, with cacheControl: %s", uri, cacheControlBuilder.build().toString())
// fetching uri: https:...png?cacheBust=force-cache, with cacheControl: no-store, max-stale=2147483647, only-if-cached
```

This case was a bit more tricky to test in terms of e2e as it would involve some caching in the server as well, I'm open to suggestions to make this more complete.

Reviewed By: javache

Differential Revision: D65490360

Pulled By: Abbondanzo

fbshipit-source-id: f807a9793f85caea39c59a370d057b9a1d450a78
2024-11-12 10:44:09 -08:00
BIKI DAS
c69e330324 Dispatch onMomentumScrollEnd after programmatic scrolling (#45187)
Summary:
in iOS on a scroll generated programatically, the `onMomentScrollEnd` is fired, though in case of android the same does not happen, this PR tries to implement the same behaviour for android as well, while diving through the code it seems we have two extra `onMomentumScrollEnd` events. Only one event should be fired.

**iOS Behaviour on Programmatic Scroll**

https://github.com/facebook/react-native/assets/72331432/fb8f16b1-4db6-49fe-83a1-a1c40bf49705

https://github.com/facebook/react-native/assets/72331432/9842f522-b616-4fb3-b197-40817f4aa9cb

**Android Behaviour on Programmatic Scroll**

https://github.com/facebook/react-native/assets/72331432/c24d3f06-4e2a-4bef-81af-d9227a3b1a4a

https://github.com/facebook/react-native/assets/72331432/d4917843-730b-4bd7-90d9-33efb0f471a7

If closely observed we can see the `onMomentumScrollEnd` does not gets called in Android unlike to iOS.

## Changelog:

[Android][Fixed] - Dispatch onMomentumScrollEnd after programmatic scrolling

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

Test Plan:
i have added updates to the FlatList example and ScrollViewSimple
here is a ScreenRecording of `onMomentumScrollEnd` firing in android after the code changes

https://github.com/facebook/react-native/assets/72331432/f036d1a5-6ebf-47ba-becd-4db98a406b15

https://github.com/facebook/react-native/assets/72331432/8c788c39-3392-4822-99c5-6e320398714b

Reviewed By: javache

Differential Revision: D65539724

Pulled By: Abbondanzo

fbshipit-source-id: f3a5527ac5979f5ec0c6ae18d80fdc20c9c9c14b
2024-11-12 10:37:16 -08:00
Fabrizio Cucci
6f59627903 Migrate com.facebook.react.views.text.ReactRawTextManager to Kotlin (#47571)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47571

As per title.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65600851

fbshipit-source-id: cd88beca23f5d7b1036354457e67d0d530e62a95
2024-11-12 08:30:35 -08:00
Riccardo Cipolleschi
fe1057afcd Let lib maintainer be explicit with componentProvider mapping (#47520)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47520

Right now, when a 3p library needs to register a component in the component system, we have to crawl the library to try and get the mappng, best effort.

With this approach, we are enriching the `codegenConfig` property to allow library developers to define the mapping themselves.

For example:
```json
//...
"codegenConfig": {
    //..
    "ios": {
      "componentProvider": {
        "RNTMyNativeView": "RNTMyNativeViewComponentView"
      }
    }
  },
```
means that the JS component `RNTMyNativeView` will be mapped to the `RNTMyNativeViewComponentView` class.

This also work for local apps, and it warns the users about what libraries are using the deprecated approach, so they can open an issue or a PR to those libraries.

## Changelog:
[iOS][Added] - Allow 3p developers to specify the association between components and classes in Fabric

Reviewed By: dmytrorykun

Differential Revision: D65666061

fbshipit-source-id: 692e753635873ff9260e131d2d18ed226b2378c2
2024-11-12 07:38:03 -08:00
Riccardo Cipolleschi
8becc2514d Generate RCTThirdPartyComponentProvider (#47518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47518

This change reintroduce the generation of the `RCTThirdPartyComponentProvider` but in the right place and with the right patterns.

1. We are generating it in the user space, not in the node_modules (fixes the circular dependency)
2. We are not using weak function signature that have to be implicitly linked to some symbols found during compilation

The change needs to crawl the folder to retrieve the information it needs. We need to implement it this way not to be breaking with respect of the current implementation.

The assumption is that components have a function in their `.mm` file with this shape:
```objc
Class<RCTComponentViewProtocol> <componentName>Cls(void)
{
  return <ComponentViewClass>.class;
}
```
I verified on GH that all the libraries out there follow this pattern.

A better approach will let library owner to specify the association of `componentName, componentClass` in the `codegenConfig`.

We will implement that as the next step and we will support both for some versions for backward compatibility.

## Changelog
[iOS][Changed] - Change how components automatically register

Reviewed By: dmytrorykun

Differential Revision: D65614347

fbshipit-source-id: a378b8bc31c1ab3d49552f2f6a4c86c3b578746b
2024-11-12 07:38:03 -08:00
Riccardo Cipolleschi
60b9d3d89e Stop generating RCTThirdPartyLibraryComponentProvider (#47517)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47517

The `RCTThirdPartyLibraryComponentProvider` has been introduced to automate the component registration of third party libraries in the apps. However, it has some serious flaws:

* It is generated in the React/Fabric folder, which means that it is generated in node_modules
* It is generated when the user installs the components in the app, which means that we can't prebuild and redistribute React Native as a binary
* it does not work with Frameworks and dynamic linking: in this scenarion, Fabric must build in isolation and if there are third party libraries involved, the lookup of the `xxxCls` function will fail

This change removes the generation of the `RCTThirdPartyLibraryComponentProvider`. In the next diffs we will implement a different mechanism to register components

## Changelog
[iOS][Changed] - Stop generating the RCTThirdPartyLibraryComponentProvider

Reviewed By: dmytrorykun

Differential Revision: D65601939

fbshipit-source-id: 9cc8c46102827d124b93b8aa6705b5e6014695c1
2024-11-12 07:38:03 -08:00
dan
62a4e46551 Fix blog post link (#47560)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47560

Reviewed By: elicwhite

Differential Revision: D65790732

Pulled By: rickhanlonii

fbshipit-source-id: 7156f85c7525cec31aa80fb0757d853d517bbef8
2024-11-12 07:19:57 -08:00
Alex Hunt
1e5286866a Configure unstable-react-profiling build mode (#47028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47028

This is a mostly internal diff enabling us to selectively enable Fusebox in release builds (experimental).

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D64110061

fbshipit-source-id: a5f5d59d7a512bb47603cf83fd60f2c2202c22ab
2024-11-12 06:55:53 -08:00
Fabrizio Cucci
a78a5af657 Migrate com.facebook.react.views.text.ReactTextUpdate to Kotlin (#47553)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47553

As per title.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65598615

fbshipit-source-id: c4f0e137e3ff350b263f5ce11dd61b78a5be9894
2024-11-12 05:15:32 -08:00
Eli Front
594c9d9a46 Add void prototype to RCTAppearance.h (#47564)
Summary:
Resolve warning on ios build:
```
.../ios/Pods/Headers/Public/React-Core/React/RCTAppearance.h:16:60 A function declaration without a prototype is deprecated in all versions of C
```

## 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] - Resolve deprecated function prototype warning in RCTAppearance.h

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

Test Plan:
Jest Result (`yarn test`):
```
Test Suites: 234 passed, 234 total
Tests:       2 skipped, 4899 passed, 4901 total
Snapshots:   1687 passed, 1687 total
Time:        46.387 s
Ran all test suites.
```

Reviewed By: cipolleschi

Differential Revision: D65816584

Pulled By: javache

fbshipit-source-id: 212021c39dfde7e638752940e67a9f964d2194ab
2024-11-12 05:15:23 -08:00
zhongwuzw
8cbc7c3357 Fixes rn-tester bundled images examples (#44482)
Summary:
Fixes rn-tester bundled images example

Before:
![image](https://github.com/facebook/react-native/assets/5061845/d33ae01b-f1de-4918-882e-b01be7e1df6f)
After:
![image](https://github.com/facebook/react-native/assets/5061845/19ff2702-e7b3-4cb0-b48b-46c270b1114d)

## Changelog:

[IOS] [FIXED] - Fixes rn-tester bundled images examples

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

Test Plan: N/L

Reviewed By: dmytrorykun

Differential Revision: D65757405

Pulled By: cipolleschi

fbshipit-source-id: 29a82acacee58d803f2bfea93444adae6aee1b79
2024-11-12 04:18:17 -08:00
Ramanpreet Nara
16eb53befa Integrate DevSupportManager into activity lifecycle (#47531)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47531

When the activity is paused, or destroyed, we should disable the devsupportmanager. (This performs cleanup).

When the activity is resumed, we should re-enable devsupportmanager. (This performs re-initialization).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D65689053

fbshipit-source-id: 99de0906b8cdc84f56b4d334ac0eeecc7b436dd5
2024-11-11 13:24:49 -08:00
Ramanpreet Nara
a2959a915c earlyjs: Reset error handler state after js pipeline fails (#47528)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47528

After the js pipeline fails to handle the error, reset the hasHandledFatalError var.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D65678387

fbshipit-source-id: ac7cd4724954ea78bf33542e208c5f5d3dba5383
2024-11-11 13:24:49 -08:00
Ramanpreet Nara
ca7b9e9509 earlyjs: Extend C++ pipeline for non-js errors (#47529)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47529

RuntimeExecutor, RuntimeScheduler, etc. can execute arbitrary c++ on the javascript thread.

If that c++ throws a non-jsi::JSError, it will bypass the js error handler (and start tearing down the react instance 😱).

Let's have the js error handler manage all exceptions raised while native is calling into js. This is more sane.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D64626610

fbshipit-source-id: 40132f24b4e2737ae3f055fbd09153111404e5bf
2024-11-11 13:24:49 -08:00
Mateo Guzmán
998ab262ea fix(rn-tester): pixel ratio example inputs not fully visible in dark mode (#47526)
Summary:
Found this small dark mode issue when navigating into the `PixelRatioExamples`

## Changelog:

[INTERNAL] [FIXED] - Fixing dark mode inputs for `PixelRatio` examples

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

Test Plan:
| Before  | After |
  | ---------- | ---------- |
  | ![Screenshot_1731090926](https://github.com/user-attachments/assets/9e20c44e-0152-4760-a436-3272b452a6a2) | ![Screenshot_1731090971](https://github.com/user-attachments/assets/17d038a8-b383-4c96-a30d-c7d213cc6f97) |

Reviewed By: lunaleaps

Differential Revision: D65735837

Pulled By: Abbondanzo

fbshipit-source-id: 5b0dc6d0ae45778723a92581cef00ce7ec4c56f1
2024-11-11 10:58:56 -08:00
Peter Abbondanzo
5b609cca09 Fix onMomentumScrollBegin not dispatching from animations (#47468)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47468

Across our scroll view implementations on iOS, we fire `onMomentumScrollEnd` whenever the scroll view finishes decelerating, whether it comes from a user's touch or call to `setContentOffset` with animations. But we omit dispatching the `onMomentumScrollBegin` event in the latter cases.

This change updates both old and new architecture to dispatch `onMomentumScrollBegin` when a view-command-driven scroll occurs with animation, like `scrollTo` or `scrollToEnd`.

Changelog:
[iOS][Fixed] - Fixed `onMomentumScrollBegin` event not firing on command-driven scroll events

Reviewed By: javache

Differential Revision: D65556000

fbshipit-source-id: bc4b778c63d8a032e1d8e00b9d4d5f83a5d651d6
2024-11-11 10:12:33 -08:00
Mateo Guzmán
6295b81e79 test(image): [android] adding missing image resize mode test cases (#47527)
Summary:
Follow up from https://github.com/facebook/react-native/issues/47433, adding some missing scenarios in the unit tests for the image component in Android.

## Changelog:

[INTERNAL] [ADDED] - Improving Android `ImageResizeMode` unit tests

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

Test Plan:
```bash
yarn test-android
```

Reviewed By: fabriziocucci

Differential Revision: D65735794

Pulled By: Abbondanzo

fbshipit-source-id: a420274c78d9eadf0439870cfaae4d16247c6034
2024-11-11 07:38:59 -08:00
oddlyspaced
e70202e606 feat(Android): add support for detecting grayscale mode enabled on android (#47497)
Summary:
On android the isGrayScaleEnabled method of AccessibilityInfo always returns false due to missing implementation. This PR fills the gap by providing the native module logic for checking grayscale mode.

## Changelog:
- Added native module code to check for grayscale mode on android
- Updated js accessibility info module  to return the correct promise instead of default false for isGrayScaleEnabled()
- Moved the test for isGrayScaleEnabled() out of ios scope to common Android and iOS scope

[ANDROID] [ADDED] - logic to check for grayscale mode on android

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

Test Plan:
Tested on :
- Google Pixel 7 Pro (Android 14)
- OnePlus 12 (Android 14)
- Pixel 6 (Android 15)

Reviewed By: cortinico

Differential Revision: D65662583

Pulled By: javache

fbshipit-source-id: 39f9ce37c9375b5380257847395393045eedbadc
2024-11-11 07:38:21 -08:00
Pieter De Baets
2c31fe99e1 Use rval for AttributedString::Fragment changes (#47494)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47494

Changelog: [General][Changed] AttributedString `appendFragment` and `prependFragment` take an rval instead of a const ref; append/prependAttributedString have been removed

Reviewed By: mdvacca

Differential Revision: D65603864

fbshipit-source-id: 1160a9e2064470f826bea66736b4fce13caa3a73
2024-11-11 07:35:20 -08:00
David Vacca
3a4493f4c4 Migrate UnobservedErrorNotifier to kotlin (#47538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47538

Migrate UnobservedErrorNotifier to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65738328

fbshipit-source-id: 651caecfbbe01d52aeac371f4427665c34b85107
2024-11-11 07:03:00 -08:00
David Vacca
94839ed174 Migrate UnobservedTaskException to kotlin (#47542)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47542

Migrate UnobservedTaskException to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65738327

fbshipit-source-id: 251f8ee55497328212ce3facab7a4686fa1a29c8
2024-11-11 07:03:00 -08:00
David Vacca
4f55161132 Internalize TaskCompletionSource class (#47543)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47543

TaskCompletionSource is public but it shouldn't, in this diff I'm making it intenral

changelog: [Android][Breaking] Reduce visibility of TaskCompletionSource class

Reviewed By: javache

Differential Revision: D65738324

fbshipit-source-id: 61db35a408162c53398b20e45a52f3eb46de1eae
2024-11-11 07:03:00 -08:00
David Vacca
a4eb5794cc Migrate TaskCompletionSource to kotlin (#47541)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47541

Migrate TaskCompletionSource to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65738330

fbshipit-source-id: 34963ae4a95dbea2fcebbdaa33436e22a7ca4751
2024-11-11 07:03:00 -08:00
David Vacca
7b21b9e69c Internalize Continuation (#47540)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47540

Continuation is only used inside RN, we should make it internal

changelog: [Android][Changed] Reduce visibility of Continuation to internal, although this interface wasn't being exposed in any public API

Reviewed By: javache

Differential Revision: D65738329

fbshipit-source-id: 6fb1b9e9a253eafad0f6eb1e4c1363d6254846da
2024-11-11 07:03:00 -08:00
David Vacca
b8337ebf97 Migrate Continuation to kotlin (#47537)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47537

Migrate Continuation interface to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65738326

fbshipit-source-id: 1a119f6d349101951dc528583f3dbaf5441da91e
2024-11-11 07:03:00 -08:00
David Vacca
17b69795c3 Migrate ExecutorException to kotlin (#47539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47539

Migrate ExecutorException to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D65738325

fbshipit-source-id: 0ae6adedf0f80d57426ebc749fd77c31942b3b47
2024-11-11 07:03:00 -08:00
David Vacca
443bc32dc4 Update KDocs for ReactHost.destroy() methods (#47536)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47536

I'm updating KDoc for ReactHost.destroy() methods to warn about potential deadlock when waiting for completion

changelog: [Android][Changed] update documentation for ReactHost.destroy() APIs

Reviewed By: shwanton

Differential Revision: D65734396

fbshipit-source-id: b7924cafce2fd58e2633736f922d303c61f6ad14
2024-11-11 07:03:00 -08:00
Samuel Susla
685facfd53 fix race condition in EventBeat (#47548)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47548

changelog: [internal]

This race condition only shows itself with flag `useOptimizedEventBatchingOnAndroid`

# Problem
EventBeat assumes method `induce` will be called repeatedly on every UI tick. This is true for iOS and existing implementation of event beat on Android. The first early exist inside of `induce` method is built with this assumption.

`useOptimizedEventBatchingOnAndroid` on Android changes this. `induce` will only be called after FabricUIManager.onRequestEventBeat is invoked and then it will stop. For one `FabricUIManager.onRequestEventBeat` call, `EventBeat::induce` is called once. And there is a chance for race condition.

Here is a simplified implementation of `induce`. This method may be called many times in sequence. The caller will set [isRequested_](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/renderer/core/EventBeat.cpp#L25) and then invoke [FabricUIManager.onRequestEventBeat](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/jni/react/fabric/AndroidEventBeat.cpp#L43). Notice how `FabricUIManager.onRequestEventBeat` is debounced if `isRequested_` flag is true.

```
void EventBeat::induce() const {
  if (!isRequested_ || isBeatCallbackScheduled_) {
   // isRequested_ is not set to false in case isBeatCallbackScheduled_) is true.
    return;
  }

  isRequested_ = false;
  isBeatCallbackScheduled_ = true;

  auto beat = std::function<void(jsi::Runtime&)>(
    // on JS queue
    isBeatCallbackScheduled_ = false;
    // beatCallback_(runtime)
  }

  runtimeScheduler_.scheduleWork(std::move(beat));
}
```

This can get into a state where `isRequested_` is not reset back to false even though `EventBeat::induce` is called when `isBeatCallbackScheduled_` is true.

`AndroidEventBeat::request` -> `isRequested_` is set to true -> `FabricUIManager::onRequestEventBeat` -> `EventBeat::induce` -> `isRequested_` is set to false -> `isBeatCallbackScheduled_` is set to true -> `AndroidEventBeat::request` -> `FabricUIManager::onRequestEventBeat` -> `EventBeat::induce` (early exit because `isBeatCallbackScheduled_` is true) -> `beat` is executed on the JS thread.

From this point on, subsequent calls to `AndroidEventBeat::request` are always debounced because flag `isRequested_` is true.

Any subsequent event on Android will end up calling `EventBeat::induce` and the mechanism gets unstuck.

# The fix

The fix is simple, any time `EventBeat::induce` is called, make sure `request_` flag is set to false. This then satisfied the expectation of `useOptimizedEventBatchingOnAndroid` optimisation.

Reviewed By: rubennorte

Differential Revision: D65566258

fbshipit-source-id: 5f15da8f5cb722b329f9f72b9ddca8e2cac04144
2024-11-11 07:01:53 -08:00
Rubén Norte
d7cb6d95a8 Clean up forceBatchingMountItemsOnAndroid feature flag (#47546)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47546

Changelog: [internal]

Cleaning up the feature flag as we've tested it's safe to land.

Reviewed By: javache

Differential Revision: D65749504

fbshipit-source-id: 964db7e9c31ebb8d7e4f7e2703a3040709c6ed6e
2024-11-11 06:05:28 -08:00
Samuel Susla
6c577e96db remove unused import and declaration in EventQueue (#47545)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47545

changelog: [internal]

Reviewed By: javache

Differential Revision: D65663098

fbshipit-source-id: b0a848de9ef01e2915a945a58a08e2e9c666a116
2024-11-11 05:27:44 -08:00
Riccardo Cipolleschi
97a4234b6e Fix Typo and skip generation of app-specific component registration (#47547)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47547

In [#47176](https://github.com/facebook/react-native/pull/47176) we disabled the generation of the component registration for app specific components as it was creating a circular dependency between the app and React Native.

However, we made a couple of typos that make it not work as expected and users picked up those typos soon.

This change fixes them for good.

## Changelog
[iOS][Fixed] - Properly stop generating component registration for components defined in app.

Reviewed By: blakef

Differential Revision: D65750433

fbshipit-source-id: 1a879c5be014905558b9fd05e6f16ac36b784ed6
2024-11-11 04:55:23 -08:00
Fabrizio Cucci
9db28834e2 Migrate com.facebook.react.views.text.ReactTextViewManagerCallback to Kotlin (#47516)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47516

As per title.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65598258

fbshipit-source-id: 0ef7e9a4aefcb021bc55698eaf43c2a69bbb4f63
2024-11-11 02:49:09 -08:00
Pieter De Baets
a9a1c86a92 Convert com.facebook.react.bridge.ReactSoftExceptionLogger to Kotlin (#47513)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47513

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65602362

fbshipit-source-id: 95e63bd04480c1c8a364fcf93d24f71f94057d65
2024-11-10 14:08:35 -08:00
David Vacca
b60e36390c Introduce ReactHost.destroy() method to notifies when the React instance is destroyed (#47534)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47534

This diff is introducing a new method to destroy React instance that allows the caller to be notified when the destroy finishes

This is necessary for apps to act upon destroy of the react instance

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D65721107

fbshipit-source-id: 2d3d9755db38461ba381b86c72df5869c542379b
2024-11-10 09:30:58 -08:00
Yedidya Feldblum
ae43411008 let Value be nothrow-move-constructible (#47422)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47422

Reviewed By: Gownta

Differential Revision: D65273055

fbshipit-source-id: 6fda316137b1f797b8b4041521555e46e1098e7c
2024-11-10 02:42:41 -08:00
D N
44d619414c fix: Remove BackHandler.removeEventListener (#45892)
Summary:
All `removeEventListener` methods was removed  2596b2f695 perviously  but seems a `BackHandler` was missed

This can be a breaking change for some third-party modules.

**Migration**: Use `remove` on the EventSubscription from `addEventListener`:

```diff
useEffect(()=>{
+  const subscription = NativeModule.removeListener(name, listener);
+  return ()=>subscription.remove();
},[])
```

## Changelog:

[GENERAL] [REMOVED] - Remove `BackHandler.removeEventListener`

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

Test Plan: ...

Reviewed By: huntie

Differential Revision: D65663591

Pulled By: javache

fbshipit-source-id: 01b804cd6ec77ea4916a0ced7fee551d045f1684
2024-11-09 15:56:44 -08:00
David Vacca
3e27ef1f6e Deprecate CatalystInstance in old architecture (#47383)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47383

CatalystInstance is deprecated and will be removed in new architecture

changelog: [Android][Changed] Deprecate CatalystInstance in old architecture

Reviewed By: cortinico

Differential Revision: D65430643

fbshipit-source-id: 96ba91c45760ead8155f9f28b6fad523be75929e
2024-11-08 20:40:18 -08:00
Thomas Nardone
7794d7af43 Add TextTransform KTX (#47525)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47525

This API is awkward for nullsafe code.  Adding an extension allows Kotlin code to use `applyTextTransform()` on either nullable or non-null strings:
```
val a: String = string.applyTextTransform(...)
val b: String? = nullableString?.applyTextTransform(...)
```
Changelog:
[Android][Added] TextTransform ktx

Reviewed By: javache

Differential Revision: D65618709

fbshipit-source-id: 28a0fe61a0eaf27aa9677af39d932982f3b694b2
2024-11-08 16:14:37 -08:00
David Vacca
34c157f6b3 Undeprecate UIManagerProvider in the new architecture (#47386)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47386

UIManagerProvider is actually useful to decouple client code from the FabricUIManagerClass
that's why I'm removing the DeprecatedInNewArchitecture annotation

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D65430644

fbshipit-source-id: 46e95b9e40e99dd9ec6df9f2d51b1fa3d3d77d27
2024-11-08 16:13:17 -08:00
Sam Zhou
cd9ece0553 Pre-suppress errors ahead of turn on partial react 19 ref-as-prop support
Summary:
`react.ref_as_prop=experimental.partial_support` will expose errors where a ref prop is passed to a function component without ref prop. This diff pre-suppresses the newly exposed errors.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D65686695

fbshipit-source-id: f241cc40f3ac414a2960dec60d9ba4633e5f93c0
2024-11-08 13:52:27 -08:00
Pieter De Baets
2f7957f2fd Merge RawText sequences (#47278)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47278

When we have multiple spans of text inside a <Text> element, React will emit these as separate RawText ShadowNodes. RawText shadow nodes cannot have any properties beyond the text they contain, yet our current AttributedText logic will generate a separate span for each and duplicate all the relevant properties.

This can be particularly inefficient when JSX is used to interpolate strings, e.g. `<Text styles={styles.text}>Example {i}/{count}</Text>` results in 4 raw text elements with duplicated properties.

Changelog: [General][Changed] Improved AttributedText generation for raw text nodes.

Reviewed By: NickGerleman

Differential Revision: D65134912

fbshipit-source-id: dba4296ebe9987e989760cdee66f1e076fbb7a98
2024-11-08 11:32:51 -08:00
Jakub Piasecki
ee7b4e2763 Fix timers in headless tasks on bridgeless mode (#47496)
Summary:
Fixes https://github.com/facebook/react-native/issues/47495

`JavaTimerManager` is being registered to receive headless tasks events in the [`TimingModule`](0ee963ea65/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.kt (L28-L29)). This module is not used on bridgeless: [1](0ee963ea65/packages/react-native/Libraries/Core/setUpTimers.js (L44-L61)), [2](0ee963ea65/packages/react-native/Libraries/Core/setUpTimers.js (L123-L132)) and since it's loaded lazily, the event listener is never registered.

This PR moves registration to the constructor of `JavaTimerManager` and deregistration to the `onInstanceDestroy` method. This way the event listener is always registered when an instance of the timer manager exists.

## Changelog:

[ANDROID] [FIXED] - Fix timers in headless tasks on bridgeless mode

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

Test Plan: See the reproducer from the issue

Reviewed By: javache

Differential Revision: D65615601

Pulled By: alanleedev

fbshipit-source-id: 6e1d36f8783e813065f79730a928b99c3e385718
2024-11-08 11:07:26 -08:00
Pieter De Baets
e3c3a0c8a7 Migrate NativeModuleRegistryBuilder to Kotlin (#47508)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47508

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D60037204

fbshipit-source-id: 2b405e492520e075b83a075009d25fb7b7fa8925
2024-11-08 10:37:37 -08:00
Pieter De Baets
2ec547ad28 Remove concurrentRoot from initialProps (#47512)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47512

As can be seen in `renderApplication`, `useConcurrentRoot` is no longer used to decide whether to run the application in concurrent mode, as we default all Fabric-users to concurrent root.

Changelog: [General][Removed] Removed type for useConcurrentRoot from AppRegistry, as it was already ignored

Reviewed By: sammy-SC, fabriziocucci

Differential Revision: D65660681

fbshipit-source-id: c99e5ae14d515015709908ed21a854c780f628e0
2024-11-08 10:26:50 -08:00
Tim Yung
090501d26d RN: Enable scheduleAnimatedEndCallbackInMicrotask (#47503)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47503

Enables the `scheduleAnimatedEndCallbackInMicrotask` feature flag that was introduced in https://github.com/facebook/react-native/pull/46714.

Changelog:
[General][Changed] - Callbacks passed to `animation.start(<callback>)` will be scheduled for execution in a microtask. Previously, there were certain scenarios in which the callback could be synchronously executed by `start`.

Reviewed By: javache

Differential Revision: D65645981

fbshipit-source-id: ac159208b7c1df60549baa52704bb0e704da0acf
2024-11-08 10:22:12 -08:00
Pieter De Baets
105f5f6000 Convert exceptions in com.facebook.react.bridge to Kotlin (#47493)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47493

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65597240

fbshipit-source-id: 8014c756d7730bea617f6d27eb1e56d75c9156cf
2024-11-08 09:31:12 -08:00
Alex Hunt
63ec67c591 Exclude Libraries/ReactPrivate/ from public-api-test
Summary:
As titled. This API is legacy / Meta-only.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D65666574

fbshipit-source-id: f9700486aec0306b305910bff14ae7f3df3fab7f
2024-11-08 09:16:21 -08:00
Sam Zhou
f5d7df6672 Pre-suppress errors to prepare for flow typing changes
Summary: Changelog: [Internal]

Reviewed By: cyan33

Differential Revision: D65633359

fbshipit-source-id: 7aaee2cab2d61b61eb5e1317d6b4ce58b6191fb8
2024-11-08 08:39:06 -08:00
Nicola Corti
7e268c9d52 Revert React 19RC to React 18.3.1 (#47380)
Summary:
While we're waiting for 19 stable, let's bring main back to 18.3.1 ahead of the 0.77 branch cut. We'll land this change just after 19 stable lands.

This is a cherry pick of b93b378fa0 which landed in 0.76 already

bypass-github-export-checks

## Changelog:

[INTERNAL] - Revert React 19RC to React 18.3.1

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

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D65430775

Pulled By: cortinico

fbshipit-source-id: f0f211754c8ffe5d037fd299e4de52c29d1d7913
2024-11-08 08:27:37 -08:00
Pieter De Baets
8cb2ad6725 Improve robolectric shadows (#47460)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47460

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D65538979

fbshipit-source-id: 7a0b0f701968a9af9197246e6e89e0ccfd55653d
2024-11-08 06:14:13 -08:00
Fabrizio Cucci
697a422bf5 Migrate com.facebook.react.views.text.FontMetricsUtil to Kotlin (#47510)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47510

As per title.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65598073

fbshipit-source-id: 401750f2df9bd434a8310f107f46a686bfa6601c
2024-11-08 06:10:22 -08:00
Nicola Corti
e64513bf4e RNGP - Do not attempt to substring to 1024 while logging. (#47509)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47509

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

Changelog:
[Android] [Fixed] - RNGP - Do not attempt to substring to 1024 while logging

Reviewed By: javache

Differential Revision: D65659586

fbshipit-source-id: 8fa16131cea96b8b6aa9c0224c7b990a4f51175f
2024-11-08 04:57:15 -08:00
Pieter De Baets
3c32da5bfe Convert com.facebook.react.bridge.NativeArray to Kotlin (#47456)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47456

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D65486257

fbshipit-source-id: d18d38fd7e605918d79e370dda7df51abac2f23c
2024-11-08 04:31:46 -08:00
Pieter De Baets
fd72537202 Convert com.facebook.react.bridge.JavaOnlyArray to Kotlin (#47424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47424

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D65479614

fbshipit-source-id: d2ab86eb0e8c68a5733c602652b4b8dccc09a0a1
2024-11-08 04:31:46 -08:00