Skip to content

Commit 66ea49b

Browse files
committed
Revert "Feature: Suspend commit without blocking render (facebook#26398)"
This reverts commit db281b3.
1 parent 75e9afd commit 66ea49b

23 files changed

+130
-894
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,6 @@ export function requestPostPaintCallback(callback: (time: number) => void) {
459459
// noop
460460
}
461461

462-
export function shouldSuspendCommit(type, props) {
463-
return false;
464-
}
465-
466-
export function startSuspendingCommit() {}
467-
468-
export function suspendInstance(type, props) {}
469-
470-
export function waitForCommitToBeReady() {
471-
return null;
472-
}
473462
// eslint-disable-next-line no-undef
474463
export function prepareRendererToRender(container: Container): void {
475464
// noop

packages/react-dom-bindings/src/client/ReactDOMHostConfig.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,19 +1608,6 @@ export function requestPostPaintCallback(callback: (time: number) => void) {
16081608
localRequestAnimationFrame(time => callback(time));
16091609
});
16101610
}
1611-
1612-
export function shouldSuspendCommit(type: Type, props: Props): boolean {
1613-
return false;
1614-
}
1615-
1616-
export function startSuspendingCommit(): void {}
1617-
1618-
export function suspendInstance(type: Type, props: Props): void {}
1619-
1620-
export function waitForCommitToBeReady(): null {
1621-
return null;
1622-
}
1623-
16241611
// -------------------
16251612
// Resources
16261613
// -------------------

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,18 +421,6 @@ export function requestPostPaintCallback(callback: (time: number) => void) {
421421
// noop
422422
}
423423

