Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Komorebi Crashes When Window Opens on 'Wrong Workspace' #1212

Closed
xidsyed opened this issue Jan 3, 2025 · 6 comments
Closed

[BUG]: Komorebi Crashes When Window Opens on 'Wrong Workspace' #1212

xidsyed opened this issue Jan 3, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@xidsyed
Copy link

xidsyed commented Jan 3, 2025

Summary

If the workspace rules define that a window should be opened on workspace 2 and if you were to open it on any other workspace then komorebi transfers the window to the correct workspace but subsequently immediately crashes.

komorebi.workspace.rules.crash.-.Made.with.Clipchamp.mp4

Version Information

OS Name: Microsoft Windows 11 Home
OS Version: 10.0.22631 N/A Build 22631

komorebic 0.1.32
tag:v0.1.32
commit_hash:4b9d8114
build_time:2025-01-01 19:37:02 +00:00
build_env:rustc 1.83.0 (90b35a623 2024-11-26),stable-x86_64-pc-windows-msvc

Komorebi Configuration

{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.29/schema.bar.json",
  "monitor": {
    "index": 0,
    "work_area_offset": {
      "left": 0,
      "top": 30,
      "right": 0,
      "bottom": 30
    }
  },
  "position": {
    "start": {
      "x": 0,
      "y": -10
    },
    "end": {
      "x": 1920,
      "y": 45
    }
  },
  "font_size": 11,
  "font_family": "Cascadia Code",
  "theme": {
    "palette": "Base16",
    "name": "Chalk",
    "accent": "Base0F"
  },
  "left_widgets": [
    {
      "Komorebi": {
        "workspaces": {
          "enable": true,
          "hide_empty_workspaces": true
        },
        "layout": {
          "enable": true
        },
        "focused_window": {
          "enable": false,
          "show_icon": false
        }
      }
    }
  ],
  "right_widgets": [
    {
      "Media": {
        "enable": true
      }
    },
    {
      "Storage": {
        "enable": false
      }
    },
    {
      "Memory": {
        "enable": true
      }
    },
    {
      "Network": {
        "enable": false,
        "data_refresh_interval": 1,
        "show_total_data_transmitted": false,
        "show_network_activity": false
      }
    },
    {
      "Date": {
        "enable": true,
        "format": "DayDateMonthYear"
      }
    },
    {
      "Time": {
        "enable": true,
        "format": {
          "Custom": "%H:%M %p"
        }
      }
    },
    {
      "Battery": {
        "enable": true,
        "data_refresh_interval": 60
      }
    }
  ]
}


{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.28/schema.json",
  "app_specific_configuration_path": "$Env:USERPROFILE/applications.json",
  "window_hiding_behaviour": "Cloak",
  "cross_monitor_move_behaviour": "Insert",
  "default_workspace_padding": 1,
  "default_container_padding": 1,
  "transparency": false,
  "border": true,
  "border_width": 0,
  "border_style": "System",
  "border_implementation": "Windows",
  "border_colours": {
    "single": "#a6856e",
    "stack": "#a6856e",
    "monocle": "#fc585e",
    "unfocused": "#000000"
  },
  "stackbar": {
    "label": "Title",
    "height": 32,
    "mode": "OnStack",
    "tabs": {
      "width": 220,
      "focused_text": "#a6856e",
      "unfocused_text": "#383838",
      "background": "#000000",
      "font_size": 28,
      "font_family": "Consolas"
    }
  },
  "monitors": [
    {
      "workspaces": [
        {
          "name": "1 Code",
          "layout": "BSP",
          "workspace_rules": [
            {
              "id": "idea64.exe",
              "kind": "Exe"
            },
            {
              "id": "studio64.exe",
              "kind": "Exe"
            }
          ]
        },
        {
          "name": "2 Notes",
          "layout": "BSP",
          "workspace_rules": [
            {
              "id": "Obsidian.exe",
              "kind": "Exe"
            }
          ]
        },
        {
          "name": "3 Web",
          "layout": "BSP"
        },
        {
          "name": "4 Comm",
          "layout": "BSP",
          "workspace_rules": [
            {
              "id": "WhatsApp Beta",
              "kind": "Title",
              "matching_strategy": "Equals"
            }
          ]
        },
        {
          "name": "5 AI",
          "layout": "BSP",
          "initial_workspace_rules": [
            {
              "id": "ChatGPT App",
              "kind": "Title",
              "matching_strategy": "StartsWith"
            },
            {
              "id": "Perplexity App",
              "kind": "Title",
              "matching_strategy": "StartsWith"
            },
            {
              "id": "Claude",
              "kind": "Title",
              "matching_strategy": "StartsWith"
            }
          ]
        },
        {
          "name": "6 Media",
          "layout": "BSP"
        },
        {
          "name": "7 Social",
          "layout": "BSP"
        },
        {
          "name": "8 Flow",
          "layout": "BSP"
        },
        {
          "name": "9 FLow",
          "layout": "BSP"
        },
        {
          "name": "0 Swap",
          "layout": "BSP",
          "workspace_rules": [
            {
              "id": "edit_komorebi",
              "kind": "Title",
              "matching_strategy": "Contains"
            }
          ]

        }
      ]
    }
  ],
  "ignore_rules": [
    {
      "id": "Voice call ‎- WhatsApp Beta",
      "kind": "Title",
      "matching_strategy": "Equals"
    }
  ]
}

Hotkey Configuration

.shell powershell

Reload whkd configuration

alt + o : taskkill /f /im whkd.exe && start /b whkd # if shell is cmd

alt + o : taskkill /f /im whkd.exe; Start-Process whkd -WindowStyle hidden # if shell is pwsh / powershell

alt + shift + o : komorebic reload-configuration

alt + shift + b : Stop-Process -name komorebi-bar; Start-Process komorebi-bar -windowstyle hidden

App shortcuts - these require shell to be pwsh / powershell

The apps will be focused if open, or launched if not open

alt + f : if ($wshell.AppActivate('Firefox') -eq $False) { start firefox }

alt + b : if ($wshell.AppActivate('Chrome') -eq $False) { start chrome }

alt + q : komorebic close
alt + m : komorebic minimize

Focus windows

alt + h : komorebic focus left
alt + j : komorebic focus down
alt + k : komorebic focus up
alt + l : komorebic focus right

alt + ctrl + oem_4 : komorebic cycle-focus previous # oem_4 is [

alt + ctrl + oem_6 : komorebic cycle-focus next # oem_6 is ]

Move windows

alt + shift + h : komorebic move left
alt + shift + j : komorebic move down
alt + shift + k : komorebic move up
alt + shift + l : komorebic move right
alt + shift + return : komorebic promote

Stack windows

alt + shift + oem_4 : komorebic stack left
alt + ctrl + oem_4 : komorebic stack down
alt + ctrl + oem_6 : komorebic stack up
alt + shift + oem_6 : komorebic stack right
alt + oem_1 : komorebic unstack # oem_1 is ;
alt + oem_4 : komorebic cycle-stack previous # oem_4 is [
alt + oem_6 : komorebic cycle-stack next # oem_6 is ]

Resize

alt + oem_plus : komorebic resize-axis horizontal increase
alt + oem_minus : komorebic resize-axis horizontal decrease
alt + shift + oem_plus : komorebic resize-axis vertical increase
alt + shift + oem_minus : komorebic resize-axis vertical decrease

Manipulate windows

alt + shift + d : komorebic toggle-float
alt + d : komorebic toggle-monocle

Window manager options

alt + shift + r : komorebic retile
alt + shift + p : komorebic toggle-pause
alt + shift + m : komorebic manage

Layouts

alt + x : komorebic flip-layout horizontal
alt + y : komorebic flip-layout vertical

Workspaces

alt + 1 : komorebic focus-workspace 0
alt + 2 : komorebic focus-workspace 1
alt + 3 : komorebic focus-workspace 2
alt + 4 : komorebic focus-workspace 3
alt + 5 : komorebic focus-workspace 4
alt + 6 : komorebic focus-workspace 5
alt + 7 : komorebic focus-workspace 6
alt + 8 : komorebic focus-workspace 7
alt + 9 : komorebic focus-workspace 8
alt + 0 : komorebic focus-workspace 9

Move windows across workspaces

alt + shift + 1 : komorebic move-to-workspace 0
alt + shift + 2 : komorebic move-to-workspace 1
alt + shift + 3 : komorebic move-to-workspace 2
alt + shift + 4 : komorebic move-to-workspace 3
alt + shift + 5 : komorebic move-to-workspace 4
alt + shift + 6 : komorebic move-to-workspace 5
alt + shift + 7 : komorebic move-to-workspace 6
alt + shift + 8 : komorebic move-to-workspace 7
alt + shift + 9 : komorebic move-to-workspace 8
alt + shift + 0 : komorebic move-to-workspace 9

Launch Apps

ctrl + alt + c : Start-Process chrome.exe

Output of komorebic check

Looking for configuration files in C:\Users\mmsye

Found komorebi.json; this file can be passed to the start command with the --config flag

Found C:\Users\mmsye.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag

@xidsyed xidsyed added the bug Something isn't working label Jan 3, 2025
@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 3, 2025

This is an odd one, I use the workspace rules quite regularly and I haven't seen this before. Can you run komorebic log in a separate tab and try to capture the crash when you reproduce it?

@xidsyed
Copy link
Author

xidsyed commented Jan 4, 2025

I tried recreating it. i found it a bit odd too. assuming its quite common to be using workspace rules and i dont see any issues being created for it ive been having this problem since the previous release

$ komorebic state
thread 'main' panicked at komorebic\src/main.rs:1439:23:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (os error 10060)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
komorebi.hangs.on.workspace.rules.part.2.-.Made.with.Clipchamp.mp4

@xidsyed xidsyed closed this as completed Jan 4, 2025
@xidsyed xidsyed reopened this Jan 4, 2025
@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 4, 2025

Looks like there has been a deadlock introduced somewhere, I think this is enough info to help me start digging 👀

@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 4, 2025

Found it

