Skip to content

Commit 13c5e2b

Browse files
authored
Sync scheduling by default, with an async opt-in (#11771)
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 2618575 commit 13c5e2b

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';
@@ -990,8 +987,6 @@ const DOMRenderer = ReactFiberReconciler({
990987

991988
scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,
992989
cancelDeferredCallback: ReactDOMFrameScheduling.cIC,
993-
994-
useSyncScheduling: !enableAsyncSchedulingByDefaultInReactDOM,
995990
});
996991

997992
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
@@ -58,6 +58,7 @@ import {
5858
invalidateContextProvider,
5959
} from './ReactFiberContext';
6060
import {NoWork, Never} from './ReactFiberExpirationTime';
61+
import {AsyncUpdates} from './ReactTypeOfInternalContext';
6162

6263
let warnedAboutStatelessRefs;
6364

@@ -72,11 +73,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
7273
scheduleWork: (fiber: Fiber, expirationTime: ExpirationTime) => void,
7374
computeExpirationForFiber: (fiber: Fiber) => ExpirationTime,
7475
) {
75-
const {
76-
shouldSetTextContent,
77-
useSyncScheduling,
78-
shouldDeprioritizeSubtree,
79-
} = config;
76+
const {shouldSetTextContent, shouldDeprioritizeSubtree} = config;
8077

8178
const {pushHostContext, pushHostContainer} = hostContext;
8279

@@ -414,7 +411,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
414411
// Check the host config to see if the children are offscreen/hidden.
415412
if (
416413
renderExpirationTime !== Never &&
417-
!useSyncScheduling &&
414+
workInProgress.internalContextTag & AsyncUpdates &&
418415
shouldDeprioritizeSubtree(type, nextProps)
419416
) {
420417
// Down-prioritize the children.

packages/react-reconciler/src/ReactFiberReconciler.js

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

9999
now(): number,
100100

101-
useSyncScheduling?: boolean,
102-
103101
+hydration?: HydrationHostConfig<T, P, I, TI, HI, C, CX, PL>,
104102

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

packages/react-reconciler/src/ReactFiberScheduler.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
187187
now,
188188
scheduleDeferredCallback,
189189
cancelDeferredCallback,
190-
useSyncScheduling,
191190
prepareForCommit,
192191
resetAfterCommit,
193192
} = config;
@@ -1178,12 +1177,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
11781177
} else {
11791178
// No explicit expiration context was set, and we're not currently
11801179
// performing work. Calculate a new expiration time.
1181-
if (useSyncScheduling && !(fiber.internalContextTag & AsyncUpdates)) {
1182-
// This is a sync update
1183-
expirationTime = Sync;
1184-
} else {
1180+
if (fiber.internalContextTag & AsyncUpdates) {
11851181
// This is an async update
11861182
expirationTime = computeAsyncExpiration();
1183+
} else {
1184+
// This is a sync update
1185+
expirationTime = Sync;
11871186
}
11881187
}
11891188
return expirationTime;

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

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ describe('ReactFiberHostContext', () => {
4646
now: function() {
4747
return 0;
4848
},
49-
useSyncScheduling: true,
5049
mutation: {
5150
appendChildToContainer: function() {
5251
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)