test: host view tests in off-screen windows (#364) - #366
Merged
Conversation
… attaches Every hosted view was ordered on screen as a key window, so macOS bound out-of-process view services (Safari's completion-list helper) to hosted controls. Tearing one window down while a service was still bound made the next orderFront raise an NSRemoteView assertion that killed the whole test process, failing whichever test came next instead of the code that changed. Nothing in these tests needs to be visible; the ones that need key status still ask for it explicitly.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The functional change is small and localized to test infrastructure, and the only feedback is a minor doc-comment wording clarification.
Pull request overview
Updates the macOS SwiftUI test hosting infrastructure to avoid ordering host windows on screen, preventing intermittent crashes caused by NSRemoteView assertions when out-of-process view services (e.g., Safari completion helper) attach to hosted controls during full-suite runs.
Changes:
- Stop making every hosted test window key and ordering it on screen in
ViewTestHost.host. - Add detailed documentation in
ViewTestHostexplaining the crash mechanism and why off-screen hosting is sufficient for most view tests.
File summaries
| File | Description |
|---|---|
| SpotiglassTests/Support/ViewTestHost.swift | Removes makeKeyAndOrderFront from the shared view host and documents the rationale to reduce intermittent full-suite crashes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+69
to
+72
| /// to be next rather than on the code that changed (#364). Nothing here | ||
| /// needs to be visible: layout, hit testing, ViewInspector and first | ||
| /// responder all work in an off-screen window. Tests that genuinely need a | ||
| /// key window ask for one through `AppKitTestSupport.makeFirstResponder`. |
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #364.
ViewTestHost.hostordered every hosted view on screen as a key window. macOS then attaches out-of-process view services to hosted controls (Safari'sSPCompletionListServiceViewControllerbinds to text fields), and when a later test tore its window down while such a service was still bound, the nextorderFrontraised anNSRemoteViewassertion that killed the whole test process. That is why three different unrelated tests failed across four full-suite runs with no code change between them.The host window is now never ordered on screen. Layout, hit testing, ViewInspector and first responder all work off screen, and the tests that genuinely need key status already ask for it through
AppKitTestSupport.makeFirstResponder.Not verified locally: per the current working agreement I did not run the suite on this machine, only
build-for-testing, which succeeded. CI is the verdict.Left open in #364: the artwork-cache test that fails only in full-suite runs, and the missing per-test watchdog for hangs.