GramEditor/gram
39
986
Fork
You've already forked gram
88

gram crashes on custom keybind execution #248

Open
opened 2026年05月01日 06:41:47 +02:00 by dantai · 13 comments
Contributor
Copy link

Hello,

First of all: Thank You for this great tool. I enjoy using it. This is my first issue report ever, so if there is something valuable missing please just let me know!

I created a custom keybind to copy a line of code, focus the terminal, paste it, execute it, and put focus back on the editor. That worked. However something goes horribly wrong sometimes:

When I open a fresh instance of gram and one of my projects, focus a line of code and use my custom keybind - gram immediately freezes completely and does not recover from it - it has to be terminated by the system.
When I open a project, focus a line of code- copy and paste it to the terminal and then execute it - without my keybind- it works. Nothing unexpected happens. When I press my custom keybind now - it just works and I can use it all the time...
It seems that gram needs to be 'activated' in a way I do not understand before being able to perform my keybind safely. I would expect that the keybind works all the time or at least that gram does not crash completely?

Further information /logs: You find the log and my keymap file attached.
The gram log says the following (repeated) at the moment of crash:

  • 2026年05月01日T06:26:24+02:00 INFO [gram::reliability] hang detected, trace file saved at: /home/xxx/.local/share/gram/hang_traces

In the hang_traces folder I have a .miniprof file with one giant line of rust? associated informations which I don't understand. I think it does not contain sensitive information? I could also send it to someone.

System: I am on Fedora 44 x86 using gram 1.2.1. My keyboad layout is german. Inside of gram I did install the R-zed and the julia extension.
Background: I wanted to use gram for coding in R&julia. So I thought to use a Jupyter Kernel and the REPL feature which I failed to get to work, so the keybind is what I tried as a workaround.

Thank You!

EDIT: Tested it on zed today: It has the same issue.

Hello, First of all: Thank You for this great tool. I enjoy using it. This is my first issue report ever, so if there is something valuable missing please just let me know! I created a custom keybind to copy a line of code, focus the terminal, paste it, execute it, and put focus back on the editor. That worked. However something goes horribly wrong sometimes: When I open a fresh instance of gram and one of my projects, focus a line of code and use my custom keybind - gram immediately freezes completely and does not recover from it - it has to be terminated by the system. When I open a project, focus a line of code- copy and paste it to the terminal and then execute it - without my keybind- it works. Nothing unexpected happens. When I press my custom keybind now - it just works and I can use it all the time... It seems that gram needs to be 'activated' in a way I do not understand before being able to perform my keybind safely. I would expect that the keybind works all the time or at least that gram does not crash completely? Further information /logs: You find the log and my keymap file attached. The gram log says the following (repeated) at the moment of crash: - 2026年05月01日T06:26:24+02:00 INFO [gram::reliability] hang detected, trace file saved at: /home/xxx/.local/share/gram/hang_traces In the hang_traces folder I have a .miniprof file with one giant line of rust? associated informations which I don't understand. I think it does not contain sensitive information? I could also send it to someone. System: I am on Fedora 44 x86 using gram 1.2.1. My keyboad layout is german. Inside of gram I did install the R-zed and the julia extension. Background: I wanted to use gram for coding in R&julia. So I thought to use a Jupyter Kernel and the REPL feature which I failed to get to work, so the keybind is what I tried as a workaround. Thank You! EDIT: Tested it on zed today: It has the same issue.

This is my first issue report ever, so if there is something valuable missing please just let me know!

I hope it's not your last! I love seeing bug reports where the reporter has really tried to think through what seems to be going wrong.

> This is my first issue report ever, so if there is something valuable missing please just let me know! I hope it's not your last! I love seeing bug reports where the reporter has really tried to think through what seems to be going wrong.
Author
Contributor
Copy link

Hello again!

To narrow it further down:

I start a new session of gram, open a project, use my keybind -> it freezes

I start a new session of gram, open a project, perform a copy or a paste action in either the editor or the terminal. Later I perform the keybind. It works.

It seems to be that performing other keybinds (for example open the sidebar or open code completion) before using the custom keybind itself does not help. The ones I figured out make the crash disappear are copy and paste.

Hope that helps. Thank you :)

EDIT: Zed 1.0 has the same issue (tested today)