2025-01-04T17:30:28.495752Z ERROR komorebi: 1 deadlocks detected
2025-01-04T17:30:28.495952Z ERROR komorebi: deadlock #0
2025-01-04T17:30:28.496118Z ERROR komorebi: thread id: 23856
2025-01-04T17:30:28.496329Z ERROR komorebi:    0:     0x7ff62245c62a - backtrace::backtrace::dbghelp64::trace
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\backtrace-0.3.71\src\backtrace\dbghelp64.rs:99
                           backtrace::backtrace::trace_unsynchronized<backtrace::capture::impl$1::create::closure_env$0>
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\backtrace-0.3.71\src\backtrace\mod.rs:66
   1:     0x7ff62245c4d7 - backtrace::backtrace::trace<backtrace::capture::impl$1::create::closure_env$0>
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\backtrace-0.3.71\src\backtrace\mod.rs:53
   2:     0x7ff622459a9e - backtrace::capture::Backtrace::create
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\backtrace-0.3.71\src\capture.rs:193
   3:     0x7ff622459a0e - backtrace::capture::Backtrace::new
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\backtrace-0.3.71\src\capture.rs:158
   4:     0x7ff622048044 - parking_lot_core::parking_lot::deadlock_impl::on_unpark
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.10\src\parking_lot.rs:1211
   5:     0x7ff622030a6e - parking_lot_core::parking_lot::deadlock::on_unpark
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.10\src\parking_lot.rs:1144
   6:     0x7ff62203342f - parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.10\src\parking_lot.rs:637
   7:     0x7ff62203311b - parking_lot_core::parking_lot::with_thread_data
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.10\src\parking_lot.rs:207
                           parking_lot_core::parking_lot::park<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.10\src\parking_lot.rs:600
   8:     0x7ff6220326d0 - parking_lot::raw_mutex::RawMutex::lock_slow
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.3\src\raw_mutex.rs:262
   9:     0x7ff621cb92c6 - parking_lot::raw_mutex::impl$0::lock
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.3\src\raw_mutex.rs:72
  10:     0x7ff6219012d3 - lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex,std::collections::hash::map::HashMap<alloc::string::String,regex::regex::string::Regex,std::hash::random::RandomState> >::lock<parking_lot::raw_mutex::RawMutex,std::collections::hash::map::HashMap<al
                               at C:\Users\LGUG2Z\.cargo\registry\src\index.crates.io-6f17d22bba15001f\lock_api-0.4.12\src\mutex.rs:223
  11:     0x7ff621a3c209 - komorebi::workspace::Workspace::update
                               at komorebi\src\workspace.rs:371
  12:     0x7ff621a510fc - komorebi::monitor::Monitor::update_focused_workspace
                               at komorebi\src\monitor.rs:361
  13:     0x7ff6218c8f87 - komorebi::window_manager::WindowManager::update_focused_workspace
                               at komorebi\src\window_manager.rs:1228
  14:     0x7ff6218c0bbc - komorebi::window_manager::WindowManager::enforce_workspace_rules
                               at komorebi\src\window_manager.rs:884
  15:     0x7ff6218abbdb - komorebi::window_manager::WindowManager::process_event
                               at komorebi\src\process_event.rs:162
  16:     0x7ff621d5bba9 - komorebi::process_event::listen_for_events::closure$0
                               at komorebi\src\process_event.rs:51
  17:     0x7ff621cb8fb9 - core::hint::black_box
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\hint.rs:389
                           std::sys::backtrace::__rust_begin_short_backtrace<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\backtrace.rs:154
  18:     0x7ff621b4f4b8 - std::thread::impl$0::spawn_unchecked_::closure$1::closure$0<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:538
  19:     0x7ff621a54298 - core::panic::unwind_safe::impl$25::call_once<tuple$<>,std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> > >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\panic\unwind_safe.rs:272
  20:     0x7ff621cb138c - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> > >,tuple$<> >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:557
  21:     0x7ff621b50d13 - std::thread::impl$7::drop::closure$0<enum2$<core::result::Result<tuple$<>,eyre::Report> > >
  22:     0x7ff621b47a3b - std::panicking::try
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:520
                           std::panic::catch_unwind
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panic.rs:358
                           std::thread::impl$0::spawn_unchecked_::closure$1<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\mod.rs:537
  23:     0x7ff62186360e - core::ops::function::FnOnce::call_once<std::thread::impl$0::spawn_unchecked_::closure_env$1<komorebi::process_event::listen_for_events::closure_env$0,tuple$<> >,tuple$<> >
                               at C:\Users\LGUG2Z\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250
  24:     0x7ff6225bbbbd - alloc::boxed::impl$48::call_once
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/alloc\src\boxed.rs:2454
                           alloc::boxed::impl$48::call_once
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/alloc\src\boxed.rs:2454
                           std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/std\src\sys\pal\windows\thread.rs:55
  25:     0x7ff803ac257d - BaseThreadInitThunk
  26:     0x7ff80464af28 - RtlUserThreadStart

@LGUG2Z LGUG2Z closed this as completed in 40e1575 Jan 4, 2025
@LGUG2Z
Copy link
Owner

LGUG2Z commented Jan 4, 2025

Should be fixed in the next nightly tagged release tonight

@LGUG2Z LGUG2Z pinned this issue Jan 4, 2025
@xidsyed
Copy link
Author

xidsyed commented Jan 5, 2025

damn. quick work bro. fixed in the new build 👍

LGUG2Z added a commit that referenced this issue Jan 5, 2025
This commit adds mutex lock scoping in
WindowManager::enforce_workspace_rule to avoid a deadlock when
should_update_focused_workspace evaluates to true.

fix #1212
@LGUG2Z LGUG2Z unpinned this issue Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants