Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature flag for setting update lane priority #19401

Merged
merged 5 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove second feature flag
  • Loading branch information
rickhanlonii committed Aug 6, 2020
commit 287a1f031054c3f18324eb5bf8eb38cf2cb4fb17
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import {
enableDeprecatedFlareAPI,
enableSetUpdateLanePriority,
decoupleUpdatePriorityFromScheduler,
} from 'shared/ReactFeatureFlags';
import invariant from 'shared/invariant';

Expand Down Expand Up @@ -111,7 +111,7 @@ const eventResponderContext: ReactDOMResponderContext = {
break;
}
case UserBlockingEvent: {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
const previousPriority = getCurrentUpdateLanePriority();
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree';
import {
enableDeprecatedFlareAPI,
enableLegacyFBSupport,
enableSetUpdateLanePriority,
decoupleUpdatePriorityFromScheduler,
} from 'shared/ReactFeatureFlags';
import {
UserBlockingEvent,
Expand Down Expand Up @@ -154,7 +154,7 @@ function dispatchUserBlockingUpdate(
container,
nativeEvent,
) {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
const previousPriority = getCurrentUpdateLanePriority();
try {
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
enableNewReconciler,
enableSetUpdateLanePriority,
decoupleUpdatePriorityFromScheduler,
} from 'shared/ReactFeatureFlags';

import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
Expand Down Expand Up @@ -1511,7 +1511,7 @@ function rerenderDeferredValue<T>(
function startTransition(setPending, config, callback) {
const priorityLevel = getCurrentPriorityLevel();
let previousLanePriority;
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
Expand All @@ -1524,7 +1524,7 @@ function startTransition(setPending, config, callback) {
},
);

if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
// If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
setCurrentUpdateLanePriority(DefaultLanePriority);
}
Expand All @@ -1538,7 +1538,7 @@ function startTransition(setPending, config, callback) {
setPending(false);
callback();
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.suspense = previousConfig;
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
enableNewReconciler,
enableSetUpdateLanePriority,
decoupleUpdatePriorityFromScheduler,
} from 'shared/ReactFeatureFlags';

import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
Expand Down Expand Up @@ -1511,7 +1511,7 @@ function rerenderDeferredValue<T>(
function startTransition(setPending, config, callback) {
const priorityLevel = getCurrentPriorityLevel();
let previousLanePriority;
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
Expand All @@ -1524,7 +1524,7 @@ function startTransition(setPending, config, callback) {
},
);

if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
// If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
setCurrentUpdateLanePriority(DefaultLanePriority);
}
Expand All @@ -1538,7 +1538,7 @@ function startTransition(setPending, config, callback) {
setPending(false);
callback();
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.suspense = previousConfig;
Expand Down
27 changes: 13 additions & 14 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
enableScopeAPI,
enableSetUpdateLanePriority,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -478,7 +477,7 @@ export function requestUpdateLane(
schedulerPriority,
);

if (enableSetUpdateLanePriority && decoupleUpdatePriorityFromScheduler) {
if (decoupleUpdatePriorityFromScheduler) {
// In the new strategy, we will track the current update lane priority
// inside React and use that priority to select a lane for this update.
// For now, we're just logging when they're different so we can assess.
Expand Down Expand Up @@ -1145,13 +1144,13 @@ export function flushDiscreteUpdates() {
export function deferredUpdates<A>(fn: () => A): A {
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(DefaultLanePriority);
}
return runWithPriority(NormalSchedulerPriority, fn);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
}
Expand Down Expand Up @@ -1211,7 +1210,7 @@ export function discreteUpdates<A, B, C, D, R>(
executionContext |= DiscreteEventContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(InputDiscreteLanePriority);
}
Expand All @@ -1221,7 +1220,7 @@ export function discreteUpdates<A, B, C, D, R>(
fn.bind(null, a, b, c, d),
);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand Down Expand Up @@ -1262,7 +1261,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
executionContext |= BatchedContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
Expand All @@ -1272,7 +1271,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
return (undefined: $FlowFixMe);
}
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand All @@ -1288,13 +1287,13 @@ export function flushControlled(fn: () => mixed): void {
executionContext |= BatchedContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
rickhanlonii marked this conversation as resolved.
Show resolved Hide resolved
setCurrentUpdateLanePriority(SyncLanePriority);
}
runWithPriority(ImmediateSchedulerPriority, fn);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand Down Expand Up @@ -2111,7 +2110,7 @@ function commitRootImpl(root, renderPriorityLevel) {

if (firstEffect !== null) {
let previousLanePriority;
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
Expand Down Expand Up @@ -2191,7 +2190,7 @@ function commitRootImpl(root, renderPriorityLevel) {
}
executionContext = prevExecutionContext;

if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
// Reset the priority to the previous non-sync value.
setCurrentUpdateLanePriority(previousLanePriority);
}
Expand Down Expand Up @@ -2634,15 +2633,15 @@ export function flushPassiveEffects() {
pendingPassiveEffectsRenderPriority = NoSchedulerPriority;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
schedulerPriorityToLanePriority(priorityLevel),
);
}
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
}
Expand Down
27 changes: 13 additions & 14 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
enableScopeAPI,
enableSetUpdateLanePriority,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -471,7 +470,7 @@ export function requestUpdateLane(
schedulerPriority,
);

if (enableSetUpdateLanePriority && decoupleUpdatePriorityFromScheduler) {
if (decoupleUpdatePriorityFromScheduler) {
// In the new strategy, we will track the current update lane priority
// inside React and use that priority to select a lane for this update.
// For now, we're just logging when they're different so we can assess.
Expand Down Expand Up @@ -1138,13 +1137,13 @@ export function flushDiscreteUpdates() {
export function deferredUpdates<A>(fn: () => A): A {
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(DefaultLanePriority);
}
return runWithPriority(NormalSchedulerPriority, fn);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
}
Expand Down Expand Up @@ -1204,7 +1203,7 @@ export function discreteUpdates<A, B, C, D, R>(
executionContext |= DiscreteEventContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(InputDiscreteLanePriority);
}
Expand All @@ -1214,7 +1213,7 @@ export function discreteUpdates<A, B, C, D, R>(
fn.bind(null, a, b, c, d),
);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand Down Expand Up @@ -1255,7 +1254,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
executionContext |= BatchedContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
Expand All @@ -1265,7 +1264,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
return (undefined: $FlowFixMe);
}
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand All @@ -1281,13 +1280,13 @@ export function flushControlled(fn: () => mixed): void {
executionContext |= BatchedContext;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
runWithPriority(ImmediateSchedulerPriority, fn);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
executionContext = prevExecutionContext;
Expand Down Expand Up @@ -2029,7 +2028,7 @@ function commitRootImpl(root, renderPriorityLevel) {

if (firstEffect !== null) {
let previousLanePriority;
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
Expand Down Expand Up @@ -2155,7 +2154,7 @@ function commitRootImpl(root, renderPriorityLevel) {
}
executionContext = prevExecutionContext;

if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
// Reset the priority to the previous non-sync value.
setCurrentUpdateLanePriority(previousLanePriority);
}
Expand Down Expand Up @@ -2478,15 +2477,15 @@ export function flushPassiveEffects() {
pendingPassiveEffectsRenderPriority = NoSchedulerPriority;
let previousLanePriority;
try {
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
schedulerPriorityToLanePriority(priorityLevel),
);
}
return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as Scheduler from 'scheduler';
import {__interactionsRef} from 'scheduler/tracing';
import {
enableSchedulerTracing,
enableSetUpdateLanePriority,
decoupleUpdatePriorityFromScheduler,
} from 'shared/ReactFeatureFlags';
import invariant from 'shared/invariant';
import {
Expand Down Expand Up @@ -183,7 +183,7 @@ function flushSyncCallbackQueueImpl() {
try {
const isSync = true;
const queue = syncQueue;
if (enableSetUpdateLanePriority) {
if (decoupleUpdatePriorityFromScheduler) {
previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(SyncLanePriority);
}
Expand All @@ -208,7 +208,7 @@ function flushSyncCallbackQueueImpl() {
);
throw error;
} finally {
if (enableSetUpdateLanePriority && previousLanePriority != null) {
if (decoupleUpdatePriorityFromScheduler && previousLanePriority != null) {
setCurrentUpdateLanePriority(previousLanePriority);
}
isFlushingSyncQueue = false;
Expand Down
Loading