Open benthamite opened 5 months ago
I have seen Emacs hang with pdf-tools
but it has been due to some interaction with url-queue
that I don't understand. My best guess is there is some race condition somewhere in the tq
library that pdf-tools
use and if pdf-info-query
always shows up at the top of backtrace, you are probably seeing another manifestation of the same thing.
You can try disabling pdf-cache-prefetch-minor-mode
and see if the hangs persist. This helped me, but since the hangs happen after inactivity (prefetching should be done by then) I doubt that it will help your case.
Another thing to figure out is why is the size of the window changing (likely when the Emacs frame gets focus). Do you have any customizations for after-focus-change-function
or focus-in-hook
?
Thanks. I have disabled pdf-cache-prefetch-minor-mode
and will report back if I notice any change.
I don't have any customizations for after-focus-change-function
or focus-in-hook
.
Assuming pdf-view-maybe-redisplay-resized-windows
always shows up in the backtrace, one thing to try will be to resize a pdf window manually using mouse or keybind and see if you can reproduce the issue that way.
The issue can be reproduced by opening a PDF and M-x toggle-frame-fullscreen
. Resize using mouse or Rectangle keybindings doesn't stuck Emacs.
Environment:
(setq ns-use-native-fullscreen nil)
A workaround is to (setq ns-use-native-fullscreen t)
.
The issue can be reproduced by opening a PDF and
M-x toggle-frame-fullscreen
. Resize using mouse or Rectangle keybindings doesn't stuck Emacs.Environment:
* macOS Version 14.6 (23G80) * GNU Emacs 29.3 (build 1, aarch64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.5.2 (Build 22G91)) * `(setq ns-use-native-fullscreen nil)`
A workaround is to
(setq ns-use-native-fullscreen t)
. Screencast CleanShot.2024-08-06.at.22.12.51.mp4
Does it happen with just emacs -Q
and pdf-tools-mode
? And can you please produce a backtrace? (Do M-x toggle-debug-on-quit RET
before full screening. C-g
will produce a backtrace if it works. If it doesn't pkill -SIGUSR2 emacs
should do the trick.)
@aikrahguzar I tried to get the backtrace according to your methods.
C-g
cannot recover the Emacs from frozen state, then I tried pkill -SIGUSR2 Emacs
(I'm using the Emacs.app on macOS). It kills the Emacs but I don't know where to get the backtrace.
@goofansu, pkill -SIGUSR2 Emacs
should both kill the process and create an associated backtrace. Did you look for it in the list of buffers (C-x b *Backtrace*
)?
@benthamite I can only see a transparent *Backtrace*
buffer in Mission Control after using the command, see the video: https://share.cleanshot.com/GPdZtJWbDHZvsGfxdqxM
@goofansu, what appears to be going on is that pkill -SIGUSR2 Emacs
didn’t succeed in killing the relevant process, so Emacs continues to be unresponsive. You can try the "nuclear option" while true; do pkill -SIGUSR2 Emacs; done
and see if this does the trick. You may also want to try a combination of pkill -SIGUSR2 Emacs
, hitting ESC
repeatedly and wait a few minutes, which in my experience sometimes eventually restores the Emacs session and triggers the backtrace. Otherwise, this may be one of those cases when restarting is the only option, in which case producing a backtrace won’t be possible.
(Also, before you do any of the above, you may want to run pkill -SIGUSR2 Emacs
when Emacs is working normally, just to test if this command has its intended effect in normal circumstances.)
(Also, before you do any of the above, you may want to run
pkill -SIGUSR2 Emacs
when Emacs is working normally, just to test if this command has its intended effect in normal circumstances.)
@benthamite It works in normal circumstance:
Then I made Emacs frozen like https://github.com/vedang/pdf-tools/issues/278#issuecomment-2321548661, and run while true; do pkill -SIGUSR2 Emacs; done
in bash shell, Emacs just crashed and I still cannot visit the *Backtrace*
buffer.
You may also want to try a combination of pkill -SIGUSR2 Emacs, hitting ESC repeatedly and wait a few minutes, which in my experience sometimes eventually restores the Emacs session and triggers the backtrace.
I'll try this combination.
@benthamite I found I can select and run command in the transparent *Backtrace*
buffer although I cannot see the content, but unfortunately the content I copied doesn't help:
Debugger entered--entering a function:
* help-command-error-confusable-suggestions((quit) "" nil)
Mmh, weird: I don’t quite understand what’s going on.
In any case, thank you for your efforts in helping us debug this issue.
@goofansu I don't have a good idea on how to proceed with debugging. I think running under gdb
might help but I don't know how to go about that. If you can please post a question about how to debug this situation to help-gnu-emacs. You will likely get response for Emacs maintainers and people on that list are very helpful.
@aikrahguzar Ok, I will. Thank you for the guide.
Describe the bug
When I leave the computer and the current buffer is displaying a PDF file with
pdf-tools
, upon returning to it hours later I sometimes have to runpkill -SIGUSR2 Emacs
. In those cases, the debugger returns a backtrace like this:Steps to Reproduce the behaviour The behavior is not easily reproducible because it happens erratically and only after long periods of inactivity.
What is the expected behaviour? Emacs does not get stuck.
Desktop Please complete the following information:
Your pdf-tools install Please complete the following information:
pdf-tools
Version:pdf-tools
customization / configuration that you use: