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

WezTerm freezes on restoring session. #83

Open
Tanish2002 opened this issue Dec 30, 2024 · 9 comments
Open

WezTerm freezes on restoring session. #83

Tanish2002 opened this issue Dec 30, 2024 · 9 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Tanish2002
Copy link

Hi, thanks for the plugin.

I tried to use this in my config:

local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm")
resurrect.periodic_save()
...
  {
    key = "w",
    mods = "ALT|SHIFT",
    action = wezterm.action_callback(function(win, pane)
      resurrect.save_state(resurrect.workspace_state.get_workspace_state())
      resurrect.window_state.save_window_action()
    end),
  },
...
wezterm.on("smart_workspace_switcher.workspace_switcher.created", function(window, path, label)
  local workspace_state = resurrect.workspace_state
  workspace_state.restore_workspace(resurrect.load_state(label, "workspace"), {
    window = window,
    relative = true,
    restore_text = true,
    on_pane_restore = resurrect.tab_state.default_on_pane_restore,
  })
end)

The session saves fine, but when I try to restore a session by simply using smart_workspace_switcher and then opening my previous zoxide directory. Wezterm straight up freezes nothing works.

I don't know what logs you would expect from me, but here is the saved workspace state(Please feel free to ask for any other logs):

{
  "window_states": [
    {
      "size": {
        "cols": 221,
        "dpi": 96,
        "pixel_height": 861,
        "pixel_width": 1768,
        "rows": 41
      },
      "tabs": [
        {
          "is_active": false,
          "is_zoomed": false,
          "pane_tree": {
            "alt_screen_active": false,
            "cwd": "/home/weeb/nixos-config",
            "domain": "local",
            "height": 41,
            "index": 0,
            "is_active": true,
            "is_zoomed": false,
            "left": 0,
            "pixel_height": 861,
            "pixel_width": 1768,
            "text": "\r\n\u001b(B\u001b[0;1m\u001b[36m~/nixos-config\u001b(B\u001b[0m \r\n\u001b(B\u001b[0;1m\u001b[35m❯\u001b(B\u001b[0m \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\u001b(B\u001b[0m",
            "top": 0,
            "width": 221
          },
          "title": ""
        },
        {
          "is_active": true,
          "is_zoomed": false,
          "pane_tree": {
            "alt_screen_active": true,
            "cwd": "/home/weeb/nixos-config",
            "domain": "local",
            "height": 41,
            "index": 0,
            "is_active": true,
            "is_zoomed": false,
            "left": 0,
            "pixel_height": 861,
            "pixel_width": 1768,
            "process": {
              "argv": [
                "/nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37/bin/bash",
                "/nix/store/hbdrhm4w2nsjhl2aff9cfqdwrqqx3pgk-scripts/bin/.pipes-wrapped"
              ],
              "cwd": "/home/weeb/nixos-config",
              "executable": "/nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37/bin/bash",
              "name": ".pipes-wrapped",
              "start_time": 338194,
              "status": "Sleep"
            },
            "top": 0,
            "width": 221
          },
          "title": ""
        }
      ],
      "title": ""
    }
  ],
  "workspace": "~/nixos-config"
}
@Tanish2002
Copy link
Author

from what I've figured out, it's struggling to resurrect inside the current window.

If i remove the following from workspace_state.restore_workspace(resurrect.load_state(label, "workspace"), {

window = window,

then it works fine, it just opens the workspace in a new window.

@Tanish2002
Copy link
Author

Found the problematic part, I believe, this line causes the issue. If I comment it out then everything works fine:

opts.window:gui_window():set_inner_size(window_state.size.pixel_width, window_state.size.pixel_height)

@MLFlexer
Copy link
Owner

Thank you very much for the detailed description and investigation! 😄

I would be interested to know if you changing resolution, like when switching monitors?

And can you replicate it and then check the output of the debug menu? The default keybindings to open it is CTRL+SHIFT+L
If this does not work because it is freezing, then it would be great if you can try with wezterm start --always-new-process and check the output. There might be a printed error, which could give a better indication of what is wrong.

@Tanish2002
Copy link
Author

Hi @MLFlexer,

I don't have a separate monitor so no, I didn't do anything like that.

As for the debug menu, I can't access it due to terminal completely freezing.
Unfortunately when I try to debug using wezterm start --always-new-process, no error is printed, just the spawned term freezes which I can close by CTRL+C on the original term window which was used to spawn it.

@MLFlexer
Copy link
Owner

MLFlexer commented Jan 3, 2025

Hi @MLFlexer,

I don't have a separate monitor so no, I didn't do anything like that.

As for the debug menu, I can't access it due to terminal completely freezing. Unfortunately when I try to debug using wezterm start --always-new-process, no error is printed, just the spawned term freezes which I can close by CTRL+C on the original term window which was used to spawn it.

Thanks for trying it out.

Unfortunetly this makes it a bit difficult to figure out the main cause of this.

Do you know if it is related to the current GUI window being smaller or larger than the one you are trying to resurrect?

And is this something you have experienced many times? or just with this particular resurrected state?

@MLFlexer MLFlexer added bug Something isn't working help wanted Extra attention is needed labels Jan 3, 2025
@Tanish2002
Copy link
Author

Here’s a rewritten version of your reply for the GitHub issue:

Hi @MLFlexer,

And is this something you have experienced many times? or just with this particular resurrected state?
This issue occurs consistently for all workspaces, not just for a specific resurrected state.

The windows are the exact same size as the one I am trying to resurrect since I use AwesomeWM it manages them automatically. Also the issue occurs for all saved workspaces..

However, your question about resizing prompted me to experiment, and I discovered that resizing the window actually unfreezes the terminal.

Here’s a video demonstrating the behavior:

wezterm-2025-01-04_02.12.18.mp4

Let me know if there's any additional information or logs I can provide to help troubleshoot this further.

@MLFlexer
Copy link
Owner

Sorry for the late reply, have been very busy lately...

Thanks for the additional information!

Does it work if you change your config to use relative=false?

Also can you try and make a keybind which changes the window size using set_inner_size and see if there is a particular input it crashes on?
I am afraid this might be a Wezterm problem and not the plugin :/

Try the following keybind:

{
	key = "x",
	mods = "ALT",
	action = wezterm.action_callback(function(window, pane)
		window:set_inner_size(<width>, <height>)
	end),
},

@MLFlexer
Copy link
Owner

Also, do you have window decorations and padding set? Because, then it might be related to #72 (comment) aswell

@MLFlexer
Copy link
Owner

#87 adds an option to avoid resizing, that might help initially, but I think it would be beneficial if you could also test the set_inner_size inputs, to see if it is a problem with Wezterm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants