Skip to content

fix: stop the edit bar crashing when a widget comes back on another display - #637

Merged
M4n0x merged 1 commit into
mainfrom
fix/636-edit-bar-zero-scale
Nov 14, 2026
Merged

M4n0x merged 1 commit into
mainfrom
fix/636-edit-bar-zero-scale

Conversation

@M4n0x

@M4n0x M4n0x commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

With two displays, StableBar aborts while editing the bar in place: a drop on one display's edit bar crashes the other one a moment later (Assertion failed: (determinant != 0), function NSCGSizeApplyInverseAffineTransform). Fixes #636.

Changes

  • BarEditView drew a unit it hadn't measured yet at .scaleEffect(0) so it grows in from nothing. Each tile is a BarEditDragSource holding an NSHostingView, and AppKit aborts laying out that hosting view at a scale it can't invert. While a widget is over one display, the other display's edit bar leaves it out and forgets its width, so after the drop it comes back unmeasured at a scale of 0.
  • It now grows in from a scale of 0.01, which AppKit can invert. At that scale a tile is under a point wide, so the grow-in looks the same.

Testing

  • New test aWidgetDroppedOnOneDisplayComesBackOnTheOtherDisplaysEditBar edits the bar on two displays, drags a widget over the first and drops it there. On main it aborts the test run with the same assertion as the crash report; with the fix it passes, three runs in a row, also with LIBDISPATCH_COOPERATIVE_POOL_STRICT=1.
  • BarEditViewTests and the other edit bar tests pass; scripts/check.sh --quick passes.
  • A standalone SwiftUI program with the same nesting (an NSHostingView in an NSViewRepresentable) aborts at a scale of 0 and runs at 0.01, both when a tile appears and when an existing tile's scale drops.
  • Not checked in the running app: no second bar was launched. Adding a widget with + may have hit the same crash (an added widget also starts unmeasured); the fix covers that path too, but I didn't reproduce it.
  • No visible change: the only difference is the first frame of the grow-in, at 1% instead of 0% of the tile's size, so there are no screenshots.

Merging

One commit: squash or rebase.

Claude Opus 5.5 via Claude Code

…isplay

The edit bar drew a widget it hadn't measured yet at a scale of 0. Each tile hosts an
NSHostingView, and AppKit aborts laying one out at a scale it can't invert. With two
displays, a drop on one brought the widget back unmeasured on the other. It now grows
in from a scale of 0.01.

Fixes #636
@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner November 13, 2026 23:14
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Unmeasured widgets in BarEditView now start at scale 0.01 instead of 0. A new test checks widget visibility on two displays while a widget is dragged to one display and after its drop is saved.

Changes: Two-display bar editing

Layer / File(s) Summary
Unmeasured widget scale and two-display drop test
Sources/StableBar/BarEditView.swift, Tests/StableBarTests/BarEditViewTests.swift
Unmeasured widgets now use scale 0.01, while measured widgets remain at scale 1. The test checks that the widget disappears from the other display during the drag and reappears after the drop is saved at .left.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 46080

This avoids a crash when a widget dropped on one display reappears unmeasured in the other display's edit bar, while keeping the grow-in effect. The change is small and easy to revert. A regression test covers the scenario, so merge risk is minimal.

Security architecture risk: Minimal · up to 46080

