Repository navigation
fix(vd): don't panic when a workspace has no monitor any more - #1843
Merged
Merged
Conversation
get_monitor_of_workspace ended in `.expect("workspace_index is broken")`,
but a miss there is not a bug: removing a monitor drops its workspaces while
a window can still carry the id of one of them until it is retracked. On a
display change that panicked the whole app.
Observed when the physical display was swapped for a simulated one (screen
going to sleep on a laptop), immediately followed by:
Cause: workspace_index is broken
Location: src\background\virtual_desktops\mod.rs:312:14
It now returns Option. The unminimize handler skips the workspace switch,
send_to returns without moving anything, and the three Tauri commands return
an error instead of taking the process down.
Contributor
|
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.
The bug
SluWorkspacesManager2::get_monitor_of_workspaceends inbut a miss there is not a broken invariant. Removing a monitor drops its
workspaces from the index, while a window can still carry the id of one of
them until it is retracked. The next lookup for that window panics.
Observed on a laptop when the physical display was swapped for a simulated one
(screen going to sleep):
The fix
get_monitor_of_workspacereturnsOption<MonitorId>, and each of its fourcallers handles a miss the way that makes sense for it:
back, it just does not drag the user to a workspace that no longer exists
send_toreturnsOk(())without moving anything, the same as itsexisting early return for untracked windows
switch_workspace,destroy_workspaceandrename_workspacereturn anUnknown workspaceerror to the caller instead of taking the process downNo behaviour changes when the lookup succeeds.
Verified
cargo clippy --all-targets -- -D warnings,cargo fmt --check,deno fmt --checkand the repo's pre-commit hooks cleanTo be precise about the second point: the display swap has not recurred on
that machine since the build with this fix was installed, so this is verified
by construction rather than by reproducing the swap. The panic site and the
callers are small enough that I am comfortable with that, but I would rather
say it than imply otherwise.
Possibly related, not addressed here
The same log has an older, unrelated panic from the official 2.8.6 build:
I did not look into it.