glzr-io / glazewm

GlazeWM is a tiling window manager for Windows inspired by i3wm.
GNU General Public License v3.0
6.46k stars 187 forks source link

1.7 - Crash: Object reference not set to an instance of an object #122

Closed ParasiteDelta closed 2 years ago

ParasiteDelta commented 2 years ago

Firstly, just want to say, thanks for your work. The amount of features with 1.7 really helps round out the program and make this a fully-featured everyday tool. With 1.6, I actually set it to autostart on boot, and it worked a treat.

That being said, only a few hours into using 1.7, I'm getting a rather generic error and crash, with the main error line being "Object reference not set to an instance of an object." This just randomly started happening, with no additional changes to the config, and it now crashes on launch with the same error. Just to try and get as much as I could, I intentionally launched it a couple more times.

The final thing that I could note is that I think it's something to do with the config itself, maybe some failed or mishandled variable? It was crashing with the old config, so I logged it as old and let the config regenerate. I even copied over the core rules and keybinds (a couple window rules in the same vein as Steam, etc.) with no issue, and it just now started this again, around 6 hours later. Maybe a program that I opened caused some kind of overload or error with the rules in the new version? The additions present in the sample config work fine in 1.6, for the record.

E1: Can confirm that it's an issue with the config pipeline, deleting and regenerating the config made it start up, even works once copy-pasting the changes into the newly-generated config. Some kind of program update error?

---Error Log:

