iOS: the Export menu reparses the whole document on every keystroke #230

closed cmc opened this on 2026-11-22 18:26 UTC · feature · milestone 1 Reviews and cleanup

Discussion

cmc 2026-11-22 18:26 UTC

Severity: High.

ExportMenu.body calls ExportScope.fileName (Sources/OrgstarMobile/ExportMenu.swift, around line 188), which parses the whole document each time SwiftUI evaluates the menu. The menu is part of the editor screen, so this runs at open and on every keystroke. Sampled in the iPhone 17 simulator while fixing #190: about 1–4 s of main-thread time per keystroke at 1 MB and 11–12 s at 10 MB. It is now the largest main-thread cost in the iOS editor.

Compute the file name from the existing tree, or only when the menu opens.

Also seen in the same run, not yet profiled:

  • ReaderScreen blocks the main thread for about 25 s opening a 10 MB file, and 1.2–3 s at 1 MB.
  • With a 10 MB file in the workspace, agenda, widgets and Spotlight work took 40–130 s, and once the main thread was blocked for 11 s at launch.
  • iOS recomputes Presentation.shadedBlocks(document.tree) for the whole tree on every edit; the Mac avoids this with mayChangeBlocks.

Platforms: iOS.

closed by cmc in commit 0616dfef30: Name iOS exports from the open tree and find block bands only when needed

2026-11-22 19:41 UTC