The change gives unmeasured widgets a small nonzero starting scale to prevent a rendering crash. The described scope does not introduce or worsen a security, ownership, or failure-containment risk.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description follows the repository template. It has Problem, Changes, Testing, and Merging sections, and it ends with the model and harness line. The Problem section states the crash and links iss…
Linked Issues check Passed [#636] Requirement: dropping a widget on one display's edit bar must not abort the app, and both edit bars must show the widget in its new place. Root cause per the issue: a unit that is unmeasured wh…
Out of Scope Changes check Passed The whole-PR summary lists two changed files: Sources/StableBar/BarEditView.swift (+3/-2, the grow-in scale change) and Tests/StableBarTests/BarEditViewTests.swift (+50, the regression test). Both…
Full details: Description check

Explanation

The description follows the repository template. It has Problem, Changes, Testing, and Merging sections, and it ends with the model and harness line. The Problem section states the crash and links issue #636 with "Fixes #636." The Changes section explains the cause (a zero-scale tile in an NSHostingView) and the fix (grow-in from 0.01). The Testing section gives a new regression test, the test runs on main and on the branch, the suite and script results, a standalone reproduction, and what was not checked in the running app. The Merging section states that one squashed or rebased commit is needed. The last line names the model and harness.

Full details: Linked Issues check

Explanation

[#636] Requirement: dropping a widget on one display's edit bar must not abort the app, and both edit bars must show the widget in its new place. Root cause per the issue: a unit that is unmeasured when it reappears is drawn at .scaleEffect(0), and AppKit aborts laying out the NSHostingView inside BarEditDragSource at that scale. At the reviewed head, Sources/StableBar/BarEditView.swift uses .scaleEffect(widths[unit.id] == nil ? 0.01 : 1) with a comment explaining the AppKit limit. A unit with no measured width now starts at 0.01, which AppKit can invert, so the reported path no longer reaches a zero scale. The PR adds aWidgetDroppedOnOneDisplayComesBackOnTheOtherDisplaysEditBar in Tests/StableBarTests/BarEditViewTests.swift, which covers the two-display drop scenario from the issue. The author reports that this test aborts on the merge base and passes with the fix. I did not run the test; that result is author-reported. The issue's optional scenario (adding a widget with +) is not a firm requirement. The same code path covers it because an added widget also starts unmeasured.

Full details: Out of Scope Changes check

Explanation

The whole-PR summary lists two changed files: Sources/StableBar/BarEditView.swift (+3/-2, the grow-in scale change) and Tests/StableBarTests/BarEditViewTests.swift (+50, the regression test). Both changes relate directly to #636. The diff tool could not return the changed blobs, so I read the reviewed head version of BarEditView.swift directly. It shows only the scale change and its comment in the reviewed region. I did not verify the test file contents, so the test's scope rests on the summary. No unrelated change is evident.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dc73d5d and 4608025.

Files selected for processing: 2

  • Sources/StableBar/BarEditView.swift
  • Tests/StableBarTests/BarEditViewTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Before and after

main at dc73d5d → this pull request at 4608025 · 150 screens drawn in one CI job · 0 changed

150 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/essentials-settings-dark, docs/essentials-settings-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/accessibility-guide-light, scenes/app-menu-popup-dark, scenes/app-menu-popup-light, scenes/apple-menu-settings-dark, scenes/apple-menu-settings-light, scenes/bottom-bar-popup-dark, scenes/bottom-bar-popup-light, scenes/chat-popup-dark, scenes/chat-popup-light, scenes/crowded-edit-bar-dark, scenes/crowded-edit-bar-light, scenes/dock-badges-bar-dark, scenes/dock-badges-bar-light, scenes/edit-bar-wide-group-dark, scenes/edit-bar-wide-group-light, scenes/essentials-clock-popup-dark, scenes/essentials-clock-popup-light, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/horizontal-list-popup-light, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/input-source-popup-dark, scenes/input-source-popup-light, scenes/notch-flare-bar-dark, scenes/notch-flare-bar-light, scenes/privacy-both-bar-dark, scenes/privacy-both-bar-light, scenes/privacy-hide-when-idle-bar-dark, scenes/privacy-hide-when-idle-bar-light, scenes/privacy-idle-bar-dark, scenes/privacy-idle-bar-light, scenes/privacy-microphone-bar-dark, scenes/privacy-microphone-bar-light, scenes/privacy-settings-dark, scenes/privacy-settings-light, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/settings-bar-dark, scenes/settings-bar-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-bottom-light, scenes/settings-bar-placement-dark, scenes/settings-bar-placement-light, scenes/settings-crashes-dark, scenes/settings-crashes-light, scenes/settings-feedback-dark, scenes/settings-feedback-light, scenes/settings-general-dark, scenes/settings-general-light, scenes/settings-general-macos15-dark, scenes/settings-general-macos15-light, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-failed-light, scenes/settings-general-move-light, scenes/settings-general-move-moving-dark, scenes/settings-general-move-moving-light, scenes/settings-general-move-replace-dark, scenes/settings-general-move-replace-light, scenes/settings-general-setup-open-dark, scenes/settings-general-setup-open-light, scenes/settings-general-spaces-dark, scenes/settings-general-spaces-light, scenes/settings-help-dark, scenes/settings-help-light, scenes/settings-help-starred-dark, scenes/settings-help-starred-light, scenes/settings-narrow-dark, scenes/settings-narrow-light, scenes/settings-package-dark, scenes/settings-package-light, scenes/settings-package-widget-dark, scenes/settings-package-widget-light, scenes/settings-theme-dark, scenes/settings-theme-light, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-uninstall-failed-light, scenes/settings-uninstall-light, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-workspace-hidden-dark, scenes/settings-workspace-hidden-light, scenes/setup-look-below-menu-bar-dark, scenes/setup-look-dark, scenes/setup-look-no-notch-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, scenes/setup-omniwm-connection-dark, scenes/setup-permissions-dark, scenes/setup-permissions-spaces-dark, scenes/setup-permissions-spaces-ready-dark, scenes/setup-placement-bottom-dark, scenes/setup-placement-dark, scenes/setup-touches-dark, scenes/setup-touches-macos15-dark, scenes/setup-touches-spaces-dark, scenes/setup-try-dark, scenes/setup-yabai-connection-dark, scenes/slider-end-stop-popup-dark, scenes/slider-end-stop-popup-light, scenes/stablebar-widget-bar-dark, scenes/stablebar-widget-bar-light, scenes/stablebar-widget-settings-dark, scenes/stablebar-widget-settings-light, scenes/starter-bar-dark, scenes/starter-bar-light, scenes/starter-edit-bar-dark, scenes/starter-edit-bar-light, scenes/system-monitor-memory-bar-dark, scenes/system-monitor-memory-bar-light, scenes/system-monitor-shows-settings-dark, scenes/system-monitor-shows-settings-light, scenes/update-popup-dark, scenes/update-popup-light, scenes/update-popup-star-github-cli-dark, scenes/update-popup-star-github-cli-light, scenes/update-popup-star-thanks-dark, scenes/update-popup-star-thanks-light, scenes/workspace-badges-bar-dark, scenes/workspace-badges-bar-light, scenes/workspace-focused-window-bar-dark, scenes/workspace-focused-window-bar-light, scenes/workspace-focused-window-padding-bar-dark, scenes/workspace-focused-window-padding-bar-light, scenes/workspace-hidden-apps-bar-dark, scenes/workspace-hidden-apps-bar-light

Visual review: 150 screens, none changed.

@M4n0x
M4n0x merged commit 78b073d into main Nov 14, 2026
15 checks passed
@M4n0x
M4n0x deleted the fix/636-edit-bar-zero-scale branch November 14, 2026 08:33
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.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.

StableBar crashes after a drop while editing the bar in place on two displays

1 participant