9/11/2022 18:11:08
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.ContainerService.CalculateXOfResizableContainer(Container container) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\ContainerService.cs:line 111
   at GlazeWM.Domain.Containers.CommandHandlers.RedrawContainersHandler.SetWindowPosition(Window window, SWP flags) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\RedrawContainersHandler.cs:line 93
   at GlazeWM.Domain.Containers.CommandHandlers.RedrawContainersHandler.Handle(RedrawContainersCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\RedrawContainersHandler.cs:line 49
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 50

9/11/2022 18:11:46
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:11:46
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44
   at GlazeWM.Domain.Common.CommandHandlers.PopulateInitialStateHandler.Handle(PopulateInitialStateCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Common\CommandHandlers\PopulateInitialStateHandler.cs:line 63
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:15:09
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:15:09
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44
   at GlazeWM.Domain.Common.CommandHandlers.PopulateInitialStateHandler.Handle(PopulateInitialStateCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Common\CommandHandlers\PopulateInitialStateHandler.cs:line 63
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:15:42
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:15:42
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44
   at GlazeWM.Domain.Common.CommandHandlers.PopulateInitialStateHandler.Handle(PopulateInitialStateCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Common\CommandHandlers\PopulateInitialStateHandler.cs:line 63
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:24:18
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

9/11/2022 18:24:18
Object reference not set to an instance of an object.   at GlazeWM.Domain.Containers.CommandHandlers.SetFocusedDescendantHandler.Handle(SetFocusedDescendantCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\SetFocusedDescendantHandler.cs:line 11
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44
   at GlazeWM.Domain.Common.CommandHandlers.PopulateInitialStateHandler.Handle(PopulateInitialStateCommand command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Domain\Common\CommandHandlers\PopulateInitialStateHandler.cs:line 63
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in C:\Users\larsb\repos\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 44

---Complete Config as is, worked for 6 hours:

gaps:
  inner_gap: 20
  outer_gap: 20

bar:
  height: 30
  position: "top"
  opacity: 1.0
  background: "#101010"
  foreground: "white"
  font_family: "Orator Std"
  font_size: "13"
  padding: "1 6 1 6"
  components_left:
    - type: "workspaces"
      focused_workspace_background: "#8192B3"
      displayed_workspace_background: "#42403e"
      default_workspace_background: "#101010"
  components_right:
    - type: "clock"
      time_formatting: "HH:mm:ss | ddd, MMM d"

workspaces:
  - name: 1
  - name: 2
  - name: 3
  - name: 4
  - name: 5
  - name: 6
  - name: 7
  - name: 8
  - name: 9

window_rules:
  # Launches system dialogs as floating by default (eg. File Explorer save/open dialog).
  - command: "set floating"
    match_class_name: "#32770"

  - command: "set floating"
    match_process_name: "/DyingLight|Sam4|CPPFPS-Win64-Shipping|MCC-Win64-Shipping|CPPFPS|Quake4|Synthetik2|Phasmophobia/"

  # Some applications (eg. Steam) have borders that extend past the normal border size.
  - command: "resize borders 0px -7px -7px -7px"
    match_process_name: "/steam|Playnite.DesktopApp|Photo|Designer/"

  - command: "ignore"
    match_process_name: "/Taskmgr|SystemPropertiesAdvanced|BorderlessGaming|QuickSFV|yuzu|hitomi_downloader_GUI/"
    match_class_name: "Qt631QWindowIcon"

keybindings:
  - command: "focus left"
    bindings: ["Alt+H", "Alt+Left"]

  - command: "focus right"
    bindings: ["Alt+L", "Alt+Right"]

  - command: "focus up"
    bindings: ["Alt+K", "Alt+Up"]

  - command: "focus down"
    bindings: ["Alt+J", "Alt+Down"]

  - command: "move left"
    bindings: ["Alt+Shift+H", "Alt+Shift+Left"]

  - command: "move right"
    bindings: ["Alt+Shift+L", "Alt+Shift+Right"]

  - command: "move up"
    bindings: ["Alt+Shift+K", "Alt+Shift+Up"]

  - command: "move down"
    bindings: ["Alt+Shift+J", "Alt+Shift+Down"]

  - command: "resize width -2%"
    binding: "Alt+U"

  - command: "resize width +2%"
    binding: "Alt+P"

  - command: "resize height +2%"
    binding: "Alt+O"

  - command: "resize height -2%"
    binding: "Alt+I"

  - command: "layout horizontal"
    binding: "Alt+Shift+V"

  - command: "layout vertical"
    binding: "Alt+V"

  - command: "toggle focus mode"
    binding: "Alt+Space"

  - command: "toggle floating"
    binding: "Alt+Shift+Space"

  - command: "set minimized"
    binding: "Alt+M"

  - command: "toggle maximized"
    binding: "Alt+X"

  - command: "close"
    binding: "Alt+Shift+Q"

  - command: "exit wm"
    binding: "Alt+Shift+E"

  - command: "reload config"
    binding: "Alt+Shift+R"

  # Launch CMD terminal (alternatively `exec wt` or `exec %ProgramFiles%/Git/git-bash.exe`
  # to start Windows Terminal and Git Bash respectively.
  - command: "exec cmd"
    binding: "Alt+Enter"

  - command: "focus workspace 1"
    binding: "Alt+1"

  - command: "focus workspace 2"
    binding: "Alt+2"

  - command: "focus workspace 3"
    binding: "Alt+3"

  - command: "focus workspace 4"
    binding: "Alt+4"

  - command: "focus workspace 5"
    binding: "Alt+5"

  - command: "focus workspace 6"
    binding: "Alt+6"

  - command: "focus workspace 7"
    binding: "Alt+7"

  - command: "focus workspace 8"
    binding: "Alt+8"

  - command: "focus workspace 9"
    binding: "Alt+9"

  - command: "move to workspace 1"
    binding: "Control+Shift+1"

  - command: "move to workspace 2"
    binding: "Control+Shift+2"

  - command: "move to workspace 3"
    binding: "Control+Shift+3"

  - command: "move to workspace 4"
    binding: "Control+Shift+4"

  - command: "move to workspace 5"
    binding: "Control+Shift+5"

  - command: "move to workspace 6"
    binding: "Control+Shift+6"

  - command: "move to workspace 7"
    binding: "Control+Shift+7"

  - command: "move to workspace 8"
    binding: "Control+Shift+8"

  - command: "move to workspace 9"
    binding: "Control+Shift+9"

  - commands: ["move to workspace 1", "focus workspace 1"]
    binding: "Alt+Shift+1"

  - commands: ["move to workspace 2", "focus workspace 2"]
    binding: "Alt+Shift+2"

  - commands: ["move to workspace 3", "focus workspace 3"]
    binding: "Alt+Shift+3"

  - commands: ["move to workspace 4", "focus workspace 4"]
    binding: "Alt+Shift+4"

  - commands: ["move to workspace 5", "focus workspace 5"]
    binding: "Alt+Shift+5"

  - commands: ["move to workspace 6", "focus workspace 6"]
    binding: "Alt+Shift+6"

  - commands: ["move to workspace 7", "focus workspace 7"]
    binding: "Alt+Shift+7"

  - commands: ["move to workspace 8", "focus workspace 8"]
    binding: "Alt+Shift+8"

  - commands: ["move to workspace 9", "focus workspace 9"]
    bindings: ["Alt+Shift+9"]
lars-berger commented 2 years ago

Hey, thanks for pointing this out!

The very first crash at 18:11:08 actually seems different than the rest of the following crashes. I've got a fix ready for the ones after 18:11:08 - they're caused by just launching GlazeWM with no manageable windows open (eg. by autostarting the WM on boot šŸ˜„).

However, I'm not too sure what could have caused the first crash, and the call stack is unfortunately not super helpful in this case. Was it right after pressing a keybinding? Could it have been a window rule in the original config? Maybe a specific application?

I'll try to add a way to record a JSON dump of the WM state to the error logs, along with a fix for the startup crash, sometime tomorrow šŸ‘

ParasiteDelta commented 2 years ago

Well, from what I remember, the referenced crashes started as I was adding an RPCS3 (PS3 emulator) link to Playnite (AIO PC games library with massive features) as an independent game entry. From that point on, it would crash on start. I tried closing all the windows I had open, I tried using the alternative config location launch parameter, I tried mixing and matching; nothing worked. So, I copied over my current config, deleted the one in the main config directory, generated a new one, then copied over that old config and overwrote it. It not only works, but it works after boot as well as I'm typing this.

As to the crash logs pertaining to no valid windows to hook, that's what's strange: starting with 1.6, I have had this in my Startup folder for weeks now and it works and launches just fine. Even now, with 1.7, it works perfectly. It's only with this crash instance that it emits that error.

ParasiteDelta commented 2 years ago

Well, nailed it down a bit more. So, in Playnite, it pops up a standard Windows dialog for choosing a directory when you go to add a game, and it's this Windows dialog that causes whatever corruption is occurring. Just had it happen, and yet again, it would not re-launch. I copied out the current config, re-launched, regenerated the config, and overwrote the newly-made config with the old one. It now works again.

Whatever new management is going on with the system dialogs is what's causing this, apparently, since during a copy operation, the dialog box would randomly center and stretch to about 75% of my screen until I pulled up a different window or program. Neither the crash with dialogs or the dialog resizing would occur in 1.6.

lars-berger commented 2 years ago

Put out a new release that should fix the crash on boot and improve error logging.

I'm trying to reproduce the initial crash with Playnite, but I'm not too sure what buttons/dialogs to click. Is it somewhere under "+ Add Game" > "Emulated game"?

I've had a couple similar experiences to the dialog resizing issue you're describing and I believe it's actually a separate issue as well šŸ˜†. My guess is that it's caused by the 1.6 feature where resizing the edges of a tiling window causes it to adjust. It's somewhat reproducible by opening "Registry Editor" and moving the window around a little. Was it a copy dialog like this that caused this issue for you - and was it floating or tiling? image

ParasiteDelta commented 2 years ago

Well, the Playnite instance was just any time you would click something that pulled up a Windows dialog for choosing a folder or filepath, so Add Manually or Scan Automatically would do it. However, 1.7.1 does appear to have fixed it for the moment, but I also removed that one line managing Windows dialogs from the config, so I'll see if that had something to do with it. As to the resizing, bizarre. The dialog appeared to open as floating, then randomly fill and stretch on focus loss or change; I'll have to try and recreate it, and again, see if that config line is doing something.

For now, at least, 1.7.1 appears stable. Thanks for the quick patch.

ParasiteDelta commented 2 years ago

Okay, I have no idea what to make of it, so I'll just post it here. It's possible that it was a bug in 1.7, it's possible that it was something with the config, or just something else, but I think I found the issue, and spoilers: it was user error.

So, in the config above, you'll notice that I've grouped together some rules under one ignore or window management command. I don't know if it's a bug or not, but as of 1.7.1 and with signs noted in earlier releases, you are not supposed to do it this way as it creates conflicts. For each type of match (match_process, match_class, etc.), you have to declare its own command or it will conflict and probably break. For example, I lumped in the exclusion for Task Manager, yet it would still create a void and attempt to manage the window even with the rule. However, once I separated the match_process and match_class for the Ignore command, it functions perfectly. This also applies to the dialog rule, where I tried merging it and got the same buggy behavior. I even noted this with my games list, where some would start out as managed before going fullscreen or floating.

Point is, it's very possible that the Windows dialog issues could be a bug, but I honestly think it was just me being stupid and merging conditions without understanding that each command would use additional match statements as compare conditions. So, as far as the random crashes, this issue is closed.

---Final config:

gaps:
  inner_gap: 20
  outer_gap: 20

bar:
  height: 30
  position: "top"
  opacity: 1.0
  background: "#101010"
  foreground: "white"
  font_family: "Orator Std"
  font_size: "13"
  padding: "1 6 1 6"
  components_left:
    - type: "workspaces"
      focused_workspace_background: "#8192B3"
      displayed_workspace_background: "#42403e"
      default_workspace_background: "#101010"
  components_right:
    - type: "clock"
      time_formatting: "HH:mm:ss | ddd, MMM d"

workspaces:
  - name: 1
  - name: 2
  - name: 3
  - name: 4
  - name: 5
  - name: 6
  - name: 7
  - name: 8
  - name: 9

keybindings:
  - command: "focus left"
    bindings: ["Alt+H", "Alt+Left"]

  - command: "focus right"
    bindings: ["Alt+L", "Alt+Right"]

  - command: "focus up"
    bindings: ["Alt+K", "Alt+Up"]

  - command: "focus down"
    bindings: ["Alt+J", "Alt+Down"]

  - command: "move left"
    bindings: ["Alt+Shift+H", "Alt+Shift+Left"]

  - command: "move right"
    bindings: ["Alt+Shift+L", "Alt+Shift+Right"]

  - command: "move up"
    bindings: ["Alt+Shift+K", "Alt+Shift+Up"]

  - command: "move down"
    bindings: ["Alt+Shift+J", "Alt+Shift+Down"]

  - command: "resize width -2%"
    binding: "Alt+U"

  - command: "resize width +2%"
    binding: "Alt+P"

  - command: "resize height +2%"
    binding: "Alt+O"

  - command: "resize height -2%"
    binding: "Alt+I"

  - command: "layout horizontal"
    binding: "Alt+Shift+V"

  - command: "layout vertical"
    binding: "Alt+V"

  - command: "toggle focus mode"
    binding: "Alt+Space"

  - command: "toggle floating"
    binding: "Alt+Shift+Space"

  - command: "set minimized"
    binding: "Alt+M"

  - command: "toggle maximized"
    binding: "Alt+X"

  - command: "close"
    binding: "Alt+Shift+Q"

  - command: "exit wm"
    binding: "Alt+Shift+E"

  - command: "reload config"
    binding: "Alt+Shift+R"

  - command: "exec cmd"
    binding: "Alt+Enter"

  - command: "focus workspace 1"
    binding: "Alt+1"

  - command: "focus workspace 2"
    binding: "Alt+2"

  - command: "focus workspace 3"
    binding: "Alt+3"

  - command: "focus workspace 4"
    binding: "Alt+4"

  - command: "focus workspace 5"
    binding: "Alt+5"

  - command: "focus workspace 6"
    binding: "Alt+6"

  - command: "focus workspace 7"
    binding: "Alt+7"

  - command: "focus workspace 8"
    binding: "Alt+8"

  - command: "focus workspace 9"
    binding: "Alt+9"

  - command: "move to workspace 1"
    binding: "Control+Shift+1"

  - command: "move to workspace 2"
    binding: "Control+Shift+2"

  - command: "move to workspace 3"
    binding: "Control+Shift+3"

  - command: "move to workspace 4"
    binding: "Control+Shift+4"

  - command: "move to workspace 5"
    binding: "Control+Shift+5"

  - command: "move to workspace 6"
    binding: "Control+Shift+6"

  - command: "move to workspace 7"
    binding: "Control+Shift+7"

  - command: "move to workspace 8"
    binding: "Control+Shift+8"

  - command: "move to workspace 9"
    binding: "Control+Shift+9"

  - commands: ["move to workspace 1", "focus workspace 1"]
    binding: "Alt+Shift+1"

  - commands: ["move to workspace 2", "focus workspace 2"]
    binding: "Alt+Shift+2"

  - commands: ["move to workspace 3", "focus workspace 3"]
    binding: "Alt+Shift+3"

  - commands: ["move to workspace 4", "focus workspace 4"]
    binding: "Alt+Shift+4"

  - commands: ["move to workspace 5", "focus workspace 5"]
    binding: "Alt+Shift+5"

  - commands: ["move to workspace 6", "focus workspace 6"]
    binding: "Alt+Shift+6"

  - commands: ["move to workspace 7", "focus workspace 7"]
    binding: "Alt+Shift+7"

  - commands: ["move to workspace 8", "focus workspace 8"]
    binding: "Alt+Shift+8"

  - commands: ["move to workspace 9", "focus workspace 9"]
    binding: "Alt+Shift+9"

window_rules:
  - command: "set floating"
    match_process_name: "/DyingLight|Sam4|CPPFPS-Win64-Shipping|MCC-Win64-Shipping|CPPFPS|Quake4|Synthetik2|Phasmophobia/"

  - command: "set floating"
    match_class_name: "#32770"

  - command: "resize borders 0px -7px -7px -7px"
    match_process_name: "/steam|Playnite.DesktopApp|Photo|Designer/"

  - command: "ignore"
    match_process_name: "/Taskmgr|BCUninstaller|SystemPropertiesAdvanced|BorderlessGaming|QuickSFV|yuzu|hitomi_downloader_GUI/"

  - command: "ignore"
    match_class_name: "Qt631QWindowIcon"
lars-berger commented 2 years ago

Ah no worries, I'm glad it's resolved šŸ‘

When multiple matching criteria are put together, it'll target a window more precisely. For example, match_process_name: /Taskmgr/ and match_class_name: "Qt631QWindowIcon" will only target windows that match both those criteria. The docs def need to be improved a little to clarify this.