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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 6 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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 {

0 commit comments

Comments
 (0)