I have been running emacs (x11 version, unwittingly) on wayland without realizing there is a wayland-specific version of emacs. My desktop has started spontaneously going apeshit and crashing. So my first move was to run emacs this way:

$ emacs --fg-daemon
$ emacsclient -c

The idea was that when the display manager goes to shit, I don’t lose my shit. I should be able to simply reattach to my emacs session by running emacsclient -c. Starting the emacs server yields this msg:

Warning: due to a long standing Gtk+ bug¹ https://gitlab.gnome.org/GNOME/gtk/issues/221 Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost. Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.

Yikes. Note the keyword might crash. So there is an arbitrary chance of survival. So then I discovered there is a wayland-specific version of emacs (emacs-pgtk). Installing it on debian required removing the original X11 version of emacs and resolving some dependency issues by not installing some pkgs. Fine, I did that. Now when I run emacs-pgtk as a server, it starts with:

Due to a limitation in GTK 3, Emacs built with PGTK will simply exit when a display connection is closed. The problem is especially difficult to fix, such that Emacs on Wayland with multiple displays is unlikely ever to be able to survive disconnects.

Fuck. So now when wayland crashes or is shut down, there is no chance of recovery. WTF? I was perhaps better off running the X11 version on wayland, where there is at least a non-deterministic chance of recovery.

