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
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
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
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
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
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
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
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
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
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
Summary:
As titled. This API is legacy / Meta-only.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D65666574
fbshipit-source-id: f9700486aec0306b305910bff14ae7f3df3fab7f
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
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47506
The Check nightlies job prepare a new nightly app with additional libraries and on iOS it builds with `yarn ios`.
The command tries to launch the app on the simulator which sometimes fails and this can make the jobs keep running for hours.
This change make sure that we only build the app
## Changelog:
[Internal] - Only build iOS in CI for Check Nightlies
Reviewed By: blakef
Differential Revision: D65656812
fbshipit-source-id: 14db3738f33f8024c9e99fe206b170209154bac7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47502
Enables the two following feature flags:
- `enableAnimatedAllowlist`
- `enableAnimatedPropsMemo`
The former enables the use of an experimental optimization to provide `unstable_createAnimatedComponentWithAllowlist` and `useAnimatedProps` an allowlist of props that reduces the set of props iterated over by to find props with `AnimatedNode` (e.g. `Animated.Value`) instance values.
The latter enables improved memoization logic in `Animated` so that its intenal state is invalidated less frequently, reducing the cost of updating `Animated` components.
Changelog:
[General][Changed] - Optimized the performance of updating `Animated` components.
Reviewed By: rozele
Differential Revision: D65645985
fbshipit-source-id: 85f9e53072f09a59589d76d0c096f4cedd17bb4b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47498
I am trying to help someone with creating a sticky header on a scrollview, specifically one that floats on the side of the scrollview instead of the top Currently we can't really do that, since utilizing `position: absolute` to layout this properly will get overriden by the header styles changed in this diff
This was only added since static was the default and we needed to apply zIndex. With proper static implementation that is no longer the case, so I think it makes sense to remove this to support this use case.
Changelog: [General] [Breaking] - `position` of sticky headers on `ScrollView` will now be taken into account
Reviewed By: rozele
Differential Revision: D65626544
fbshipit-source-id: 8d650ca7654918e692435935e7c1094c412fd9f6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47470
Convert to Kotlin and formalize it being an internal class (some methods were already `protected` in Java)
Changelog:
[Android] [Breaking] - Stable API - Make SwipeRefreshLayoutManager internal
Reviewed By: cortinico
Differential Revision: D65481861
fbshipit-source-id: afc5c624373fbcd3ca2d28b2834d2682de672997
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47466
Now, when the useAlwaysAvailableJSErrorHandling feature flag is true, React Native will use the earlyjs c++ error reporting pipeline for handling all javascript errors!
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D64715159
fbshipit-source-id: 597a5278eb792f87dca10e06fa9816b3a8c47b84
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47475
Creates a feature flag to evalute the impact of disabling `InteractionManager` and replacing its scheduling behavior with `setImmediate`.
Changelog:
[Internal]
Reviewed By: javache
Differential Revision: D65577455
fbshipit-source-id: c0dc2b4d062eff4929ef37c5e217fd194addd790
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47419
Minor improvements to `ImageExample` so we log when images fail to load. Also replaces a `Text` component with `RNTesterText` so it's legible.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D65363864
fbshipit-source-id: 6c7ce8d5af6aabfed21479c784911bdcffe4684e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47478
That's a reland of D65540601
The `UIManager.eventDispatcher` return type is wrong and is causing a breaking change in 0.77
For 0.76 we fixed it in the release branch but we should fix it for good in main as well.
To solve it I had to fix the circular dependency between .bridge and .uimanager.
I wish I could have isolated the .events package better but as everythign is public, any
change we do is going to be a breaking change so I'm being over cautios here.
Changelog:
[Android] [Fixed] - Undo breaking change of UiManager.eventDispatcher return type
Reviewed By: javache
Differential Revision: D65595391
fbshipit-source-id: fc7f6dce78e531c5ec0cc493ed90c0012262b77f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47461
As titled, is overwritten later in the file.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D65546370
fbshipit-source-id: 4ea71d24e429b7bbded3e7bb7c75015a2c9d95d8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47482
XCBeautify swallow some errors, especially all the linker errors when some symbol is not defined. The full error is not available in the raw log either.
This makes much harder to debug those issues when they happen.
We can remove xcbeautify for the time being, while we find a better solution.
## Changelog
[Internal] - Remove XCBeautify from ci
Reviewed By: dmytrorykun
Differential Revision: D65596745
fbshipit-source-id: 0550d4cbeadc5bec8acc61b5edc1320d3445bcaf
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47481
The Codegenerated files has this option turned off.
This is causing Xcode to output hundreds of warnings due to missing nullability options. RThis fixes them.
## CHANGELOG
[Internal] - Set ASSUME_NONNULL regions in codegen'd files
Reviewed By: dmytrorykun
Differential Revision: D65596598
fbshipit-source-id: bbf664944e103c05ef593a7e07bf5b767445950c
Summary:
When running the commands to check the flow types locally, there is quite some noise from files under `packages/rn-tester/Pods` that should not be checked as they are not from the source code itself.
<img width="839" alt="Screenshot 2024-11-07 at 00 50 55" src="https://github.com/user-attachments/assets/7ad3d96d-0f4a-4772-9e37-34d7e593b4cf">
## Changelog:
[INTERNAL] [FIXED] - Excluding `packages/rn-tester/Pods/` from flow checks
Pull Request resolved: https://github.com/facebook/react-native/pull/47474
Test Plan:
```bash
yarn flow
```
Reviewed By: cortinico
Differential Revision: D65594400
Pulled By: cipolleschi
fbshipit-source-id: d5e8828f41fc87c9a95293c250f24673ebbc6cd4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47458
We are in a weird situation where React Native depends on some files that are generated by Codegen.
Codegen runs in the user project, so those dependencies are not available to React Native if we try to build it in isolation.
This is a problem and a blocker to prepare the prebuilds for iOS.
This image show the changes we are introducing:
On the right we have the current situation.
On the left the new one.
{F1954418630}
## Changelog:
[Internal] - Generate React Native specific code inside React Native
Reviewed By: cortinico, blakef
Differential Revision: D65541505
fbshipit-source-id: 1412d7f23c4d2230b795af41f1e832c8a70d5859
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47399
Deletes `unstable_setEnableSyncOnScroll` which we are no longer experirmenting with in React Native.
Changelog:
[Internal] - Deleted `unstable_setEnableSyncOnScroll` on `ScrollView`, which was never part of the React Native Public API.
Reviewed By: tdn120, sammy-SC
Differential Revision: D65449039
fbshipit-source-id: 6608d5ccca477f1da5e0168c4a342cce17014b08
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47354
`PointerValue::invalidate()` is called from `Pointer` destructor, which is implicitly `noexcept`, and from `Pointer` move-assignment operator, which is now `noexcept`.
Reviewed By: neildhar
Differential Revision: D65271399
fbshipit-source-id: 26fd9707e4389da78537d0d607adaef0c68690ca