mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
add feature flag to disable Choreographer callbacks in Paper infra
Summary: changelog: [internal] For constrained environments, we want to lower cpu usage of RN when the app is idle. `UIViewOperationQueue` and `EventDispatcherImpl` are not used in Fabric and therefore they do not need to run on each frame. Reviewed By: javache Differential Revision: D50741161 fbshipit-source-id: aa605893f1c8a4ac97a49bb7a6de2e2637a0832e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e2eb26c951
commit
4655f2063d
+8
@@ -174,4 +174,12 @@ public class ReactFeatureFlags {
|
||||
* in JS will be rejected (The JS error will include native stack)
|
||||
*/
|
||||
public static boolean rejectTurboModulePromiseOnNativeError = true;
|
||||
|
||||
/*
|
||||
* When the app is completely migrated to Fabric, set this flag to true to
|
||||
* disable parts of Paper infrastructre that are not needed anymore but consume
|
||||
* memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no
|
||||
* longer work as they won't subscribe to ReactChoregrapher for updates.
|
||||
*/
|
||||
public static boolean enableFabricRendererExclusively = false;
|
||||
}
|
||||
|
||||
+5
-2
@@ -25,6 +25,7 @@ import com.facebook.react.bridge.RetryableMountingLayerException;
|
||||
import com.facebook.react.bridge.SoftAssertions;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
|
||||
import com.facebook.systrace.Systrace;
|
||||
@@ -962,8 +963,10 @@ public class UIViewOperationQueue {
|
||||
|
||||
/* package */ void resumeFrameCallback() {
|
||||
mIsDispatchUIFrameCallbackEnqueued = true;
|
||||
ReactChoreographer.getInstance()
|
||||
.postFrameCallback(ReactChoreographer.CallbackType.DISPATCH_UI, mDispatchUIFrameCallback);
|
||||
if (!ReactFeatureFlags.enableFabricRendererExclusively) {
|
||||
ReactChoreographer.getInstance()
|
||||
.postFrameCallback(ReactChoreographer.CallbackType.DISPATCH_UI, mDispatchUIFrameCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ void pauseFrameCallback() {
|
||||
|
||||
+6
-2
@@ -14,6 +14,7 @@ import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.systrace.Systrace;
|
||||
@@ -315,8 +316,11 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe
|
||||
}
|
||||
|
||||
private void post() {
|
||||
ReactChoreographer.getInstance()
|
||||
.postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, mCurrentFrameCallback);
|
||||
if (!ReactFeatureFlags.enableFabricRendererExclusively) {
|
||||
ReactChoreographer.getInstance()
|
||||
.postFrameCallback(
|
||||
ReactChoreographer.CallbackType.TIMERS_EVENTS, mCurrentFrameCallback);
|
||||
}
|
||||
}
|
||||
|
||||
public void maybePostFromNonUI() {
|
||||
|
||||
Reference in New Issue
Block a user