Skip to content

Clean Up window freezes after expanding sections and scrolling #892

Open

Description

@oguzhanvarsak

Describe the bug
The Clean Up window stops responding (spinning cursor) after expanding a few sections and scrolling. The app stays at ~100% CPU on the main thread and doesn't recover.

To Reproduce

  1. Open Clean Up and wait for the scan to finish.
  2. Expand a few sections, e.g. Derived Data and Simulator devices.
  3. Scroll the list up and down.
  4. The window freezes. No selection is needed, though selecting items in an expanded section triggers it as well.

The data set is small (~55 DerivedData folders, ~13 simulator devices), so it isn't caused by the number of rows.

Expected behavior
Expanding sections and scrolling stays responsive.

Notes
Sampling the frozen process shows the main thread never going idle. Nearly all samples are in SwiftUI layout for the cleanup list's LazyVStacks (LazyStack.measureEstimates, LazySubviewPlacements.placeSubviews, LazyLayoutViewCache.updateItemPhases), plus hover updates; almost no time is spent in app code.

The list nests lazy stacks: the section cards sit in a ScrollView > LazyVStack in CleanupWindow, and each expanded card (CleanupCategorySection, CleanupRuntimeSection) contains another LazyVStack of rows.

Version

  • OS: macOS 26.7.2 (25G332), Apple silicon M1 Pro
  • Xcodes: 4.2.0 (42), also reproduced on main (9836fd8)

Demo

Screen.Recording.2026-11-15.at.4.16.39.PM.mov

Activity

  1. oguzhanvarsak commented on Nov 15, 2026

    @oguzhanvarsak
    Author

    Some notes from looking into this:

    What fixes it
    Switching the cleanup list from LazyVStack to VStack stops the freeze. That means the section list in CleanupWindow and the row stacks in CleanupCategorySection and CleanupRuntimeSection. After the change, a sample taken right after expanding sections, scrolling and toggling items shows the main thread idle at 0% CPU.

    What didn't
    Making only the inner row stacks eager (keeping the outer LazyVStack) still froze. The outer lazy stack measuring tall, variable-height section cards is enough to trigger it.

    Limitation: very large sections
    With eager stacks, a section with ~1,000 entries (a custom folder) no longer freezes, but scrolling it while expanded is slow: every row is built up front, memory went from ~630 MB to ~1.7 GB, and each scroll event hit-tests all rows.

    I also tried flattening the list into a single LazyVStack, with headers and rows as siblings so there's no nesting. That kept memory low and didn't freeze, but scrolling the 1,000-entry section still lagged: SwiftUI spends its time measuring rows and resolving scroll positions. Smooth scrolling at that size probably needs a different approach, such as a List/table-backed layout or showing only the largest items with a "Show all" option.

    Unrelated, but noticed
    Each selection change starts a new SavingsEstimator walk, and earlier walks seem to keep running after cancellation. Rapid clicking keeps a background thread busy for a while; it doesn't cause the freeze.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions