fix: process state change events synchronously on main thread#25
Merged
fix: process state change events synchronously on main thread#25
Conversation
When screenParametersChanged fires, set_displays() migrates nodes in Rust and calls notify() → onStateChange() on the main thread. Previously, onStateChange always used DispatchQueue.main.async, so the migration events were queued rather than processed immediately. This caused handleDisplayChange (which runs right after set_displays returns) to read stale Swift-side nodes, creating windows on the wrong display. Fix: use MainActor.assumeIsolated to process events synchronously when already on the main thread, ensuring nodes are updated before handleDisplayChange runs. Background thread callbacks (from IPC server) continue to use DispatchQueue.main.async as before.
typester
pushed a commit
that referenced
this pull request
Feb 27, 2026
🤖 I have created a release *beep* *boop* --- ## [0.1.11](v0.1.10...v0.1.11) (2026-02-27) ### Features * add version subcommand to CLI ([#26](#26)) ([9c253e5](9c253e5)) ### Bug Fixes * process state change events synchronously on main thread ([#25](#25)) ([61b9f6e](61b9f6e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
When screenParametersChanged fires, set_displays() migrates nodes in Rust and calls notify() → onStateChange() on the main thread. Previously, onStateChange always used DispatchQueue.main.async, so the migration events were queued rather than processed immediately. This caused handleDisplayChange (which runs right after set_displays returns) to read stale Swift-side nodes, creating windows on the wrong display.
Fix: use MainActor.assumeIsolated to process events synchronously when already on the main thread, ensuring nodes are updated before handleDisplayChange runs. Background thread callbacks (from IPC server) continue to use DispatchQueue.main.async as before.