mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
This flag first moves the `shouldYield()` logic into React itself. We need this for `postTask` compatibility anyway since this logic is no longer a concern of the scheduler. This means that there can also be no global `requestPaint()` that asks for painting earlier. So this is best rolled out with `enableAlwaysYieldScheduler` (and ideally `enableYieldingBeforePassive`) instead of `enableRequestPaint`. Once in React we can change the yield timing heuristics. This uses the previous 5ms for Idle work to keep everything responsive while doing background work. However, for Transitions and Retries we have seen that same thread animations (like loading states animating, or constant animations like cool Three.js stuff) can take CPU time away from the Transition that causes moving into new content to slow down. Therefore we only yield every 25ms. The purpose of this yield is not to avoid the overhead of yielding, which is very low, but rather to intentionally block any frequently occurring other main thread work like animations from starving our work. If we could we could just tell everyone else to throttle their stuff for ideal scheduling but that's not quite realistic. In other words, the purpose of this is to reduce the frame rate of animations to 30 fps and we achieve this by not yielding. We still do yield to allow the animations to not just stall. This seems like a good balance. The 5ms of Idle is because we don't really need to yield less often since the overhead is low. We keep it low to allow 120 fps animations to run if necessary and our work may not be the only work within a frame so we need to yield early enough to leave enough time left. Similarly we choose 25ms rather than say 35ms to ensure that we push long enough to guarantee to half the frame rate but low enough that there's plenty of time left for a rAF to power each animation every other frame. It's also low enough that if something else interrupts the work like a new interaction, we can still be responsive to that within 50ms or so. We also need to yield in case there's I/O work that needs to get bounced through the main thread. This flag is currently off everywhere since we have so many other scheduling flags but that means there's some urgency to roll those out fully so we can test this one. There's also some tests to update since this doesn't go through the Mock scheduler anymore for yields.
88 lines
3.7 KiB
JavaScript
88 lines
3.7 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
|
|
import typeof * as ExportsType from './ReactFeatureFlags.native-fb';
|
|
import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynamic';
|
|
|
|
// Re-export dynamic flags from the internal module.
|
|
// Intentionally using * because this import is compiled to a `require` call.
|
|
import * as dynamicFlagsUntyped from 'ReactNativeInternalFeatureFlags';
|
|
const dynamicFlags: DynamicExportsType = (dynamicFlagsUntyped: any);
|
|
|
|
// We destructure each value before re-exporting to avoid a dynamic look-up on
|
|
// the exports object every time a flag is read.
|
|
export const {
|
|
alwaysThrottleRetries,
|
|
enableFabricCompleteRootInCommitPhase,
|
|
enableHiddenSubtreeInsertionEffectCleanup,
|
|
enableObjectFiber,
|
|
enablePersistedModeClonedFlag,
|
|
enableShallowPropDiffing,
|
|
enableUseResourceEffectHook,
|
|
passChildrenWhenCloningPersistedNodes,
|
|
enableSiblingPrerendering,
|
|
enableOwnerStacks,
|
|
} = dynamicFlags;
|
|
|
|
// The rest of the flags are static for better dead code elimination.
|
|
export const disableClientCache = true;
|
|
export const disableCommentsAsDOMContainers = true;
|
|
export const disableDefaultPropsExceptForClasses = true;
|
|
export const disableInputAttributeSyncing = false;
|
|
export const disableLegacyContext = false;
|
|
export const disableLegacyContextForFunctionComponents = false;
|
|
export const disableLegacyMode = false;
|
|
export const disableSchedulerTimeoutInWorkLoop = false;
|
|
export const disableTextareaChildren = false;
|
|
export const enableAsyncDebugInfo = false;
|
|
export const enableAsyncIterableChildren = false;
|
|
export const enableCPUSuspense = true;
|
|
export const enableCreateEventHandleAPI = false;
|
|
export const enableDeferRootSchedulingToMicrotask = true;
|
|
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
|
|
export const enableMoveBefore = true;
|
|
export const enableFizzExternalRuntime = true;
|
|
export const enableGetInspectorDataForInstanceInProduction = true;
|
|
export const enableHalt = false;
|
|
export const enableInfiniteRenderLoopDetection = false;
|
|
export const enableLegacyCache = false;
|
|
export const enableLegacyFBSupport = false;
|
|
export const enableLegacyHidden = false;
|
|
export const enableNoCloningMemoCache = false;
|
|
export const enablePostpone = false;
|
|
export const enableProfilerCommitHooks = __PROFILE__;
|
|
export const enableProfilerNestedUpdatePhase = __PROFILE__;
|
|
export const enableProfilerTimer = __PROFILE__;
|
|
export const enableReactTestRendererWarning = false;
|
|
export const enableRenderableContext = true;
|
|
export const enableRetryLaneExpiration = false;
|
|
export const enableSchedulingProfiler = __PROFILE__;
|
|
export const enableComponentPerformanceTrack = false;
|
|
export const enableScopeAPI = false;
|
|
export const enableServerComponentLogs = true;
|
|
export const enableSuspenseAvoidThisFallback = false;
|
|
export const enableSuspenseCallback = true;
|
|
export const enableTaint = true;
|
|
export const enableTransitionTracing = false;
|
|
export const enableTrustedTypesIntegration = false;
|
|
export const enableUpdaterTracking = __PROFILE__;
|
|
export const enableUseEffectEventHook = false;
|
|
export const favorSafetyOverHydrationPerf = true;
|
|
export const renameElementSymbol = false;
|
|
export const retryLaneExpirationMs = 5000;
|
|
export const syncLaneExpirationMs = 250;
|
|
export const transitionLaneExpirationMs = 5000;
|
|
export const enableHydrationLaneScheduling = true;
|
|
export const enableYieldingBeforePassive = false;
|
|
export const enableThrottledScheduling = false;
|
|
|
|
// Flow magic to verify the exports of this file match the original version.
|
|
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
|