424-
export function shouldSuspendCommit(type: Type, props: Props): boolean {
425-
return false;
426-
}
427-
428-
export function startSuspendingCommit(): void {}
429-
430-
export function suspendInstance(type: Type, props: Props): void {}
431-
432-
export function waitForCommitToBeReady(): null {
433-
return null;
434-
}
435-
436424
export function prepareRendererToRender(container: Container): void {
437425
// noop
438426
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,6 @@ export function requestPostPaintCallback(callback: (time: number) => void) {
522522
// noop
523523
}
524524

525-
export function shouldSuspendCommit(type: Type, props: Props): boolean {
526-
return false;
527-
}
528-
529-
export function startSuspendingCommit(): void {}
530-
531-
export function suspendInstance(type: Type, props: Props): void {}
532-
533-
export function waitForCommitToBeReady(): null {
534-
return null;
535-
}
536-
537525
export function prepareRendererToRender(container: Container): void {
538526
// noop
539527
}

packages/react-noop-renderer/src/ReactNoop.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export const {
2828
createLegacyRoot,
2929
getChildrenAsJSX,
3030
getPendingChildrenAsJSX,
31-
getSuspenseyThingStatus,
32-
resolveSuspenseyThing,
33-
resetSuspenseyThingCache,
3431
createPortal,
3532
render,
3633
renderLegacySyncRoot,

packages/react-noop-renderer/src/ReactNoopPersistent.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export const {
2828
createLegacyRoot,
2929
getChildrenAsJSX,
3030
getPendingChildrenAsJSX,
31-
getSuspenseyThingStatus,
32-
resolveSuspenseyThing,
33-
resetSuspenseyThingCache,
3431
createPortal,
3532
render,
3633
renderLegacySyncRoot,

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 0 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type Props = {
4747
left?: null | number,
4848
right?: null | number,
4949
top?: null | number,
50-
src?: string,
5150
...
5251
};
5352
type Instance = {
@@ -73,11 +72,6 @@ type CreateRootOptions = {
7372
...
7473
};
7574

76-
type SuspenseyCommitSubscription = {
77-
pendingCount: number,
78-
commit: null | (() => void),
79-
};
80-
8175
const NO_CONTEXT = {};
8276
const UPPERCASE_CONTEXT = {};
8377
const UPDATE_SIGNAL = {};
@@ -244,11 +238,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
244238
hidden: !!newProps.hidden,
245239
context: instance.context,
246240
};
247-
248-
if (type === 'suspensey-thing' && typeof newProps.src === 'string') {
249-
clone.src = newProps.src;
250-
}
251-
252241
Object.defineProperty(clone, 'id', {
253242
value: clone.id,
254243
enumerable: false,
@@ -282,78 +271,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
282271
return hostContext === UPPERCASE_CONTEXT ? rawText.toUpperCase() : rawText;
283272
}
284273

285-
type SuspenseyThingRecord = {
286-
status: 'pending' | 'fulfilled',
287-
subscriptions: Array<SuspenseyCommitSubscription> | null,
288-
};
289-
290-
let suspenseyThingCache: Map<
291-
SuspenseyThingRecord,
292-
'pending' | 'fulfilled',
293-
> | null = null;
294-
295-
// Represents a subscription for all the suspensey things that block a
296-
// particular commit. Once they've all loaded, the commit phase can proceed.
297-
let suspenseyCommitSubscription: SuspenseyCommitSubscription | null = null;
298-
299-
function startSuspendingCommit(): void {
300-
// This is where we might suspend on things that aren't associated with a
301-
// particular node, like document.fonts.ready.
302-
suspenseyCommitSubscription = null;
303-
}
304-
305-
function suspendInstance(type: string, props: Props): void {
306-
const src = props.src;
307-
if (type === 'suspensey-thing' && typeof src === 'string') {
308-
// Attach a listener to the suspensey thing and create a subscription
309-
// object that uses reference counting to track when all the suspensey
310-
// things have loaded.
311-
const record = suspenseyThingCache.get(src);
312-
if (record === undefined) {
313-
throw new Error('Could not find record for key.');
314-
}
315-
if (record.status === 'pending') {
316-
if (suspenseyCommitSubscription === null) {
317-
suspenseyCommitSubscription = {
318-
pendingCount: 1,
319-
commit: null,
320-
};
321-
} else {
322-
suspenseyCommitSubscription.pendingCount++;
323-
}
324-
}
325-
// Stash the subscription on the record. In `resolveSuspenseyThing`,
326-
// we'll use this fire the commit once all the things have loaded.
327-
if (record.subscriptions === null) {
328-
record.subscriptions = [];
329-
}
330-
record.subscriptions.push(suspenseyCommitSubscription);
331-
} else {
332-
throw new Error(
333-
'Did not expect this host component to be visited when suspending ' +
334-
'the commit. Did you check the SuspendCommit flag?',
335-
);
336-
}
337-
return suspenseyCommitSubscription;
338-
}
339-
340-
function waitForCommitToBeReady():
341-
| ((commit: () => mixed) => () => void)
342-
| null {
343-
const subscription = suspenseyCommitSubscription;
344-
if (subscription !== null) {
345-
suspenseyCommitSubscription = null;
346-
return (commit: () => void) => {
347-
subscription.commit = commit;
348-
const cancelCommit = () => {
349-
subscription.commit = null;
350-
};
351-
return cancelCommit;
352-
};
353-
}
354-
return null;
355-
}
356-
357274
const sharedHostConfig = {
358275
supportsSingletons: false,
359276

@@ -405,11 +322,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
405322
hidden: !!props.hidden,
406323
context: hostContext,
407324
};
408-
409-
if (type === 'suspensey-thing' && typeof props.src === 'string') {
410-
inst.src = props.src;
411-
}
412-
413325
// Hide from unit tests
414326
Object.defineProperty(inst, 'id', {value: inst.id, enumerable: false});
415327
Object.defineProperty(inst, 'parent', {
@@ -568,45 +480,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
568480
const endTime = Scheduler.unstable_now();
569481
callback(endTime);
570482
},
571-
572-
shouldSuspendCommit(type: string, props: Props): boolean {
573-
if (type === 'suspensey-thing' && typeof props.src === 'string') {
574-
if (suspenseyThingCache === null) {
575-
suspenseyThingCache = new Map();
576-
}
577-
const record = suspenseyThingCache.get(props.src);
578-
if (record === undefined) {
579-
const newRecord: SuspenseyThingRecord = {
580-
status: 'pending',
581-
subscriptions: null,
582-
};
583-
suspenseyThingCache.set(props.src, newRecord);
584-
const onLoadStart = props.onLoadStart;
585-
if (typeof onLoadStart === 'function') {
586-
onLoadStart();
587-
}
588-
return props.src;
589-
} else {
590-
if (record.status === 'pending') {
591-
// The resource was already requested, but it hasn't finished
592-
// loading yet.
593-
return true;
594-
} else {
595-
// The resource has already loaded. If the renderer is confident that
596-
// the resource will still be cached by the time the render commits,
597-
// then it can return false, like we do here.
598-
return false;
599-
}
600-
}
601-
}
602-
// Don't need to suspend.
603-
return false;
604-
},
605-
606-
startSuspendingCommit,
607-
suspendInstance,
608-
waitForCommitToBeReady,
609-
610483
prepareRendererToRender() {},
611484
resetRendererAfterRender() {},
612485
};
@@ -635,11 +508,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
635508
hostUpdateCounter++;
636509
instance.prop = newProps.prop;
637510
instance.hidden = !!newProps.hidden;
638-
639-
if (type === 'suspensey-thing' && typeof newProps.src === 'string') {
640-
instance.src = newProps.src;
641-
}
642-
643511
if (shouldSetTextContent(type, newProps)) {
644512
if (__DEV__) {
645513
checkPropStringCoercion(newProps.children, 'children');
@@ -821,9 +689,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
821689
if (instance.hidden) {
822690
props.hidden = true;
823691
}
824-
if (instance.src) {
825-
props.src = instance.src;
826-
}
827692
if (children !== null) {
828693
props.children = children;
829694
}
@@ -1050,50 +915,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
1050915
return getPendingChildrenAsJSX(container);
1051916
},
1052917

1053-
getSuspenseyThingStatus(src): string | null {
1054-
if (suspenseyThingCache === null) {
1055-
return null;
1056-
} else {
1057-
const record = suspenseyThingCache.get(src);
1058-
return record === undefined ? null : record.status;
1059-
}
1060-
},
1061-
1062-
resolveSuspenseyThing(key: string): void {
1063-
if (suspenseyThingCache === null) {
1064-
suspenseyThingCache = new Map();
1065-
}
1066-
const record = suspenseyThingCache.get(key);
1067-
if (record === undefined) {
1068-
const newRecord: SuspenseyThingRecord = {
1069-
status: 'fulfilled',
1070-
subscriptions: null,
1071-
};
1072-
suspenseyThingCache.set(key, newRecord);
1073-
} else {
1074-
if (record.status === 'pending') {
1075-
record.status = 'fulfilled';
1076-
const subscriptions = record.subscriptions;
1077-
if (subscriptions !== null) {
1078-
record.subscriptions = null;
1079-
for (let i = 0; i < subscriptions.length; i++) {
1080-
const subscription = subscriptions[i];
1081-
subscription.pendingCount--;
1082-
if (subscription.pendingCount === 0) {
1083-
const commit = subscription.commit;
1084-
subscription.commit = null;
1085-
commit();
1086-
}
1087-
}
1088-
}
1089-
}
1090-
}
1091-
},
1092-
1093-
resetSuspenseyThingCache() {
1094-
suspenseyThingCache = null;
1095-
},
1096-
1097918
createPortal(
1098919
children: ReactNodeList,
1099920
container: Container,

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ function updateSuspenseComponent(
22982298
const newOffscreenQueue: OffscreenQueue = {
22992299
transitions: currentTransitions,
23002300
markerInstances: parentMarkerInstances,
2301-
retryQueue: null,
2301+
wakeables: null,
23022302
};
23032303
primaryChildFragment.updateQueue = newOffscreenQueue;
23042304
} else {
@@ -2399,7 +2399,7 @@ function updateSuspenseComponent(
23992399
const newOffscreenQueue: OffscreenQueue = {
24002400
transitions: currentTransitions,
24012401
markerInstances: parentMarkerInstances,
2402-
retryQueue: null,
2402+
wakeables: null,
24032403
};
24042404
primaryChildFragment.updateQueue = newOffscreenQueue;
24052405
} else if (offscreenQueue === currentOffscreenQueue) {
@@ -2408,9 +2408,9 @@ function updateSuspenseComponent(
24082408
const newOffscreenQueue: OffscreenQueue = {
24092409
transitions: currentTransitions,
24102410
markerInstances: parentMarkerInstances,
2411-
retryQueue:
2411+
wakeables:
24122412
currentOffscreenQueue !== null
2413-
? currentOffscreenQueue.retryQueue
2413+
? currentOffscreenQueue.wakeables
24142414
: null,
24152415
};
24162416
primaryChildFragment.updateQueue = newOffscreenQueue;

0 commit comments

Comments
 (0)