¹ Apparently gitlab.gnome.org is an exclusive access-restricted website, so I am blocked from even reading about the bug.

  • Zenie@piaille.fr
    link
    fedilink
    arrow-up
    2
    ·
    9 days ago

    @evenwicht

    Yea, that is an old one. I did just read something here about it. It seems like there was some enlightenment.

    But the devs on both sides are in denial about it.

    • Zenie@piaille.fr
      link
      fedilink
      arrow-up
      1
      ·
      7 days ago

      @evenwicht

      Building Emacs is only difficult the first time.

      Most systems can’t just find everything is needs. I just do it the way everything used to be.

      I run ./configure and look at the logs with grep to see what is missing. I hate the way apt names things, figuring out the package name to install is sometimes difficult.

    • evenwichtOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      9 days ago

      As I see it, emacs is the heart and soul of the whole gnu infra. Multi-million dollar projects have their engineers using it, particularly in aerospace. And gtk is not the only game in town. It is GTK that must serve the needs of emacs, not the other way around. So if GTK is failing to serve emacs well, why isn’t emacs ditching it? I suppose there is a diffusion of responsibility problem… none of the projects that depend on emacs, however big, wants to pony up the money that would benefit everyone.

          • evenwichtOP
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            9 days ago

            Do you know off-hand what that entails? I ran this in Debian:

            $ apt-cache depends emacs
            emacs
             |Depends: emacs-gtk
             |Depends: emacs-lucid
              Depends: emacs-nox
            
            $ apt-cache depends emacs-gtk | grep gtk
            emacs-gtk
              Depends: libgtk-3-0
            

            (edit) found the following, which implies that I need to compile emacs myself:

            https://gist.github.com/abelardojarab/f4c154f1aa4e15fe6b97a8cfc2010022

            The --with-x-toolkit=lucid option was also mentioned in the warning output of the daemon of the x11 version of emacs.

            It would be interesting to know if any platform already builds emacs that way. Would be nice if repology.org tracked that but I doubt it does.

              • evenwichtOP
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                8 days ago

                ah, thanks!

                (update) Oof!

                aptitude install emacs-lucid -r
                The following NEW packages will be installed:
                  emacs-lucid{b} libm17n-0{a} m17n-db{a} 
                0 packages upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
                Need to get 5,978 kB/7,529 kB of archives. After unpacking 43.9 MB will be used.
                The following packages have unmet dependencies:
                 emacs-pgtk : Conflicts: emacs-lucid but 1:28.2+1-15+deb12u4 is to be installed
                 emacs-lucid : Depends: emacs-bin-common (= 1:28.2+1-15+deb12u4) but 1:30.1+1-6~bpo12+1 is installed
                               Depends: emacs-common (= 1:28.2+1-15+deb12u4) but 1:30.1+1-6~bpo12+1 is installed
                 emacs-bin-common : Breaks: emacs-lucid (< 1:29.2) but 1:28.2+1-15+deb12u4 is to be installed
                The following actions will resolve these dependencies:
                
                     Keep the following packages at their current version:
                1)     emacs-lucid [Not Installed]                        
                
                
                
                Accept this solution? [Y/n/q/?]
                

                I guess I have to remove emacs and go from scratch. Although if that’s possible, I have to wonder why apt could not figure this out.

  • Xuqi@todon.nl
    link
    fedilink
    arrow-up
    2
    ·
    9 days ago

    @evenwicht To add a data point: When using KDE (and Proton) on Wayland, my emacs crashes 90% of the time if the computer wakes from suspend, and 100% crashes when the desktop switches from light mode to dark mode and vice versa. After switching to another wayland compositor and DE Emacs never crashes.

    • evenwichtOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      9 days ago

      what is DE? I am using sway on wayland. Maybe I should replace sway with something else.

      (edit) although I should say emacs never crashes for me /without provocation/. But when wayland crashes, then the emacs daemon often crashes as a consequence.

      • Xuqi@todon.nl
        link
        fedilink
        arrow-up
        2
        ·
        9 days ago

        @evenwicht My bad, I should make clear that DE = desktop environment. And I did not use the word properly since I did not replace the whole KDE thing. I use niri + noctalia now.

  • Jerkface (any/all)@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    3
    ·
    8 days ago

    Just don’t run the GTK version? These bugs have existed for decades now. I don’t know why GTK is the default version, I never installl it.

    • evenwichtOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 days ago

      The bugs may be old but they don’t seem to be triggered in normal circumstances. Hence why they are not fixed over a long time. The bugs are only killing me now because of other bugs (wayland just recently started going randomly apeshit and crashing for me lately). The server mode is a workaround for those other bugs in my case. But I can see why some advanced users would like to use the server mode anyway.

      Debian offers these 3 versions (possibly more):

      • emacs-gtk
      • emacs-pgtk
      • emacs-lucid

      Installing emacs-lucid after installing emacs-pgtk is a shit show, which then makes emacs-pgtk a terrible default. And as you rightly point out, emacs-gtk is a bad default because it sometimes crashes when the display manager goes down. That leaves emacs-lucid. Perhaps that should be the default on debian when someone runs apt install emacs. Or perhaps even better would be for the installer to interview users to find out which of the 3 is ideal for the user.

      The Debian bug tracker has recently undergone some defensive changes that now block bug submission over tor. So I guess won’t document this idea anywhere that matters.

      • Jerkface (any/all)@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        2
        ·
        8 days ago

        Not sure I agree with your premise. It is a perfectly normal use case that happens frequently for everyone using emacs-server, which is intended and expected to outlive interactive sessions like a DE. This wart is a shame on both projects. I suppose you are saying that emacs-server itself is an obscure case, which I can’t really speak to.

        • evenwichtOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          8 days ago

          It’s likely rare to use the emacs server mode at all. Most users would consider that extra complexity for nothing as far as their needs go. It has some nuanced advantages for advanced users. Consider that rudel had potential to make server mode broadly interesting for a wide userbase because multiple users could simultaneously collaborate on the same emacs buffer. Rudel is non-debian and not included as part of emacs. And it was last touched 4 years ago IIUC. Then within the already small number of users of the server, some will shutdown the DE and restart it, or switch DEs, or suffer from DE crashes. It’s a quite rare scenario within an uncommonly used feature.

          Of course it’s a clear bug that the server does not outlive the DE, and an embarrassment. The reason it has persisted could only be attributed to lack of demand for a fix. You and I are probably like 2 in a million people who care to have it fixed. I can only speculate since I cannot reach the access-restricted bug tracker on gnome.org. I don’t suppose gitlab has a bug voting feature like launchpad does for ubuntu.