Hello again! To narrow it further down: I start a new session of gram, open a project, use my keybind -> it freezes I start a new session of gram, open a project, perform a copy or a paste action in either the editor or the terminal. Later I perform the keybind. It works. It seems to be that performing other keybinds (for example open the sidebar or open code completion) before using the custom keybind itself does not help. The ones I figured out make the crash disappear are copy and paste. Hope that helps. Thank you :) EDIT: Zed 1.0 has the same issue (tested today)
Owner
Copy link

Thank you!

Thank you!
Author
Contributor
Copy link

Hello,

A short update from my side:

After some research I did convert my miniprof file (hangtrace) into a tracy file using the zed-dev documentation and the zed fork of tracy: https://zed.dev/docs/performance
You can find it attached. The log file above and the tracy file belong together, so you can use it to identify the timestamps. Looking into it with tracy (https://tracy.nereid.pl/).. I am not so sure where to look. So in the log the hang starts at around second 12, maybe the event occured a bit earlier. One hint on the main thread (the best I found since tracys output is not super easy/obvious to me) points me to the following function inside of grams source code:

crates/workspace/src/workspace.rs:2355

I find the following in line 2355 .... It is inside a public? function called send_keystrokes_impl ()

state.queue.extend(keystrokes);

A comment a bit later in line 2362 talks about "avoiding infinite recursion". Maybe this did not work out?

Since I am not a rust dev ( I usually do simple statistical coding ...) I do not really know what to do with this but I am glad to have gotten so far......

Thank You :)!

Hello, A short update from my side: After some research I did convert my miniprof file (hangtrace) into a tracy file using the zed-dev documentation and the zed fork of tracy: https://zed.dev/docs/performance You can find it attached. The log file above and the tracy file belong together, so you can use it to identify the timestamps. Looking into it with tracy (https://tracy.nereid.pl/).. I am not so sure where to look. So in the log the hang starts at around second 12, maybe the event occured a bit earlier. One hint on the main thread (the best I found since tracys output is not super easy/obvious to me) points me to the following function inside of grams source code: crates/workspace/src/workspace.rs:2355 I find the following in line 2355 .... It is inside a public? function called send_keystrokes_impl () state.queue.extend(keystrokes); A comment a bit later in line 2362 talks about "avoiding infinite recursion". Maybe this did not work out? Since I am not a rust dev ( I usually do simple statistical coding ...) I do not really know what to do with this but I am glad to have gotten so far...... Thank You :)!
Owner
Copy link

Hi,

Thank you! That’s definitely a good start. I’ll try to have a look as soon as I have time.

Hi, Thank you! That’s definitely a good start. I’ll try to have a look as soon as I have time.
Author
Contributor
Copy link

Hello :)

a short update: The newest version(s?) of zed fix this behavior and the keystroke sending also seems to be quicker in a way if I am not wrong. I will try to look if I can find what was fixing this issue, maybe that could be backported :)*

I will try it, but last time my machine got too low on ram to compile gram ....:/

Hello :) a short update: The newest version(s?) of zed fix this behavior and the keystroke sending also seems to be quicker in a way if I am not wrong. I will try to look if I can find what was fixing this issue, maybe that could be backported :)* I will try it, but last time my machine got too low on ram to compile gram ....:/
Owner
Copy link

Hi :)

Yeah it's demanding. There are some hints to get the compiler to use less RAM here:

https://gram-editor.com/docs/development/

Hi :) Yeah it's demanding. There are some hints to get the compiler to use less RAM here: https://gram-editor.com/docs/development/
Author
Contributor
Copy link

Hello!

Okay, So I needed to increase my swap size to compile gram and finally...

Merging these two commits - or at least the changes in the workspace crate - into gram :

github.com/zed-industries/zed@e18da9ef6d

github.com/zed-industries/zed@8f329d1ee3

does fix the issue and it seems somehow quicker now in performing the keybind combination. I am very happy :) Indeed it was in the function send_keystrokes_impl in the workspace crate

@krig : What do you think? Could/Should I hand that in somehow? I am a bit excited that it worked :)

Hello! Okay, So I needed to increase my swap size to compile gram and finally... Merging these two commits - or at least the changes in the workspace crate - into gram : https://github.com/zed-industries/zed/commit/e18da9ef6d8019ac726e050d9b15cab931d9e738 https://github.com/zed-industries/zed/commit/8f329d1ee330f7d05a3fc36301b9988878e61aa2 does fix the issue and it seems somehow quicker now in performing the keybind combination. I am very happy :) Indeed it was in the function send_keystrokes_impl in the workspace crate @krig : What do you think? Could/Should I hand that in somehow? I am a bit excited that it worked :)
Owner
Copy link

@dantai Hi! Great that you got it working. Yeah, I’d be happy to merge those if you want to create a PR, thank you!

@dantai Hi! Great that you got it working. Yeah, I’d be happy to merge those if you want to create a PR, thank you!
Author
Contributor
Copy link

Okay, I prepared everything for the PR and the bug reappeared when testing it again. In zed as well as in gram... I am sorry.

I do not get it... It reappeared after clearing the cache... I do not know if this was accidental but it seems to be more complicated and not so easy predictable, maybe something with the interaction with the host-system (I updated stuff (including zed) as well...)

Strange that it worked well quite a number of times and it was different in gram and zed....

Okay, I prepared everything for the PR and the bug reappeared when testing it again. In zed as well as in gram... I am sorry. I do not get it... It reappeared after clearing the cache... I do not know if this was accidental but it seems to be more complicated and not so easy predictable, maybe something with the interaction with the host-system (I updated stuff (including zed) as well...) Strange that it worked well quite a number of times and it was different in gram and zed....
Author
Contributor
Copy link

Hallo again :)

Okay, this commit from a zed pre-release finally fixes it also for gram...

https://github.com/zed-industries/zed/pull/58826

I will continue testing it and create a PR if it keeps working.

The times gram freezed is now a 4sec waiting period after which gram continues to work again.

What I think happens (if I understood it correctly from the commit) under wayland... The combined keybind /copy action opens the copy buffer/clipboard and the paste action shortly afterwards tries to read the copy buffer while it is still empty or something is still open(?) and then the read action halts gram forever.
It still feels a bit awkward that there are 4sec hangs now but the copy and then paste immediately again keybind action is maybe also an unusual scenario... and it is much better to wait 4sec then to kill the process...

Maybe there is something to the copy action in gram/zed or to the execution of a sequence of keybinds that the later keybind does not wait for the previous one to be finished. Ensuring that would fix it completely then.?...

Hallo again :) Okay, this commit from a zed pre-release finally fixes it also for gram... https://github.com/zed-industries/zed/pull/58826 I will continue testing it and create a PR if it keeps working. The times gram freezed is now a 4sec waiting period after which gram continues to work again. What I think happens (if I understood it correctly from the commit) under wayland... The combined keybind /copy action opens the copy buffer/clipboard and the paste action shortly afterwards tries to read the copy buffer while it is still empty or something is still open(?) and then the read action halts gram forever. It still feels a bit awkward that there are 4sec hangs now but the copy and then paste immediately again keybind action is maybe also an unusual scenario... and it is much better to wait 4sec then to kill the process... Maybe there is something to the copy action in gram/zed or to the execution of a sequence of keybinds that the later keybind does not wait for the previous one to be finished. Ensuring that would fix it completely then.?...
Owner
Copy link

Great, sounds good to at least not hang :)

Great, sounds good to at least not hang :)
Author
Contributor
Copy link

Okay, testing the newer versions of zed again I see that they do not really hang anymore whilst gram has the 4 sec hang from time to time.
I think there are still improvements in zed to catch up for the wayland clipboard.... I will see what I can find...

Okay, testing the newer versions of zed again I see that they do not really hang anymore whilst gram has the 4 sec hang from time to time. I think there are still improvements in zed to catch up for the wayland clipboard.... I will see what I can find...
Sign in to join this conversation.
No Branch/Tag specified
main
test/wgpu-on-mac
test-ci/failing-test-mac
test/failing-test-mac
test/build-on-22-04
test/wgpu-present-mode-mailbox
v2.1
test/altgr-fix-again
test/2.0.0-rc1
test/linux-build
test/objc2
v1.2.1
3.0.1
3.0.0
2.2.0
2.1.2
2.1.1
2.1.0
2.0.0
1.2.1
1.2.0
1.1.0
1.0.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GramEditor/gram#248
Reference in a new issue
GramEditor/gram
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?