Skip to content

Commit

Permalink
Remove decoupleUpdatePriorityFromScheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Mar 8, 2021
1 parent 5fe091c commit e89d74e
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 542 deletions.
26 changes: 6 additions & 20 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree';

import {
enableLegacyFBSupport,
decoupleUpdatePriorityFromScheduler,
enableNewReconciler,
} from 'shared/ReactFeatureFlags';
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem';
Expand Down Expand Up @@ -177,25 +176,10 @@ function dispatchContinuousEvent(
container,
nativeEvent,
) {
if (decoupleUpdatePriorityFromScheduler) {
const previousPriority = getCurrentUpdateLanePriority();
try {
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
setCurrentUpdateLanePriority(InputContinuousLanePriority);
runWithPriority(
UserBlockingPriority,
dispatchEvent.bind(
null,
domEventName,
eventSystemFlags,
container,
nativeEvent,
),
);
} finally {
setCurrentUpdateLanePriority(previousPriority);
}
} else {
const previousPriority = getCurrentUpdateLanePriority();
try {
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
setCurrentUpdateLanePriority(InputContinuousLanePriority);
runWithPriority(
UserBlockingPriority,
dispatchEvent.bind(
Expand All @@ -206,6 +190,8 @@ function dispatchContinuousEvent(
nativeEvent,
),
);
} finally {
setCurrentUpdateLanePriority(previousPriority);
}
}

Expand Down
86 changes: 28 additions & 58 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
enableSchedulingProfiler,
enableNewReconciler,
enableCache,
decoupleUpdatePriorityFromScheduler,
enableUseRefAccessWarning,
enableStrictEffects,
enableLazyContextPropagation,
Expand Down Expand Up @@ -1713,66 +1712,37 @@ function rerenderDeferredValue<T>(value: T): T {

function startTransition(setPending, callback) {
const priorityLevel = getCurrentPriorityLevel();
if (decoupleUpdatePriorityFromScheduler) {
const previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
);
const previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
);

runWithPriority(
priorityLevel < UserBlockingPriority
? UserBlockingPriority
: priorityLevel,
() => {
setPending(true);
},
);
runWithPriority(
priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
() => {
setPending(true);
},
);

// TODO: Can remove this. Was only necessary because we used to give
// different behavior to transitions without a config object. Now they are
// all treated the same.
setCurrentUpdateLanePriority(DefaultLanePriority);
// TODO: Can remove this. Was only necessary because we used to give
// different behavior to transitions without a config object. Now they are
// all treated the same.
setCurrentUpdateLanePriority(DefaultLanePriority);

runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
if (decoupleUpdatePriorityFromScheduler) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
} else {
runWithPriority(
priorityLevel < UserBlockingPriority
? UserBlockingPriority
: priorityLevel,
() => {
setPending(true);
},
);

runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
}
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
setCurrentUpdateLanePriority(previousLanePriority);
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
}

function mountTransition(): [(() => void) => void, boolean] {
Expand Down
86 changes: 28 additions & 58 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
enableSchedulingProfiler,
enableNewReconciler,
enableCache,
decoupleUpdatePriorityFromScheduler,
enableUseRefAccessWarning,
enableStrictEffects,
enableLazyContextPropagation,
Expand Down Expand Up @@ -1713,66 +1712,37 @@ function rerenderDeferredValue<T>(value: T): T {

function startTransition(setPending, callback) {
const priorityLevel = getCurrentPriorityLevel();
if (decoupleUpdatePriorityFromScheduler) {
const previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
);
const previousLanePriority = getCurrentUpdateLanePriority();
setCurrentUpdateLanePriority(
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
);

runWithPriority(
priorityLevel < UserBlockingPriority
? UserBlockingPriority
: priorityLevel,
() => {
setPending(true);
},
);
runWithPriority(
priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
() => {
setPending(true);
},
);

// TODO: Can remove this. Was only necessary because we used to give
// different behavior to transitions without a config object. Now they are
// all treated the same.
setCurrentUpdateLanePriority(DefaultLanePriority);
// TODO: Can remove this. Was only necessary because we used to give
// different behavior to transitions without a config object. Now they are
// all treated the same.
setCurrentUpdateLanePriority(DefaultLanePriority);

runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
if (decoupleUpdatePriorityFromScheduler) {
setCurrentUpdateLanePriority(previousLanePriority);
}
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
} else {
runWithPriority(
priorityLevel < UserBlockingPriority
? UserBlockingPriority
: priorityLevel,
() => {
setPending(true);
},
);

runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
}
runWithPriority(
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
() => {
const prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = 1;
try {
setPending(false);
callback();
} finally {
setCurrentUpdateLanePriority(previousLanePriority);
ReactCurrentBatchConfig.transition = prevTransition;
}
},
);
}

function mountTransition(): [(() => void) => void, boolean] {
Expand Down
Loading

0 comments on commit e89d74e

Please sign in to comment.