Commit Graph

12270 Commits

Author SHA1 Message Date
Alex Taylor (alta) cbdb4d78c0 Update hermes-parser and related packages in fbsource to 0.23.0 (#45504)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45504

Bump hermes-parser and related packages to [0.23.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D59881428

fbshipit-source-id: cf8d055b3a1078895fc16ec3da26981eabc22db7
2024-07-18 13:52:22 -07:00
zhongwuzw 14de1b708a Fabric: Fixes Modal present splash when animation type is none (#41853)
Summary:
Because the modal layout is triggered by state,  it's an async operation after the first mount, so we can see the splash when present modal. now we can pass the screen size to the initial state which can layout in the first mount operation.

before:
https://github.com/facebook/react-native/assets/5061845/a39d519e-e2f6-42f1-8319-6216c88e9cf3

After:
https://github.com/facebook/react-native/assets/5061845/c7d59820-399b-4ea2-943d-d889971ea7ee

## Changelog:

[IOS] [FIXED] - Fabric: Fixes Modal present splash when animation type is none

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

Test Plan: RNTester Modal example, present modal in none animation mode.

Reviewed By: sammy-SC

Differential Revision: D51984766

Pulled By: cipolleschi

fbshipit-source-id: 34a40e75c87f1046ab2e4df45196a277f47bd525
2024-07-18 10:08:50 -07:00
Alexander Blom a37534e6ce Fix data race in BufferedRuntimeExecutor (#45512)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45512

isBufferingEnabled_ can be read (by design) from multiple threads, but
it's not atomic. Make it so.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D59907026

fbshipit-source-id: ffce54a28404148b3e270fa90dfe850a334ca2f0
2024-07-18 08:19:53 -07:00
Oskar Kwaśniewski fbcb8f6b2b fix: Hermes prepare_command fails with space in path (#45316)
Summary:
This PR fixes a case where the user initializes react native in a directory that contains a space.

It was causing pod install to fail because the path to `create-dummy-hermes-xcframework.sh` script wasn't in a string.

## Changelog:

[IOS] [FIXED] - Hermes prepare_command fails with space in path

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

Test Plan:
1. Create a directory with space in path
2. Initialize React Native inside
3. Install pods
4. Check if pod install doesn't fail

Reviewed By: dmytrorykun

Differential Revision: D59912979

Pulled By: cipolleschi

fbshipit-source-id: b2c08d5035a245f8b4d6bfaf562e46d9c5d127b5
2024-07-18 07:23:32 -07:00
Samuel Susla cdd70f0397 cache JNI calls to FabricUIManager::getColor (#45501)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45501

changelog: [internal]

Implement caching for FabricUIManager::getColor. A call to FabricUIManager::getColor takes on average 0.4ms and there can be many of them. The arguments for the call keep repeating in majority of times. Employing a simple caching mechanism here to avoid unnecessary trips via JNI to reduce overhead.

The dependencies in graphics in BUCK are incorrect. I tried to separate this into multiple files and move implementation to .cpp file but this will require a bit of a more restructuring to make it possible.

Reviewed By: mdvacca, dmytrorykun

Differential Revision: D59859754

fbshipit-source-id: 748efce7f0b8c96001b6ac1a4b457b8c9d63fe9c
2024-07-18 07:06:02 -07:00
Rubén Norte 15b8ac8db2 Add support for longer tasks with explicit yielding in LongTask API (#45471)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45471

Changelog: [internal]

This is a React Native specific modification of the Long Tasks API that refines the logic to detect long tasks considering voluntary yielding checks.

In RN, as opposed to Web, we can have a very long task executing in the JS thread without causing any issues to the responsiveness of the app, as long as the task checks whether it should yield in short intervals. In this case, if the app always checks whether it should yield at least once every 50ms, the task will not be considered "long".

Check the new unit tests to see this behavior in practice.

Reviewed By: sammy-SC

Differential Revision: D55647992

fbshipit-source-id: 82ab41173d4d9deee65b8ade2268c40d7f58c6e2
2024-07-18 05:08:58 -07:00
Rubén Norte 64c4e385cb Implement Long Tasks API for PerformanceObserver (#45473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45473

This is a basic implementation of the Long Tasks API (https://w3c.github.io/longtasks/).

It detects and reports long tasks when using the Event Loop (in the modern RuntimeScheduler) when a new feature flag for this purpose is enabled.

This doesn't include attribution information at the moment.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D55491870

fbshipit-source-id: e1ccad9cc6a35073b31230a8cf3a4660ab9a043d
2024-07-18 05:08:58 -07:00
Rubén Norte dffc156ea7 Move timing definitions to a specific target (#45492)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45492

Changelog: [internal]

When testing the changes in https://github.com/facebook/react-native/pull/45473 / D55491870, I saw that the reported time spans for long tasks didn't perfectly align with the long tasks themselves in traces (Perfetto).

Taking a closer look, I realized that I wasn't doing the conversion between times and durations from `chrono` and `DOMHighResTimeStamp` (a `double`) correctly, and we're doing this conversion very often.

This moves the definition of `DOMHighResTimeStamp` to its own library and adds conversion methods to make sure we don't make this mistake in the future.

Reviewed By: rshest

Differential Revision: D59820241

fbshipit-source-id: c123920de56336da384ddc484f6ac9d287724301
2024-07-18 05:08:58 -07:00
Blake Friedman 9aed45a9d9 always proxy to @react-native-community/cli (#45464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45464

Previous work would cause versions >= react-native 0.76 to exit if called through `npx react-native <cmd>`. This was intended to be full deprecated and removed.  The intention was to shift users to calling react-native-community/cli directly.

This change allows commands to be proxied to react-native-community/cli but with no guarantees of success.  It's up to each framework / project to explicitly create that dependency.

This also  provides warnings, which won't go away, suggesting the supported method of calling the community CLI directly.

The outcome is that we're not going to break existing workflows.

closes: #45461

Changelog: [General][Fixed] allow proxying commands from react-native to react-native-community/cli with explicit warning

Reviewed By: cortinico

Differential Revision: D59805357

fbshipit-source-id: 21e23b082a9c709effa050d8e7dd04a40f5ab0e6
2024-07-18 04:48:19 -07:00
Nicola Corti 6e34283ab3 Remove report-app-size (#45483)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45483

We don't really use this functionality and is getting harder to migrate to GHA,
hence I'm removing it.

Changelog:
[Internal] [Changed] - Remove report-app-size

Reviewed By: cipolleschi

Differential Revision: D59822862

fbshipit-source-id: 2d082454aea3b3c5863bd34556a23c2fc847f841
2024-07-18 04:34:32 -07:00
Nicola Corti fcd526d6cc Improve tests for GenerateAutolinkingNewArchitecturesFileTask (#45510)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45510

This is just a quality of life improvement, where we test the C++ autolinking
code generation a bit more.

Changelog:
[Internal] [Changed] - Improve tests for GenerateAutolinkingNewArchitecturesFileTask

Reviewed By: blakef

Differential Revision: D59907847

fbshipit-source-id: e6367cc3b1c01700310437b73bc984e3666b3499
2024-07-18 04:15:44 -07:00
Nicola Corti aaeb7af700 Add react-native.config.js to autolinking lockfiles (#45511)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45511

This adds react-native.config.js to autolinking default lockfiles
so autolinking can account for changes in that file.

Changelog:
[Internal] [Changed] - Add react-native.config.js to autolinking lockfiles

Reviewed By: blakef

Differential Revision: D59907268

fbshipit-source-id: d5893a3f7b4d5d9f6c6c13042aa6866ad16b2ea4
2024-07-18 04:15:44 -07:00
Riccardo Cipolleschi 8408b8bc96 Fix path to node in .xcode.env.local (#43333)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43333

This change fixes https://github.com/facebook/react-native/issues/43285.
Basically, when using a `yarn` alias to install pods, yarn creates a copy of the `node` and `yarn` executables and the `command -v node` command will return the path to that executable.

## Changelog
[iOS][Fixed] - Do not use temporary node when creating the .xcode.env.local

Reviewed By: dmytrorykun

Differential Revision: D54542774

fbshipit-source-id: 3ab0d0bb441988026feff9d5390dcfd10869a1b5
2024-07-18 03:35:50 -07:00
Alex Taylor (alta) 9504e864bc Deploy 0.241.0 to xplat (#45507)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45507

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D59891129

fbshipit-source-id: c1da0730d6c1b52cce5de730b47b3f3c854dff6b
2024-07-18 02:58:25 -07:00
Nick Gerleman c82edec62e FilterPrimitive -> FilterFunction (#45505)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45505

These are filter functions, not primitives. Change the name to be more accurate and easier to understand.

https://drafts.fxtf.org/filter-effects/#filter-functions

changelog: [internal]

Reviewed By: joevilches

Differential Revision: D59793167

fbshipit-source-id: a0ab9bfbcab0c1e17d3094ce6ada44040aaa6afb
2024-07-17 23:22:45 -07:00
Nick Gerleman f96a4c0d5d Camelize filter function names in object notation (#45503)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45503

Kebab case object literals are a pain as an API to give folks. Keep string parsing using the kebab-case web names, like in CSS, but keep object notation camelCase.

This is super super hacked up, and we should burn away all these viewconfig processors as soon as we can.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D59793095

fbshipit-source-id: 888cad31142d7aeed42687ab23c2023ac7e4882d
2024-07-17 20:35:17 -07:00
Nick Gerleman 27c6fcbe72 JS plumbing to get boxShadow into native (#45452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45452

With this we enable <View> to use BoxShadow.

BoxShadow property can be a string as defined on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow

Or it can also be a list of BoxShadow primitives:
```
[
{
  offsetX: 10,
  offsetY: 5,
  color: 'red',
  inset: true,
},
{
  ...
},
]
```

The diff includes:

* Style sheet changes so typing is valid
* Process function to turn boxShadow format into parsed boxShadow primitive
* Test for process function
* View config changes on Android, iOS and ReactNativeStyleAttributes

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D57872933

fbshipit-source-id: 2c5732709959bd996cce2f979549fc95cf2410e2
2024-07-17 20:35:17 -07:00
Joe Vilches 66465fb69d Remove calls to CGColorRelease in box shadow impl (#45488)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45488

In certain cases where the color fails to parse, this code will throw an exception since the underlying color does not exist and we are trying to free it. We do not actually need to even do this, since we obtain the CGColor from a UIColor. The UIColor will manage the memory of the CGColor in this case so we are fine.

Source: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-SW1

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D59819536

fbshipit-source-id: ace4656475e7deecac215acb67cb419141e432ea
2024-07-17 18:27:53 -07:00
Joe Vilches 1e20e49163 Rename "spreadRadius" -> "spreadDistance" (#45481)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45481

We are going with this name as it is more commonly used in the spec and makes more sense since there are no circles involved with spread

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59819180

fbshipit-source-id: cf20c22b11e9ff9935b9f54e28db37d3ea399d8f
2024-07-17 18:27:53 -07:00
Thomas Nardone b10724890e View recycling - fix API access and disable when not possible (#45484)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45484

Prior to Android SDK 28, there was no way to tell if a View's pivotX or pivotY were set.  Unfortunately this breaks view recycling due to the default behavior of:
- `getPivotX()` and `getPivotY()` [initialize as 0](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.h#643)
- As long as they haven't been set, [they actually default to width/2 and height/2](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.cpp#195).

Thus even if we were to check for `getPixotX() == 0`, we wouldn't know if it was specifically set to 0 (making the pivot actually 0), or still just the default value.  We'd then need to reset the pivot any time the width or height changed.  [`View.resetPivot()`](https://developer.android.com/reference/android/view/View#resetPivot%28%29) was presumably added to fix this in API 28.

This diff adds nullability to `prepareToRecycleView()` so we can act accordingly - returning null if the view can't be recycled.

Also added a version check for [`setAnimationMatrix()`](https://developer.android.com/reference/android/view/View#setAnimationMatrix%28android.graphics.Matrix%29), which is only available in 29+.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D59827328

fbshipit-source-id: d1729bba347e8af7fb2b57c95ed2e0b66a15d155
2024-07-17 18:00:48 -07:00
Blake Friedman 188a09ef69 fix linting noise (#45465)
Summary:
## Summary:
Fix linting warnings

Changelog: [Internal]

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

Test Plan:
```
$ eslint .
Done in 46.11s.
$ arc f
ok No lint issues.
```

Reviewed By: cipolleschi

Differential Revision: D59805820

Pulled By: blakef

fbshipit-source-id: f33d99a6a06607c3c3762881cc7c182804b981e1
2024-07-17 10:07:00 -07:00
Riccardo Cipolleschi 394aae1c1c Make the ScrollView connect with the TurboAnimatedModule to fix pressable and animated (#45457)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45457

With this change, we are implementing in Android a similar logic that we implemented in iOS.
1. When the user stops dragging a scroll view, it tells native animated modle that a scroll has finished
2. NativeAnimated module asks to the NativeAnimatedNodesModule if there are native node listening to the scroll
3. In case they are, it emits an event to JS
4. JS listen to the events and resync the Shadow Tree and the Native Tree (this implemented in a previous change)

## Changelog
[Android][Fixed] - Sync the Shadow Tree and the Native Tree with Native animation when scroll is driving the animation

Reviewed By: sammy-SC

Differential Revision: D59756577

fbshipit-source-id: e558557b477f4da9da1f89fb31ba86d0ea1390a3
2024-07-17 09:22:39 -07:00
Riccardo Cipolleschi fd748ae84c Receive the onUserDrivenAnimationEnded event in JS (#45383)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45383

This is the second step required to fix the onTouchMove event in the new architecture.

In this change, we are retrieving the list of nodes that are connected by the animation, and we are sending an event to the nodes so that we can trigger the commit.

## Changelog
[iOS][Added] - retrieve the tags of the nodes connected by the animation and send them to JS

Reviewed By: sammy-SC

Differential Revision: D59524617

fbshipit-source-id: 584317afa8e4cf0ad9f98f38e4e5d436c5fe3ac5
2024-07-17 09:22:39 -07:00
Riccardo Cipolleschi 7af743236f Send onScrollEnded Event to native driver (#45382)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45382

This change is the first step to tr and solve the pressability's `onTouchMove` issue with animation driven natively in the New Architecture.

 The idea is to trigger a special event from native to let JS know that a scroll event has ended (`scrollViewDidEndDragging` or `scrollViewdidEndDecelerating`).

When this happens, we need to send an event to JS to let him know that it has to sync the Native Tree with the Shadow Tree.

Step 2 is to connect Native with JS

## Changelog:
[iOS][Added] - Send onScrollEnded event to NativeTurboAnimatedModule

Reviewed By: sammy-SC

Differential Revision: D59459989

fbshipit-source-id: cb425cddcdaa9d700ec40accaf4ab3ce1f3c5038
2024-07-17 09:22:39 -07:00
Pieter De Baets 00d4d9c632 Limit sampling to 50 frames (#45478)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45478

Some code is far too recursive. This consumes buffer space and causes problems for the Perfetto frontend. Let's limit it to 50 frames.

Changelog: [Internal]

Reviewed By: rubennorte, sammy-SC

Differential Revision: D59813638

fbshipit-source-id: 69068f9c2193d706ec0cc00ffc0d5950ae094e05
2024-07-17 05:30:21 -07:00
Zeya Peng a6f5e5adeb Fix react/renderer ColorTest (#45485)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45485

## Changelog:

the new functions I introduced in https://github.com/facebook/react-native/pull/45365 to read color channel value, like `alphaFromColor`, will return float between 0~255 on iOS and 8bit unsigned ints on other platforms, because of different platform implementation. However that way we cannot assume consistent return value across platforms, which kind of contradicts with RN's cross platform design.

so here I make `alphaFromColor` in Color.h (the cross platform method) to always return uint8_t, while still allow `alphaFromHostPlatformColor` to return different result

[Internal] [Fixed] -

Reviewed By: christophpurrer

Differential Revision: D59826142

fbshipit-source-id: 4401918be29980474bdc8601443ae33155710f22
2024-07-16 16:35:13 -07:00
Deepanshu.shukla 50f7892a1f fix: add headers in fabric image component (#45415)
Summary:
FIXES [45404](https://github.com/facebook/react-native/issues/45404)

 sending headers from Image  component  not working in new arch , implementation was missing
```
<Image
        source={{
          uri: "http://localhost:3000/image",
          headers: {
            "test-header": 'test',
              "hello":"tested"
          }
        }}
        style={{
          width: 300,
          height: 300,
        }}
      />
```

## Changelog:
[IOS] [ADDED]- sending missing **headers** field with **Image** component in fabric

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

Test Plan:
# Tested
Attaching the below video to show how headers are getting received on server from Image component running in new arch

https://github.com/user-attachments/assets/c816265d-0bb5-4670-bde0-cfec72d7618f

Reviewed By: javache, cipolleschi

Differential Revision: D59807462

Pulled By: blakef

fbshipit-source-id: dffa4d80db58de6a81947ac876aa76ec7e62dd48
2024-07-16 16:20:11 -07:00
Rob Hogan db16a7895e jsinspector: Vendor base64 encoding, remove folly::base64 dependency (#45445)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45445

Roll our own base64 encoding and revert D59685218, which fixed the missing Folly dependency implied by D54309633.

I assumed Folly base64 was already elsewhere in RN but given it isn't, and we only need simple, non-perf-sensitive encoding for the debugger (not the SIMD or delegated implementations, or decoding), it might be best to just include our own encoder.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D58323859

fbshipit-source-id: 5ce98561e9ced82765e8e7c18e5d2ebfa8148c8c
2024-07-16 14:34:14 -07:00
Andrew Coates 892c8352ca Use more accurate type in LinkingManager spec file (#45450)
Summary:
The `LinkingModule.getInitialURL` method is declared as returning a `Proimise<string>` but looking at the implementation it can also return null:

https://github.com/facebook/react-native/blob/a96272e27eeee0c7a26e73bb32e55d3ef8d741aa/packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm#L166
which is returned by
https://github.com/facebook/react-native/blob/a96272e27eeee0c7a26e73bb32e55d3ef8d741aa/packages/react-native/Libraries/Linking/Linking.js#L96
which happens to expand the type to the correct type for most external users.

React-native-window's turbomodule codegen is more type strict, and so cannot return null with the current spec.

## Changelog:

[INTERNAL] [FIXED] - Use more accurate type in LinkingManager spec file

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

Test Plan:
Type change only, so should only affect build time change which will be caught by CI.
Have verified that this type change allows react-native-windows to return null.

Reviewed By: robhogan

Differential Revision: D59816089

Pulled By: zeyap

fbshipit-source-id: 9810f150ce84b503883e72b1f29518d2e62258b6
2024-07-16 13:41:48 -07:00
Rob Hogan c085180264 jsinspector: Support UTF-8 responses to CDP's IO.read (#45426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45426

The initial implementation of `Network.loadNetworkResource` and the accompanying `IO.read` (D54202854) base64-encodes all data as if it is binary. This is the more general case, and we'll continue to base64-encode non-text resources.

In the common case of text resources (particularly JS and JSON), it'd be preferable to do as Chrome does and send UTF-8 over the wire directly. This has a few performance benefits:
 - Less CPU and RAM footprint on device (UTF-8 truncation is constant-time, fast, and in-place), similarly less decoding for the frontend.
 - 25% less data per chunk (base64 encodes 3 bytes as 4 characters), implies up to 25% fewer network round trips for large resources.

It also has the benefit of being human-readable in the CDP protocol inspector.

## Determining whether data is text
We use exactly Chromium's heuristic for this (code pointers in comments), which is based only on the `Content-Type` header, and assuming any text mime type is UTF-8.

## UTF-8 truncation
The slight implementation complexity here is that `IO.read` requests may specify a maximum number of bytes, and so we must slice a raw buffer up into valid UTF-8 sequences. This turns out to be fairly simple and cheap:
 1. Naively truncate the buffer, inspect the last byte
 2. If the last byte has topmost bit =0, it's ASCII (single byte) and we're done.
 3. Otherwise, look back at most 3 bytes to find the first byte of the code point (topmost bits 11), counting the number of "continuationBytes" at the end of our buffer. If we don't find one within 3 bytes then the string isn't UTF-8 - throw.
 4. Read the code point length, which is encoded into the first byte.
 5. Resize to remove the last code point fragment, unless it terminates correctly exactly at the end of our buffer.

## Edge cases + divergence from Chrome
Chrome's behaviour here in at least one case is questionable and we intentionally differ:
 - If a response has header "content-type: text/plain" but content eg`0x80` (not valid UTF-8), Chrome will respond to an `IO.read` with `{ "data": "", "base64Encoded": false, "eof": false }`, ie an empty string, but will move its internal pointer such that the next or some subsequent `IO.read` will have `"eof": true`. To the client, this is indistinguishable from a successfully received resource, when in fact it is effectively corrupted.
 - Instead, we respond with a CDP error to the `IO.read`. We do not immediately cancel the request or discard data, since not all `IO.read` errors are necessarily fatal. I've verified that CDT sends `IO.close` after an error, so we'll clean up that way (this isn't strictly guaranteed by any spec, but nor is `IO.close` after a resource is successfully consumed).

Changelog:
[General][Added] Debugger: Support text responses to CDP `IO.read` requests

Reviewed By: hoxyq

Differential Revision: D58323790

fbshipit-source-id: def8bf8426266f16bb305d836a6efe8927a9dfc4
2024-07-16 12:31:41 -07:00
Håkon Knutzen 0f051f6034 Add missing lock around assignment of cancellation handler in RCTImageLoader (#45454)
Summary:
When running the entire unit test suite of `RNTesterPods` with `TSan`, I saw that occasionally a data race was detected on line 843 of `RCTImageLoader`. It seems the completion handler that does contain the lock around `cancelLoad` is called concurrently with the value being assigned on line 843. Here there is no lock in place.

Here is the output of `TSan` when I comment out my fix:
```
WARNING: ThreadSanitizer: data race (pid=72490)
  Write of size 8 at 0x000144151ce8 by main thread:
    #0 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16e8030)
    https://github.com/facebook/react-native/issues/1 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df8dc)
    https://github.com/facebook/react-native/issues/2 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df534)
    https://github.com/facebook/react-native/issues/3 -[RCTImageLoaderTests testImageLoaderUsesImageURLLoaderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0x7cb8)
    https://github.com/facebook/react-native/issues/4 __invoking___ <null> (CoreFoundation:arm64+0x13371c)

  Previous write of size 8 at 0x000144151ce8 by thread T4 (mutexes: write M0):
    #0 __140-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_2 <null> (RNTesterUnitTests:arm64+0x16e8894)
    https://github.com/facebook/react-native/issues/1 __139-[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke <null> (RNTesterUnitTests:arm64+0x16e3430)
    https://github.com/facebook/react-native/issues/2 __139-[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_3 <null> (RNTesterUnitTests:arm64+0x16e52a8)
    https://github.com/facebook/react-native/issues/3 __75-[RCTImageLoaderTests testImageLoaderUsesImageURLLoaderWithHighestPriority]_block_invoke_2 <null> (RNTesterUnitTests:arm64+0x7f24)
    https://github.com/facebook/react-native/issues/4 -[RCTConcreteImageURLLoader loadImageForURL:size:scale:resizeMode:progressHandler:partialLoadHandler:completionHandler:] <null> (RNTesterUnitTests:arm64+0x6c470)
    https://github.com/facebook/react-native/issues/5 __139-[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke.172 <null> (RNTesterUnitTests:arm64+0x16e4964)
    https://github.com/facebook/react-native/issues/6 __tsan::invoke_and_release_block(void*) <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x77ee0)
    https://github.com/facebook/react-native/issues/7 _dispatch_client_callout <null> (libdispatch.dylib:arm64+0x3974)

  Location is heap block of size 48 at 0x000144151cc0 allocated by main thread:
    #0 malloc <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x4fa48)
    https://github.com/facebook/react-native/issues/1 _malloc_type_malloc_outlined <null> (libsystem_malloc.dylib:arm64+0xf3ec)
    https://github.com/facebook/react-native/issues/2 _call_copy_helpers_excp <null> (libsystem_blocks.dylib:arm64+0x10b4)
    https://github.com/facebook/react-native/issues/3 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df8dc)
    https://github.com/facebook/react-native/issues/4 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df534)
    https://github.com/facebook/react-native/issues/5 -[RCTImageLoaderTests testImageLoaderUsesImageURLLoaderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0x7cb8)
    https://github.com/facebook/react-native/issues/6 __invoking___ <null> (CoreFoundation:arm64+0x13371c)

  Mutex M0 (0x000108f316e8) created at:
    #0 pthread_mutex_init <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x2cc98)
    https://github.com/facebook/react-native/issues/1 -[NSLock init] <null> (Foundation:arm64+0x5ca14c)
    https://github.com/facebook/react-native/issues/2 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df8dc)
    https://github.com/facebook/react-native/issues/3 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:progressBlock:partialLoadBlock:completionBlock:] <null> (RNTesterUnitTests:arm64+0x16df534)
    https://github.com/facebook/react-native/issues/4 -[RCTImageLoaderTests testImageLoaderUsesImageURLLoaderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0x7cb8)
    https://github.com/facebook/react-native/issues/5 __invoking___ <null> (CoreFoundation:arm64+0x13371c)

  Thread T4 (tid=10935088, running) is a GCD worker thread
```

## Changelog:

[iOS][Fixed] Data race in `RCTImageLoader` related to assignment of cancellation block.

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

Test Plan: There are already tests in place for `RCTImageLoader`. I hope these will cover the fix.

Reviewed By: realsoelynn

Differential Revision: D59816000

Pulled By: zeyap

fbshipit-source-id: f959d472eb60f83f39ced6711ee395949ab37e7c
2024-07-16 12:30:43 -07:00
Alex Hunt c47b04b07e Enable Fusebox by default (#45469)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45469

Enables React Native DevTools by default on `main`, ahead of the 0.76 release. We've observed no new bug reports internally over the last two weeks, and are moving forward with our rollout plan.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D59804882

fbshipit-source-id: 0cb6302f4d940718786db2e5d8fb652fae6a8c54
2024-07-16 10:16:25 -07:00
Nick Lefever c0b288ca3f Use weak ptr for runtime shadow node reference (#45463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45463

Changelog: [Internal]

State updates will clone shadow nodes for an shadow tree revision that is outdated.

This can lead to accessing deallocated shadow node references because the JS renderer committed a newer revision and deallocated the one used by the pending state update.

By using a weak pointer to hold a reference to the runtime shadow node reference, we can only update references for wrappers that are still valid.

Reviewed By: javache

Differential Revision: D59804999

fbshipit-source-id: 89c9967d139d3cac7d7252994beae419bc591e79
2024-07-16 09:23:42 -07:00
Nicola Corti 2098806c22 Unbreak RNTester instacrashing on main (#45467)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45467

This unbreaks RNTester instacrashing on main.

Changelog:
[Internal] [Changed] - Unbreak RNTester instacrashing on main

Reviewed By: javache

Differential Revision: D59806826

fbshipit-source-id: 6d5246cd02e2c364068d047b973b2954b459df1e
2024-07-16 07:42:43 -07:00
Riccardo Cipolleschi 050006a7a7 Add example for Pressability with Native Driver in RNTester (#45413)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45413

## Changes
Add an example in RNTester to test that pressability with NativeDrivers works properly.

## Context
The pressability handling is a bit peculiar.
We have to handle 3 main behaviors:
* `PressIn` -> `PressOut` => triggers the `onPress`
* `PressIn` -> move inside the rectangle -> `PressOut` => triggers the `onPress`
* `PressIn` -> move outside the rectangle -> `PressOut` => cancel `onPress`.

For the first case, we detect whether the press happens inside a component in the Native layer only. And everything works.

When a move is involved, we:
1. Detect the initial press in the Native layer
2. We move the coursor and we delegate the detection of whether we are inside of a rect or not to the JS layer
3. The JS layer asks the C++ layer about the layout and decide whether we are in case 2 (move but still inside the rect) or in case 3 (move but outside the rect).

The problem is that with `nativeDriver` and animations, the C++ layer doesn't know about where the receiver view actually is.
This results in issues like the one shown by [#36504](https://github.com/facebook/react-native/issues/36504), where the onMove is not handled correctly.

## Solution
The solution is to keep detecting whether we are in the receiver view or not in the Native layer and pass the receiver view position and size back to JS so that the JS layer don't have to jump to C++ to make this decision.

We decided to pass the frame information because the JS layer is adding some padding and configurations to the final rectangle and we don't want to lose those configurations.

## Changelog
[General][Added] - Add example in RNTester to show that pressability works properly with NativeDrivers

Reviewed By: sammy-SC

Differential Revision: D58182480

fbshipit-source-id: 9ca4fb9a3ca1a8af52ccbe208cbfe8434175f87d
2024-07-16 07:20:51 -07:00
Riccardo Cipolleschi 7fd6c2c45e Fix CCI cache issues (#45460)
Summary:
CCI on main is broken. We suspect that's due to cache issues which restore a wrong layout for the Folly pod.
This PR is an attempt to fix it

## Changelog:
[Internal] - Fix missing folly base 64

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

Test Plan: CCI and GHA are green

Reviewed By: sammy-SC, huntie

Differential Revision: D59804748

Pulled By: cipolleschi

fbshipit-source-id: 44d6b169cf3319f4d7ee9e0a5833f07bc6ba4bb3
2024-07-16 06:26:07 -07:00
Pieter De Baets 5bb57eb2b3 Ignore PackagerStatusCallback on invalidated ReactInstanceManager (#45458)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45458

Checking for packager is an async operation, which may return when we've already destroyed the ReactInstanceManager. Prevent the CatalystInstance from being created if the ReactInstanceManager has been invalidated.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D59753247

fbshipit-source-id: e3ac2b6dd142330e2d4051519b9863584b33f8a6
2024-07-16 05:19:33 -07:00
shubhamguptadream11 b243d343fa fix: background color fix when border is dotted and dashed (#45430)
Summary:
This PR fixes these issues: https://github.com/facebook/react-native/issues/42289, https://github.com/facebook/react-native/issues/45368

## Changelog:

[IOS] [FIXED] - Message

In iOS for old/new architecture when we are trying to pass borderStyle other than 'solid' then in this
**Old Arch file**
https://github.com/facebook/react-native/blob/2eb7bcb8d9c0f239a13897e3a5d4397d81d3f627/packages/react-native/React/Views/RCTView.m#L807
**New Arch file**
https://github.com/facebook/react-native/blob/2eb7bcb8d9c0f239a13897e3a5d4397d81d3f627/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L652
 file useCoreAnimationBorderRendering is coming as nil since borderStyle passed is not **solid**. Due to which else case block executes and there we are applying backgroundColor as nil.

I just removed that hardcoded check for sold style and make sured that it is now working now with all three borderStyle 'dotted' | 'solid' | 'dashed' for Text and View both

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

Pick one each for the category and type tags:

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

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

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

Test Plan:
Tested with possible borderStyle values.

Providing the fixed screenshot here.

![simulator_screenshot_5E7DDDE7-71F2-4A35-93B3-BFD9F980EA18](https://github.com/user-attachments/assets/3949085e-946f-4669-aaf5-fe366f7e6fc4)

Reviewed By: cortinico

Differential Revision: D59755124

Pulled By: cipolleschi

fbshipit-source-id: 091bb9ba731ac93973230970b526396fd6ea2989
2024-07-16 04:39:21 -07:00
Pieter De Baets e02ca334b1 Skip getProperty calls for unreferenced props in RawPropsParser (#45456)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45456

Small perf improvement when using enableCppPropsIteratorSetter

Changelog: [Internal]

Reviewed By: sammy-SC, mdvacca

Differential Revision: D59699469

fbshipit-source-id: d65a5e26faf218d0b79c9ac691007310b6db4182
2024-07-16 04:38:45 -07:00
Samuel Susla 334b5c9fdb Execute insert mount instructions after layout update and state update (#45448)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45448

changelog: [internal]

I would like to experiment with executing insert mount instructions after layout and state update. It has shown small improvement in local testing

Reviewed By: mdvacca

Differential Revision: D59582123

fbshipit-source-id: 3ee6ec12a533a287ed32f7373863175f3a107548
2024-07-16 02:13:12 -07:00
Samuel Susla 4d88b20847 create hook to setup animations in passive effects (#45410)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45410

changelog: [internal]

For better performance, let's test setting up the animation graph from passive effects. This will delay the work, not blocking the paint.

Reviewed By: rubennorte

Differential Revision: D59644374

fbshipit-source-id: ff951ee7c1a1d47e13c55fc7c7f6c0690aa465f7
2024-07-16 02:13:12 -07:00
Ruslan Shestopalyuk e443c1f0cf Make sure that ScrollView.scrollIndicatorInsets prop finds its way from JS into C++/Fabric (#45444)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45444

## Changelog:

[Internal] -

Even though `ScrollView.scrollIndicatorInsets` isn't supported on the vanilla Android platform, it still may be used on some other variations of it, which means that the changes may not potentially find the way into C++/Fabric, opening a door of all kinds of weird corner case issues.

Reviewed By: christophpurrer

Differential Revision: D59761458

fbshipit-source-id: 4dae5c96791ca924d589a3d803d8fa60fdca1b67
2024-07-16 01:33:43 -07:00
Joe Vilches 944d40f204 Add mix-blend-mode effects to iOS (#45304)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45304

Add support for most keyword values of mix-blend-mode on iOS and added RNTester Example
Missing compositing operators and global values

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59402969

fbshipit-source-id: b7e1aaed01fbf8f80e04ad0fa73d2ef63b5ad933
2024-07-15 18:10:17 -07:00
Joe Vilches a96272e27e Add drop-shadow test (#45306)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45306

Adding missing drop-shadow test to rn-tester.
Added with alpha-hotdog image to show we are creating the shadow with the alpha channel of the view.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D59410148

fbshipit-source-id: 5a03ee84313979f99585b8ca7e07abf9cdbe2396
2024-07-15 16:09:43 -07:00
generatedunixname89002005232357 85dd14c912 Revert D59170923 (#45447)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45447

This diff reverts D59170923
Breaking OSS build

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D59759991

fbshipit-source-id: 39aa0b447a90801d1da5a39461b33b4c4cc4197b
2024-07-15 13:44:09 -07:00
Nick Gerleman 2d67b723d3 Gate off "mixBlendMode" and "filter" on Paper (#45443)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45443

We are only building these out for Fabric. This means only one natural iOS impl, but that other Android bits will not work fully correctly on Paper (like setting containing block for filter element). This also means we can remove view configs once we're on Fabric CSS parser. We will do the same for boxShadow once that is ready.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D59762282

fbshipit-source-id: 14ce07f04b822c6aee908894c9081419594fc484
2024-07-15 13:05:40 -07:00
Peter Abbondanzo 018d0621c1 Declare public resources from images that are loaded by name (#45421)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45421

RNTester contains Android resources that are loaded by name and not resolved by Metro. As a result, these assets are not automatically linked when RNTester JS code is embedded in other projects. This is considered "legacy" loading and is generally discouraged, but is still showcased as an alernative way of loading resources.

I also modified the Image test to ensure that flag status is printed so it's obvious why the vector drawable hasn't loaded.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D59585555

fbshipit-source-id: d42fb44d8846d8e7c7aa01dca4cec89ae85a9195
2024-07-15 12:39:06 -07:00
Nicola Corti 52237838dc Deprecate DeveloperSettings.isStartSamplingProfilerOnInit (#45442)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45442

This deprecates also `DeveloperSettings.isStartSamplingProfilerOnInit`
so we can remove it in a future version of React Native.

This field is unused so you should not be using it at all.

Changelog:
[Android] [Changed] - Deprecate DeveloperSettings.isStartSamplingProfilerOnInit

Reviewed By: blakef

Differential Revision: D59757500

fbshipit-source-id: dc879ba46f2f937e5f259a4101646c2f060db548
2024-07-15 12:16:33 -07:00
rozele (Meta Employee) 8f27188037 Updates ViewConfig types to delegate isInAParentText context (#29872)
Summary:
## Summary

Now that HostContext determination for Fabric is a DEV-only behavior, we
can move the HostContext determination to resolve from the ViewConfig
for a given type. Doing this will allow arbitrary types to register
themselves as potential parents of raw text string children. This is the
first of two diffs for react as we'll:

1. Add the new property to the ViewConfig types
2. Update React Native to include the `supportsRawText` property for
`RCTText`, `RCTVirtualText`, `AndroidTextInput`, etc.
3. Switch the behavior of react to read from the ViewConfig rather than
a static list of types.

Changelog: [Internal]

## Test Plan

- yarn test
- yarn test --prod
- Pulled change into react-native, added `supportsRawText` props to
RCTText, RCTVirtualText, etc. ViewConfigs and confirmed everything type
checks.

DiffTrain build for commit https://github.com/facebook/react/commit/a5cc797b8801dfe58c7a34c99a9fa60c6c9c8274.

bypass-github-export-checks

Reviewed By: poteto

Differential Revision: D59641180

Pulled By: rozele

fbshipit-source-id: a3ddb1bc810a70d5f782e708cb845e3eae136d78
2024-07-15 10:58:38 -07:00
zhongwuzw 9e2f8859c4 Reland: [iOS] Fixes ellipsis carries background from trimmed text (#45412)
Summary:
Reland https://github.com/facebook/react-native/issues/39408 . Try to fix the crash https://github.com/facebook/react-native/issues/37926#issuecomment-2225113557. cc. javache I changed the range from glyph to character because all attributes related APIs are character range.

## Changelog:

[IOS] [FIXED] - Fixes ellipsis carries background from trimmed text

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

Test Plan: https://github.com/facebook/react-native/issues/37926 .

Reviewed By: cipolleschi

Differential Revision: D59681679

Pulled By: javache

fbshipit-source-id: de4cb73e0304b8c0b0a40f4f6838b2c679747009
2024-07-15 10:53:35 -07:00