Skip to content

Commit 9e1560c

Browse files
authored
docs: update section about DISABLE_COMMIT_PAUSING_MECHANISM feature flag (#9117)
## Summary This PR updates the docs about feature flags with our current recommendations. ## Test plan
1 parent 2e34032 commit 9e1560c

File tree

2 files changed

+30
-77
lines changed

2 files changed

+30
-77
lines changed

docs/docs-reanimated/docs/guides/feature-flags.md

Lines changed: 29 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -37,95 +37,48 @@ Feature flags available in `react-native-worklets` are listed [on this page](htt
3737

3838
When enabled, this feature flag is supposed to eliminate jittering of animated components like sticky header while scrolling. This feature flag is safe to enable only if `preventShadowTreeCommitExhaustion` feature flag from `react-native` (available since React Native 0.81) is also enabled – see instructions below. In all other cases it can lead to unresponsiveness of the app due to the starvation of React commits. For more details, see [PR #7852](https://github.com/software-mansion/react-native-reanimated/pull/7852).
3939

40-
In React Native 0.81, `preventShadowTreeCommitExhaustion` feature flag can be enabled by setting experimental release level. If you're using Expo, you can enable it using [`expo-build-properties`](https://docs.expo.dev/versions/latest/sdk/build-properties/):
40+
:::note
41+
We no longer recommend setting experimental React Native release level because it also enables other unrelated flags, for instance `fixTextClippingAndroid15useBoundsForWidth`, which supposedly causes incorrect text clipping on Android 15. Instead, you should enable only the `preventShadowTreeCommitExhaustion` feature flag according to the instructions below.
42+
:::
4143

42-
```json
43-
{
44-
"expo": {
45-
// ...
46-
"plugins": [
47-
// ...
48-
// highlight-start
49-
[
50-
"expo-build-properties",
51-
{
52-
"android": {
53-
"reactNativeReleaseLevel": "experimental"
54-
},
55-
"ios": {
56-
"reactNativeReleaseLevel": "experimental"
57-
}
58-
}
59-
]
60-
// highlight-end
61-
]
62-
}
63-
}
64-
```
44+
Here's how you can enable `preventShadowTreeCommitExhaustion` feature flag from React Native.
6545

66-
It will add the following lines in `gradle.properties` (Android) and `Info.plist` (iOS):
46+
First, please apply the following change in `ReactNativeFeatureFlagsDefaults.h`:
6747

68-
```gradle
69-
reactNativeReleaseLevel=experimental
48+
```diff
49+
bool preventShadowTreeCommitExhaustion() override {
50+
- return false;
51+
+ return true;
52+
}
7053
```
7154

72-
```
73-
<key>ReactNativeReleaseLevel</key>
74-
<string>experimental</string>
75-
```
55+
It is recommended to make a patch after applying this change to make it persistent using tools like [patch-package](https://www.npmjs.com/package/patch-package), [yarn patch](https://yarnpkg.com/cli/patch) or [pnpm patch](https://pnpm.io/cli/patch).
7656

77-
If you're not using Expo, in order to enable experimental release level on Android, you need to add the following lines in `MainApplication.kt` of your app:
78-
79-
```kt
80-
package com.helloworld
81-
82-
import android.app.Application
83-
import com.facebook.react.PackageList
84-
import com.facebook.react.ReactApplication
85-
import com.facebook.react.ReactHost
86-
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
87-
import com.facebook.react.ReactNativeHost
88-
import com.facebook.react.ReactPackage
89-
// highlight-next-line
90-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
91-
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
92-
import com.facebook.react.defaults.DefaultReactNativeHost
93-
// highlight-next-line
94-
import com.facebook.react.common.ReleaseLevel
95-
96-
class MainApplication : Application(), ReactApplication {
97-
// ...
57+
You also need to build React Native from source in order for this change to take effect.
9858

99-
override fun onCreate() {
100-
super.onCreate()
101-
// highlight-next-line
102-
DefaultNewArchitectureEntryPoint.releaseLevel = ReleaseLevel.EXPERIMENTAL
103-
loadReactNative(this)
104-
}
59+
For Android, please add the following lines in `android/settings.gradle` according to the instructions [here](https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source):
60+
61+
```gradle
62+
includeBuild('../node_modules/react-native') {
63+
dependencySubstitution {
64+
substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
65+
substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
66+
substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
67+
substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
68+
}
10569
}
10670
```
10771

108-
For iOS, you need edit the following line in `AppDelegate.swift` of your app:
109-
110-
```swift
111-
@main
112-
class AppDelegate: UIResponder, UIApplicationDelegate {
113-
// ...
114-
115-
func application(
116-
_ application: UIApplication,
117-
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
118-
) -> Bool {
119-
let delegate = ReactNativeDelegate()
120-
// highlight-next-line
121-
let factory = RCTReactNativeFactory(delegate: delegate, releaseLevel: RCTReleaseLevel.Experimental)
122-
delegate.dependencyProvider = RCTAppDependencyProvider()
72+
For iOS, add the following lines in `ios/Podfile` according to the instructions [here](https://reactnative.dev/blog/2026/02/11/react-native-0.84#precompiled-binaries-on-ios-by-default).
12373

124-
// ...
125-
}
126-
}
74+
```rb
75+
ENV['RCT_USE_PREBUILT_RNCORE'] = '0'
12776
```
12877

78+
:::tip
79+
Flickering/jittering while scrolling will be ultimately fixed by branching mechanism which was introduced in [this PR to React Native](https://github.com/facebook/react-native/pull/54835). Currently it's under testing and should be out in some future release of React Native.
80+
:::
81+
12982
### `ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS`
13083

13184
When enabled, non-layout styles will be applied using the `synchronouslyUpdateViewOnUIThread` method (which doesn't involve layout recalculation) instead of than `ShadowTree::commit` method (which requires layout recalculation). In an artificial benchmark, it can lead to up to 4x increase of frames per second. Even though we don't expect such high speedups in the production apps, there should be a visible improvements in the smoothness of some animations. However, there are some unwanted side effects that one needs to take into account and properly compensate for:

docs/docs-reanimated/docs/guides/performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Please note that downgrading your Expo SDK version or using an older release of
2020

2121
**Problem:** When scrolling a `FlatList` or `ScrollView`, you might notice flickering or jittering of animated components (e.g. sticky header) implemented using `useAnimatedScrollHandler` hook.
2222

23-
**Solution:** You need to upgrade to React Native 0.81 (or newer), set experimental release level in order to enable `preventShadowTreeCommitExhaustion` feature flag and enable [`DISABLE_COMMIT_PAUSING_MECHANISM`](/docs/guides/feature-flags#disable_commit_pausing_mechanism) static feature flag as described [here](/docs/guides/feature-flags#disable_commit_pausing_mechanism).
23+
**Solution:** You need to upgrade to React Native 0.81 (or newer), enable `preventShadowTreeCommitExhaustion` React Native feature flag and enable [`DISABLE_COMMIT_PAUSING_MECHANISM`](/docs/guides/feature-flags#disable_commit_pausing_mechanism) static feature flag. For more details, click [here](/docs/guides/feature-flags#disable_commit_pausing_mechanism).
2424

2525
### ⚠️ Lower FPS while scrolling
2626

0 commit comments

Comments
 (0)