Skip to content

perf: keep the bar moving while a widget move saves - #353

Merged
Seb-GRAF merged 1 commit into
mainfrom
perf/150-move-save
Oct 28, 2026
Merged

Seb-GRAF merged 1 commit into
mainfrom
perf/150-move-save

Conversation

@Seb-GRAF

Copy link
Copy Markdown
Collaborator

Problem

Moving a widget while editing the bar in place blocked the main thread for about 220 ms with a large configuration. Since #348 nothing moves on screen during that time, but animated widgets such as the Now Playing equalizer paused, and a click or drag started then had to wait.

Fixes #150

Changes

  • Skip a load. requireSavedWidget loads the saved file only when there are command-line changes. Without them, every widget on the bar is saved, so the check can't fail.
  • Save off the main thread. A move now composes the edited configuration and loads the result in the background. The main thread only writes the file and applies the result. The composing code moves from BarStore into ConfigurationEditing.swift so the background task can run it with a snapshot of the store's state. BarStore keeps the same methods, which call it.
  • Check before writing. The background result is written only if the file, the command-line changes and pending Settings changes are the same as when it started. Otherwise the move fails with "The configuration changed. Try your move again."
  • Keep the order. Moves from drag and drop, arrow keys and Move Left/Right are queued, with undo, remove and property changes behind them. Each move is still one undo step. Queued moves that haven't started are dropped when editing ends.
  • Keep the drop in place. A dropped tile stays in its new slot until the saved order arrives, including when another drag starts or is cancelled in the meantime. This keeps the overshoot fixed in fix: drag and click widgets on every display while editing the bar in place #348 from coming back.

Settings and the command line still save on the main thread. A pending Settings change still saves on the main thread before a move.

Testing

Release build, on a copy of a real configuration (13 widgets, 45 JSON files, scripts replaced with true), median of 8 moves:

Step Before After
Check the widget isn't from the command line 75.5 ms, main thread skipped
Compose the edited configuration 68.9 ms, main thread 69.8 ms, background
Load the new configuration 77.6 ms, main thread 76.9 ms, background
Write and apply included above 3.4 ms, main thread
Main thread per move 221.4 ms ≈3.5 ms

A move still takes about 150 ms to save. The longest gap seen on the main thread during a move was 10.2 ms.

  • swift test --filter "BarEditingTests|BarEditViewTests|WidgetDragSessionTests|ConfigurationHistoryTests|WidgetSetup|Customization" passes (111 XCTest, 14 Swift Testing), including the two drop tests from fix: drag and click widgets on every display while editing the bar in place #348.
  • New tests: a prepared move is rejected after a file, command-line or Settings change in between; a second drag while the first drop saves, and a cancelled drag, keep the first drop in place; queued moves and undo apply in order with one undo step each.
  • Not yet checked on the live bar. A signed test build is with the maintainer.

Merging

One commit; a merge commit keeps it as is.

GPT-6 Astra via Codex in T3 Code, reviewed by Claude Opus 5.5 via Claude Code

@Seb-GRAF
Seb-GRAF merged commit ef92476 into main Oct 28, 2026
8 checks passed
@Seb-GRAF
Seb-GRAF deleted the perf/150-move-save branch October 28, 2026 10:52
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moving a widget while editing the bar freezes it for about a second

1 participant