Skip to content

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Oct 6, 2025

Including Suspense in hidden Activity can be confusing since that likely ends up to overlapping rects (e.g. when each tab content is in an Activity or when previous "pages" are kept in Activity for a better backwards-forwards cache.

We now differentiate between Offscreen used by Suspense and Offscreen used by Activity. Activity-Offscreen will just unmount all nodes. Suspense-Offscreen will stay as-is and unmount nodes except Suspense nodes in the Suspense tree.

@meta-cla meta-cla bot added the CLA Signed label Oct 6, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Oct 6, 2025
@eps1lon eps1lon force-pushed the sebbie/10-06-_devtools_don_t_include_suspense_in_hidden_activity branch from 21137eb to 2a2cca5 Compare October 6, 2025 17:45
@eps1lon eps1lon requested a review from sebmarkbage October 6, 2025 17:45
@eps1lon eps1lon marked this pull request as ready for review October 6, 2025 17:45
function App({hidden}) {
return (
<>
<Activity mode={hidden ? 'hidden' : 'visiible'}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Activity mode={hidden ? 'hidden' : 'visiible'}>
<Activity mode={hidden ? 'hidden' : 'visible'}>

if (isHiddenOffscreen(fiber)) {
// hidden Activity is noisy.
// Including it may show overlapping Suspense rects
} else if (isSuspendedOffscreen(fiber)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t this always be false because isHiddenOffscreen above is a superset of isSuspendedOffscreen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I handled the suspended case first in the other places but not here. Now we always handle suspended before hidden.

Though I'm not sure how to make this matter in the mount path. In the current test, fiber.child is always null when mounting a suspended Offscreen. I guess we can't hit this in modern Suspense where we don't commit an inconsistent tree. But I believe React 17 could commit an inconsistent, hidden tree where this would matter?

@eps1lon eps1lon force-pushed the sebbie/10-06-_devtools_don_t_include_suspense_in_hidden_activity branch from 2a2cca5 to 3c482be Compare October 13, 2025 15:04
@eps1lon eps1lon requested a review from sebmarkbage October 13, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants