Skip to content

Commit f6fc30f

Browse files
committed
Sync scheduling by default, with an async opt-in
Removes the `useSyncScheduling` option from the HostConfig, since it's no longer needed. Instead of globally flipping between sync and async, our strategy will be to opt-in specific trees and subtrees.
1 parent 4d0e8fc commit f6fc30f

File tree

14 files changed

+9
-37
lines changed

14 files changed

+9
-37
lines changed

packages/react-art/src/ReactART.js

-2
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,6 @@ const ARTRenderer = ReactFiberReconciler({
478478

479479
now: ReactDOMFrameScheduling.now,
480480

481-
useSyncScheduling: true,
482-
483481
mutation: {
484482
appendChild(parentInstance, child) {
485483
if (child.parentNode === parentInstance) {

packages/react-cs-renderer/src/ReactNativeCS.js

-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ const ReactNativeCSFiberRenderer = ReactFiberReconciler({
182182
return false;
183183
},
184184

185-
useSyncScheduling: false,
186-
187185
now(): number {
188186
// TODO: Enable expiration by implementing this method.
189187
return 0;

packages/react-dom/src/client/ReactDOM.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ import * as EventPluginHub from 'events/EventPluginHub';
2828
import * as EventPluginRegistry from 'events/EventPluginRegistry';
2929
import * as EventPropagators from 'events/EventPropagators';
3030
import * as ReactInstanceMap from 'shared/ReactInstanceMap';
31-
import {
32-
enableAsyncSchedulingByDefaultInReactDOM,
33-
enableCreateRoot,
34-
} from 'shared/ReactFeatureFlags';
31+
import {enableCreateRoot} from 'shared/ReactFeatureFlags';
3532
import ReactVersion from 'shared/ReactVersion';
3633
import * as ReactDOMFrameScheduling from 'shared/ReactDOMFrameScheduling';
3734
import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState';
@@ -981,8 +978,6 @@ const DOMRenderer = ReactFiberReconciler({
981978

982979
scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,
983980
cancelDeferredCallback: ReactDOMFrameScheduling.cIC,
984-
985-
useSyncScheduling: !enableAsyncSchedulingByDefaultInReactDOM,
986981
});
987982

988983
ReactGenericBatching.injection.injectFiberBatchedUpdates(

packages/react-native-renderer/src/ReactNativeFiberRenderer.js

-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ const NativeRenderer = ReactFiberReconciler({
193193
return false;
194194
},
195195

196-
useSyncScheduling: true,
197-
198196
mutation: {
199197
appendChild(
200198
parentInstance: Instance,

packages/react-reconciler/src/ReactFiberBeginWork.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
invalidateContextProvider,
6060
} from './ReactFiberContext';
6161
import {NoWork, Never} from './ReactFiberExpirationTime';
62+
import {AsyncUpdates} from './ReactTypeOfInternalContext';
6263

6364
if (__DEV__) {
6465
var warnedAboutStatelessRefs = {};
@@ -71,11 +72,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
7172
scheduleWork: (fiber: Fiber, expirationTime: ExpirationTime) => void,
7273
computeExpirationForFiber: (fiber: Fiber) => ExpirationTime,
7374
) {
74-
const {
75-
shouldSetTextContent,
76-
useSyncScheduling,
77-
shouldDeprioritizeSubtree,
78-
} = config;
75+
const {shouldSetTextContent, shouldDeprioritizeSubtree} = config;
7976

8077
const {pushHostContext, pushHostContainer} = hostContext;
8178

@@ -403,7 +400,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
403400
// Check the host config to see if the children are offscreen/hidden.
404401
if (
405402
renderExpirationTime !== Never &&
406-
!useSyncScheduling &&
403+
workInProgress.internalContextTag & AsyncUpdates &&
407404
shouldDeprioritizeSubtree(type, nextProps)
408405
) {
409406
// Down-prioritize the children.

packages/react-reconciler/src/ReactFiberReconciler.js

-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export type HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL> = {
9595

9696
now(): number,
9797

98-
useSyncScheduling?: boolean,
99-
10098
+hydration?: HydrationHostConfig<T, P, I, TI, HI, C, CX, PL>,
10199

102100
+mutation?: MutableUpdatesHostConfig<T, P, I, TI, C, PL>,

packages/react-reconciler/src/ReactFiberScheduler.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
182182
now,
183183
scheduleDeferredCallback,
184184
cancelDeferredCallback,
185-
useSyncScheduling,
186185
prepareForCommit,
187186
resetAfterCommit,
188187
} = config;
@@ -1173,12 +1172,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
11731172
} else {
11741173
// No explicit expiration context was set, and we're not currently
11751174
// performing work. Calculate a new expiration time.
1176-
if (useSyncScheduling && !(fiber.internalContextTag & AsyncUpdates)) {
1177-
// This is a sync update
1178-
expirationTime = Sync;
1179-
} else {
1175+
if (fiber.internalContextTag & AsyncUpdates) {
11801176
// This is an async update
11811177
expirationTime = computeAsyncExpiration();
1178+
} else {
1179+
// This is a sync update
1180+
expirationTime = Sync;
11821181
}
11831182
}
11841183
return expirationTime;

packages/react-reconciler/src/__tests__/ReactFiberHostContext-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('ReactFiberHostContext', () => {
4545
now: function() {
4646
return 0;
4747
},
48-
useSyncScheduling: true,
4948
mutation: {
5049
appendChildToContainer: function() {
5150
return null;

packages/react-rt-renderer/src/ReactNativeRTFiberRenderer.js

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ const NativeRTRenderer = ReactFiberReconciler({
153153
return false;
154154
},
155155

156-
useSyncScheduling: true,
157-
158156
now(): number {
159157
// TODO: Enable expiration by implementing this method.
160158
return 0;

packages/react-test-renderer/src/ReactTestRenderer.js

-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ const TestRenderer = ReactFiberReconciler({
203203
clearTimeout(timeoutID);
204204
},
205205

206-
useSyncScheduling: true,
207-
208206
getPublicInstance,
209207

210208
now(): number {

packages/shared/ReactFeatureFlags.js

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import invariant from 'fbjs/lib/invariant';
1111

1212
export const enableAsyncSubtreeAPI = true;
13-
export const enableAsyncSchedulingByDefaultInReactDOM = false;
1413
// Exports ReactDOM.createRoot
1514
export const enableCreateRoot = false;
1615
export const enableUserTimingAPI = __DEV__;

packages/shared/forks/ReactFeatureFlags.native-cs.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import typeof * as CSFeatureFlagsType from './ReactFeatureFlags.native-cs';
1414

1515
export const debugRenderPhaseSideEffects = false;
1616
export const enableAsyncSubtreeAPI = true;
17-
export const enableAsyncSchedulingByDefaultInReactDOM = false;
1817
export const enableCreateRoot = false;
1918
export const enableUserTimingAPI = __DEV__;
2019

packages/shared/forks/ReactFeatureFlags.native.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const {debugRenderPhaseSideEffects} = require('ReactFeatureFlags');
1717

1818
// The rest of the flags are static for better dead code elimination.
1919
export const enableAsyncSubtreeAPI = true;
20-
export const enableAsyncSchedulingByDefaultInReactDOM = false;
2120
export const enableCreateRoot = false;
2221
export const enableUserTimingAPI = __DEV__;
2322
export const enableMutatingReconciler = true;

packages/shared/forks/ReactFeatureFlags.www.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
1111
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www';
1212

1313
// Re-export dynamic flags from the www version.
14-
export const {
15-
debugRenderPhaseSideEffects,
16-
enableAsyncSchedulingByDefaultInReactDOM,
17-
} = require('ReactFeatureFlags');
14+
export const {debugRenderPhaseSideEffects} = require('ReactFeatureFlags');
1815

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

0 commit comments

Comments
 (0)