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

Freeze on M1 Mac with kind-icon, corfu and eglot installed #333

Open
drewmoseley opened this issue Apr 15, 2023 · 10 comments
Open

Freeze on M1 Mac with kind-icon, corfu and eglot installed #333

drewmoseley opened this issue Apr 15, 2023 · 10 comments

Comments

@drewmoseley
Copy link

I have a configuration that will lock up with eglot is attempting to provide details about source components. Unfortunately the minimal config that seems to reproduce it is longer than ideal:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)

(package-initialize)
(package-install 'eglot)
(package-install 'corfu)
(package-install 'kind-icon)
(package-install 'tree-sitter)
(package-install 'tree-sitter-langs)

(setq
 corfu-cycle t
 corfu-auto t
 corfu-popupinfo-delay 0.5
 kind-icon-default-face 'corfu-default
 )

(global-corfu-mode)
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)
(global-tree-sitter-mode)

In this case if I open a C file such as:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  print
}

explicitly launch eglot (M-x eglot) and then delete and retype the word "print", Emacs will lock up and need to be force-quit. It seems that some combination of corfu popups, kind-icons, and eglot source analysis locks up.

The same config does not lock up in an EmacsForMacOSX nightly. (The release build doesn't work due to lack of SVG support).

Similarly, this works properly on Ubuntu.

@railwaycat
Copy link
Owner

I'm not very sure if (global-tree-sitter-mode) is related here? The latest emacs mac port still based on the Emacs 28 branch, but not on 29 yet. As far as I know tree-sitter support is in Emacs since 29?

@drewmoseley
Copy link
Author

I'm using the external package version of tree-sitter. By itself It does seem to work ok. It only seems to be in combination with all the other packages that there is an issue.

@jdtsmith
Copy link

jdtsmith commented Aug 1, 2023

pkill -SIGUSR2 Emacs will probably give you a traceback. I'd suspect your language server. corfu and eglot don't play super well together. You may need to wrap eglot-capf in cape-capf-buster and cape-wrap-noninterruptible.

@jdtsmith
Copy link

jdtsmith commented Aug 1, 2023

You should also be sure to use --with-libsrvg when compiling; see #312.

@drewmoseley
Copy link
Author

Unfortunately, I don't get a backtrace using pkill. I'll keep an eye out for a new build using --with-libsrvg and retest.

@lhernanz
Copy link

lhernanz commented Oct 9, 2023

Same problem here, also with the combination of kind-icon and corfu. This is happening to me in org-mode where there is not lsp/eglot involved. This is the stack trace that I get, it seems that the problem is related to the parsing of the kind-icon SVG icons:

Heaviest stack for the main thread of the target process:
  47  start + 2236 (dyld + 24360) [0x194223f28]
  47  main + 612 (Emacs + 2403560) [0x100336ce8]
  47  main.cold.1 + 16 (Emacs + 2575684) [0x100360d44]
  47  mac_gui_loop + 68 (Emacs + 2404320) [0x100336fe0]
  47  __document_rasterizer_create_block_invoke.1501 + 32 (Emacs + 2406248) [0x100337768]
  47  -[EmacsSVGDocument initWithData:options:] + 204 (Emacs + 2380280) [0x1003311f8]
  47  -[WKWebViewConfiguration init] + 64 (WebKit + 3447736) [0x1b558abb8]
  47  WebKit::InitializeWebKit2() + 84 (WebKit + 123684) [0x1b525f324]
  47  std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) + 180 (libc++.1.dylib + 87712) [0x1944a76a0]
  47  WebKit::runInitializationCode(void*) + 36 (WebKit + 2336804) [0x1b547b824]
  47  JSC::initialize() + 84 (JavaScriptCore + 17684408) [0x1af9947b8]
  47  std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) + 180 (libc++.1.dylib + 87712) [0x1944a76a0]
  47  JSC::initialize()::$_11::operator()() const + 60 (JavaScriptCore + 17720460) [0x1af99d48c]
  47  ??? [0xffff8001aeeeac24]
  47  _sigtramp + 56 (libsystem_platform.dylib + 14884) [0x1945aaa24]
  47  __sigsuspend + 8 (libsystem_kernel.dylib + 60864) [0x194549dc0]
 *47  ??? (kernel.release.t6000 + 5228196) [0xfffffe00088e46a4]

@jdtsmith
Copy link

jdtsmith commented Oct 9, 2023

Try just this in the *scratch* buffer:

(require 'svg-lib)
(insert-image (svg-lib-icon "heart" '(:foreground "blue")))

Everyone should recompile --with-librsvg and test again.

@lhernanz
Copy link

lhernanz commented Oct 9, 2023

Hard freeze again on the second command. Exactly the same stack trace as above.

@jdtsmith
Copy link

jdtsmith commented Oct 9, 2023

I understand that emacs-mac in recent versions had to switch to some javascript-driven Webkit SVG display usage as the former API they were using disappeared (see #312). The webkit version is quite slow, and perhaps is also related to this crash given the traceback.

I've found using librsvg to be perfectly stable, so give that a try, like so (altering flags to taste):

brew install emacs-mac --with-librsvg --with-native-compilation  

You could M-x report-emacs-bug to put this in front of the emacs-mac developer.

@lhernanz
Copy link

Thanks! Compiling with librsvg seems to be doing the trick. I will keep testing this for a few days to make sure that everything is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants