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

Sync scheduling by default, with an async opt-in #11771

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions packages/react-art/src/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ const ARTRenderer = ReactFiberReconciler({

now: ReactDOMFrameScheduling.now,

useSyncScheduling: true,

mutation: {
appendChild(parentInstance, child) {
if (child.parentNode === parentInstance) {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-cs-renderer/src/ReactNativeCS.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ const ReactNativeCSFiberRenderer = ReactFiberReconciler({
return false;
},

useSyncScheduling: false,

now(): number {
// TODO: Enable expiration by implementing this method.
return 0;
Expand Down
7 changes: 1 addition & 6 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ import * as EventPluginHub from 'events/EventPluginHub';
import * as EventPluginRegistry from 'events/EventPluginRegistry';
import * as EventPropagators from 'events/EventPropagators';
import * as ReactInstanceMap from 'shared/ReactInstanceMap';
import {
enableAsyncSchedulingByDefaultInReactDOM,
enableCreateRoot,
} from 'shared/ReactFeatureFlags';
import {enableCreateRoot} from 'shared/ReactFeatureFlags';
import ReactVersion from 'shared/ReactVersion';
import * as ReactDOMFrameScheduling from 'shared/ReactDOMFrameScheduling';
import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState';
Expand Down Expand Up @@ -981,8 +978,6 @@ const DOMRenderer = ReactFiberReconciler({

scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,
cancelDeferredCallback: ReactDOMFrameScheduling.cIC,

useSyncScheduling: !enableAsyncSchedulingByDefaultInReactDOM,
});

ReactGenericBatching.injection.injectFiberBatchedUpdates(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ const NativeRenderer = ReactFiberReconciler({
return false;
},

useSyncScheduling: true,

mutation: {
appendChild(
parentInstance: Instance,
Expand Down
9 changes: 3 additions & 6 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
invalidateContextProvider,
} from './ReactFiberContext';
import {NoWork, Never} from './ReactFiberExpirationTime';
import {AsyncUpdates} from './ReactTypeOfInternalContext';

if (__DEV__) {
var warnedAboutStatelessRefs = {};
Expand All @@ -71,11 +72,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
scheduleWork: (fiber: Fiber, expirationTime: ExpirationTime) => void,
computeExpirationForFiber: (fiber: Fiber) => ExpirationTime,
) {
const {
shouldSetTextContent,
useSyncScheduling,
shouldDeprioritizeSubtree,
} = config;
const {shouldSetTextContent, shouldDeprioritizeSubtree} = config;

const {pushHostContext, pushHostContainer} = hostContext;

Expand Down Expand Up @@ -403,7 +400,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
// Check the host config to see if the children are offscreen/hidden.
if (
renderExpirationTime !== Never &&
!useSyncScheduling &&
workInProgress.internalContextTag & AsyncUpdates &&
shouldDeprioritizeSubtree(type, nextProps)
) {
// Down-prioritize the children.
Expand Down
2 changes: 0 additions & 2 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ export type HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL> = {

now(): number,

useSyncScheduling?: boolean,

+hydration?: HydrationHostConfig<T, P, I, TI, HI, C, CX, PL>,

+mutation?: MutableUpdatesHostConfig<T, P, I, TI, C, PL>,
Expand Down
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
now,
scheduleDeferredCallback,
cancelDeferredCallback,
useSyncScheduling,
prepareForCommit,
resetAfterCommit,
} = config;
Expand Down Expand Up @@ -1173,12 +1172,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
} else {
// No explicit expiration context was set, and we're not currently
// performing work. Calculate a new expiration time.
if (useSyncScheduling && !(fiber.internalContextTag & AsyncUpdates)) {
// This is a sync update
expirationTime = Sync;
} else {
if (fiber.internalContextTag & AsyncUpdates) {
// This is an async update
expirationTime = computeAsyncExpiration();
} else {
// This is a sync update
expirationTime = Sync;
}
}
return expirationTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe('ReactFiberHostContext', () => {
now: function() {
return 0;
},
useSyncScheduling: true,
mutation: {
appendChildToContainer: function() {
return null;
Expand Down
2 changes: 0 additions & 2 deletions packages/react-rt-renderer/src/ReactNativeRTFiberRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ const NativeRTRenderer = ReactFiberReconciler({
return false;
},

useSyncScheduling: true,

now(): number {
// TODO: Enable expiration by implementing this method.
return 0;
Expand Down
2 changes: 0 additions & 2 deletions packages/react-test-renderer/src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ const TestRenderer = ReactFiberReconciler({
clearTimeout(timeoutID);
},

useSyncScheduling: true,

getPublicInstance,

now(): number {
Expand Down
1 change: 0 additions & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import invariant from 'fbjs/lib/invariant';

export const enableAsyncSubtreeAPI = true;
export const enableAsyncSchedulingByDefaultInReactDOM = false;
// Exports ReactDOM.createRoot
export const enableCreateRoot = false;
export const enableUserTimingAPI = __DEV__;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import typeof * as CSFeatureFlagsType from './ReactFeatureFlags.native-cs';

export const debugRenderPhaseSideEffects = false;
export const enableAsyncSubtreeAPI = true;
export const enableAsyncSchedulingByDefaultInReactDOM = false;
export const enableCreateRoot = false;
export const enableUserTimingAPI = __DEV__;

Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const {debugRenderPhaseSideEffects} = require('ReactFeatureFlags');

// The rest of the flags are static for better dead code elimination.
export const enableAsyncSubtreeAPI = true;
export const enableAsyncSchedulingByDefaultInReactDOM = false;
export const enableCreateRoot = false;
export const enableUserTimingAPI = __DEV__;
export const enableMutatingReconciler = true;
Expand Down
5 changes: 1 addition & 4 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www';

// Re-export dynamic flags from the www version.
export const {
debugRenderPhaseSideEffects,
enableAsyncSchedulingByDefaultInReactDOM,
} = require('ReactFeatureFlags');
export const {debugRenderPhaseSideEffects} = require('ReactFeatureFlags');

// The rest of the flags are static for better dead code elimination.
export const enableAsyncSubtreeAPI = true;
Expand Down