Skip to content

Commit

Permalink
Land enableNativeEventPriorityInference
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Mar 8, 2021
1 parent 73e900b commit 9e06824
Show file tree
Hide file tree
Showing 16 changed files with 10 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
}

// @gate experimental
// @gate enableNativeEventPriorityInference
it('ignores discrete events on a pending removed element', async () => {
const disableButtonRef = React.createRef();
const submitButtonRef = React.createRef();
Expand Down Expand Up @@ -95,7 +94,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
});

// @gate experimental
// @gate enableNativeEventPriorityInference
it('ignores discrete events on a pending removed event listener', async () => {
const disableButtonRef = React.createRef();
const submitButtonRef = React.createRef();
Expand Down Expand Up @@ -165,7 +163,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
});

// @gate experimental
// @gate enableNativeEventPriorityInference
it('uses the newest discrete events on a pending changed event listener', async () => {
const enableButtonRef = React.createRef();
const submitButtonRef = React.createRef();
Expand Down Expand Up @@ -229,7 +226,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
});

// @gate experimental
// @gate enableNativeEventPriorityInference
it('mouse over should be user-blocking but not discrete', async () => {
const root = ReactDOM.unstable_createRoot(container);

Expand Down Expand Up @@ -260,7 +256,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
});

// @gate experimental
// @gate enableNativeEventPriorityInference
it('mouse enter should be user-blocking but not discrete', async () => {
const root = ReactDOM.unstable_createRoot(container);

Expand Down
20 changes: 6 additions & 14 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
LegacyRoot,
} from 'react-reconciler/src/ReactRootTags';

import {enableNativeEventPriorityInference} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import enqueueTask from 'shared/enqueueTask';
const {IsSomeRendererActing} = ReactSharedInternals;
Expand Down Expand Up @@ -934,19 +933,12 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
discreteUpdates: NoopRenderer.discreteUpdates,

idleUpdates<T>(fn: () => T): T {
if (enableNativeEventPriorityInference) {
const prevEventPriority = currentEventPriority;
currentEventPriority = NoopRenderer.IdleEventPriority;
try {
fn();
} finally {
currentEventPriority = prevEventPriority;
}
} else {
return Scheduler.unstable_runWithPriority(
Scheduler.unstable_IdlePriority,
fn,
);
const prevEventPriority = currentEventPriority;
currentEventPriority = NoopRenderer.IdleEventPriority;
try {
fn();
} finally {
currentEventPriority = prevEventPriority;
}
},

Expand Down
12 changes: 2 additions & 10 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
disableSchedulerTimeoutInWorkLoop,
enableStrictEffects,
skipUnmountedBoundaries,
enableNativeEventPriorityInference,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -456,15 +455,8 @@ export function requestUpdateLane(fiber: Fiber): Lane {
const currentLanePriority = getCurrentUpdateLanePriority();
lane = findUpdateLane(currentLanePriority);
} else {
if (enableNativeEventPriorityInference) {
const eventLanePriority = getCurrentEventPriority();
lane = findUpdateLane(eventLanePriority);
} else {
const schedulerLanePriority = schedulerPriorityToLanePriority(
schedulerPriority,
);
lane = findUpdateLane(schedulerLanePriority);
}
const eventLanePriority = getCurrentEventPriority();
lane = findUpdateLane(eventLanePriority);
}

return lane;
Expand Down
12 changes: 2 additions & 10 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
disableSchedulerTimeoutInWorkLoop,
enableStrictEffects,
skipUnmountedBoundaries,
enableNativeEventPriorityInference,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -456,15 +455,8 @@ export function requestUpdateLane(fiber: Fiber): Lane {
const currentLanePriority = getCurrentUpdateLanePriority();
lane = findUpdateLane(currentLanePriority);
} else {
if (enableNativeEventPriorityInference) {
const eventLanePriority = getCurrentEventPriority();
lane = findUpdateLane(eventLanePriority);
} else {
const schedulerLanePriority = schedulerPriorityToLanePriority(
schedulerPriority,
);
lane = findUpdateLane(schedulerLanePriority);
}
const eventLanePriority = getCurrentEventPriority();
lane = findUpdateLane(eventLanePriority);
}

return lane;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,66 +68,6 @@ describe('ReactSchedulerIntegration', () => {
);
}

// TODO: Figure out what to do with these tests. I don't think most of them
// make sense once we decouple Scheduler from React. Perhaps need similar
// tests for React DOM.
// @gate !enableNativeEventPriorityInference
it('has correct priority during rendering', () => {
function ReadPriority() {
Scheduler.unstable_yieldValue(
'Priority: ' + getCurrentPriorityAsString(),
);
return null;
}
ReactNoop.render(<ReadPriority />);
expect(Scheduler).toFlushAndYield(['Priority: Normal']);

runWithPriority(UserBlockingPriority, () => {
ReactNoop.render(<ReadPriority />);
});
expect(Scheduler).toFlushAndYield(['Priority: UserBlocking']);

runWithPriority(IdlePriority, () => {
ReactNoop.render(<ReadPriority />);
});
expect(Scheduler).toFlushAndYield(['Priority: Idle']);
});

// TODO: Figure out what to do with these tests. I don't think most of them
// make sense once we decouple Scheduler from React. Perhaps need similar
// tests for React DOM.
// @gate !enableNativeEventPriorityInference
it('has correct priority when continuing a render after yielding', () => {
function ReadPriority() {
Scheduler.unstable_yieldValue(
'Priority: ' + getCurrentPriorityAsString(),
);
return null;
}

runWithPriority(UserBlockingPriority, () => {
ReactNoop.render(
<>
<ReadPriority />
<ReadPriority />
<ReadPriority />
</>,
);
});

// Render part of the tree
expect(Scheduler).toFlushAndYieldThrough(['Priority: UserBlocking']);

// Priority is set back to normal when yielding
expect(getCurrentPriorityAsString()).toEqual('Normal');

// Priority is restored to user-blocking when continuing
expect(Scheduler).toFlushAndYield([
'Priority: UserBlocking',
'Priority: UserBlocking',
]);
});

it('passive effects are called before Normal-pri scheduled in layout effects', async () => {
const {useEffect, useLayoutEffect} = React;
function Effects({step}) {
Expand Down Expand Up @@ -172,28 +112,6 @@ describe('ReactSchedulerIntegration', () => {
]);
});

// TODO: Figure out what to do with these tests. I don't think most of them
// make sense once we decouple Scheduler from React. Perhaps need similar
// tests for React DOM.
// @gate !enableNativeEventPriorityInference
it('after completing a level of work, infers priority of the next batch based on its expiration time', () => {
function App({label}) {
Scheduler.unstable_yieldValue(
`${label} [${getCurrentPriorityAsString()}]`,
);
return label;
}

// Schedule two separate updates at different priorities
runWithPriority(UserBlockingPriority, () => {
ReactNoop.render(<App label="A" />);
});
ReactNoop.render(<App label="B" />);

// The second update should run at normal priority
expect(Scheduler).toFlushAndYield(['A [UserBlocking]', 'B [Normal]']);
});

it('requests a paint after committing', () => {
const scheduleCallback = Scheduler.unstable_scheduleCallback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ describe('useMutableSourceHydration', () => {
});

// @gate experimental
// @gate enableNativeEventPriorityInference
it('should detect a tear during a higher priority interruption', () => {
const source = createSource('one');
const mutableSource = createMutableSource(source, param => param.version);
Expand Down
2 changes: 0 additions & 2 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,4 @@ export const disableSchedulerTimeoutInWorkLoop = false;

export const enableSyncMicroTasks = false;

export const enableNativeEventPriorityInference = false;

export const enableLazyContextPropagation = false;
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.testing.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
export const enableRecursiveCommitTraversal = false;
export const disableSchedulerTimeoutInWorkLoop = false;
export const enableSyncMicroTasks = false;
export const enableNativeEventPriorityInference = false;
export const enableLazyContextPropagation = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ export const enableUseRefAccessWarning = __VARIANT__;
export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;
export const enableSyncMicroTasks = __VARIANT__;
export const enableNativeEventPriorityInference = __VARIANT__;
export const enableLazyContextPropagation = __VARIANT__;
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const {
disableNativeComponentFrames,
disableSchedulerTimeoutInWorkLoop,
enableSyncMicroTasks,
enableNativeEventPriorityInference,
enableLazyContextPropagation,
} = dynamicFeatureFlags;

Expand Down

0 comments on commit 9e06824

Please sign in to comment.