Skip to content

Commit

Permalink
Add feature flag to use microtasks in the React Native Fabric renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Sep 12, 2023
1 parent 41f0e9d commit d14e50d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react-native-renderer/src/ReactFiberConfigFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const {
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
} = nativeFabricUIManager;

import {diffInCommitPhase} from 'shared/ReactFeatureFlags';
import {diffInCommitPhase, useMicrotasksForSchedulingInFabric} from 'shared/ReactFeatureFlags';

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

Expand Down Expand Up @@ -122,7 +122,6 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoMutation';
export * from 'react-reconciler/src/ReactFiberConfigWithNoHydration';
export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
export * from 'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
export * from 'react-reconciler/src/ReactFiberConfigWithNoMicrotasks';
export * from 'react-reconciler/src/ReactFiberConfigWithNoResources';
export * from 'react-reconciler/src/ReactFiberConfigWithNoSingletons';

Expand Down Expand Up @@ -499,3 +498,9 @@ export function waitForCommitToBeReady(): null {
}

export const NotPendingTransition: TransitionStatus = null;

// -------------------
// Microtasks
// -------------------
export const supportsMicrotasks = useMicrotasksForSchedulingInFabric;
export const scheduleMicrotask: any = typeof queueMicrotask === 'function' ? queueMicrotask : scheduleTimeout;
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export const enableAsyncActions = __EXPERIMENTAL__;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

// -----------------------------------------------------------------------------
// Chopping Block
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
export const enableUseRefAccessWarning = __VARIANT__;
export const enableDeferRootSchedulingToMicrotask = __VARIANT__;
export const alwaysThrottleRetries = __VARIANT__;
export const useMicrotasksForSchedulingInFabric = __VARIANT__;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): DynamicFlagsType): ExportsType);
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const {
enableUseRefAccessWarning,
enableDeferRootSchedulingToMicrotask,
alwaysThrottleRetries,
useMicrotasksForSchedulingInFabric,
} = dynamicFlags;

// The rest of the flags are static for better dead code elimination.
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ export const enableAsyncActions = false;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ export const enableAsyncActions = false;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ export const enableAsyncActions = false;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ export const enableAsyncActions = false;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@ export const enableFizzExternalRuntime = true;

export const forceConcurrentByDefaultForTesting = false;

export const useMicrotasksForSchedulingInFabric = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
1 change: 1 addition & 0 deletions scripts/flow/xplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ declare module 'ReactNativeInternalFeatureFlags' {
declare export var enableUseRefAccessWarning: boolean;
declare export var enableDeferRootSchedulingToMicrotask: boolean;
declare export var alwaysThrottleRetries: boolean;
declare export var useMicrotasksForSchedulingInFabric: boolean;
}

0 comments on commit d14e50d

Please sign in to comment.