Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 28, 2024
1 parent 16ee439 commit ae87aca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion packages/react-reconciler/src/ReactFiberLane.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,18 +905,21 @@ export function addFiberToLanesMap(
}
}

export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {
export function movePendingFibersToMemoized(root: FiberRoot, passedLanes) {
console.log('movePendingFibersToMemoized', root, new Error().stack);
if (!enableUpdaterTracking) {
return;
}
if (!isDevToolsPresent) {
return;
}
let lanes = root.pendingLanes;
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
const memoizedUpdaters = root.memoizedUpdaters;
while (lanes > 0) {
const index = laneToIndex(lanes);
const lane = 1 << index;
console.log({index, lane, passedLanes});

const updaters = pendingUpdatersLaneMap[index];
if (updaters.size > 0) {
Expand All @@ -931,6 +934,7 @@ export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {

lanes &= ~lane;
}
console.log('moved');
}

export function addTransitionToLanesMap(
Expand Down
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber): boolean {
export function performConcurrentWorkOnRoot(
root: FiberRoot,
didTimeout: boolean,
passedLanes,
): RenderTaskFn | null {
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
resetNestedUpdateFlag();
Expand Down Expand Up @@ -947,6 +948,7 @@ export function performConcurrentWorkOnRoot(
// Defensive coding. This is never expected to happen.
return null;
}
console.log({lanes, passedLanes});

// We disable time-slicing in some cases: if the work has been CPU-bound
// for too long ("expired" work, to prevent starvation), or we're in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('updaters', () => {
}
const schedulerTags = [];
const schedulerTypes = [];
console.log(fiberRoot.pendingUpdatersLaneMap);
fiberRoot.memoizedUpdaters.forEach(fiber => {
schedulerTags.push(fiber.tag);
schedulerTypes.push(fiber.elementType);
Expand Down Expand Up @@ -262,7 +263,7 @@ describe('updaters', () => {
await waitForAll([]);
});

it('should cover suspense pings', async () => {
it.only('should cover suspense pings', async () => {
let data = null;
let resolver = null;
let promise = null;
Expand Down Expand Up @@ -304,19 +305,19 @@ describe('updaters', () => {
expect(setShouldSuspend).not.toBeNull();
expect(allSchedulerTypes).toEqual([[null]]);

console.log('suspend -----------------');
await act(() => {
setShouldSuspend(true);
});
assertLog(['onCommitRoot']);
expect(allSchedulerTypes).toEqual([[null], [Suspender]]);

expect(resolver).not.toBeNull();
await act(() => {
resolver('abc');
return promise;
});
assertLog(['onCommitRoot']);
expect(allSchedulerTypes).toEqual([[null], [Suspender], []]);
console.log('final -----------------');
resolver('abc');
await waitForAll(['onCommitRoot']);

expect(allSchedulerTypes).toEqual([[null], [Suspender], [Suspender]]);

// Verify no outstanding flushes
await waitForAll([]);
Expand Down

0 comments on commit ae87aca

Please sign in to comment.