flathub / net.ankiweb.Anki

https://flathub.org/apps/details/net.ankiweb.Anki
20 stars 13 forks source link

Application does not start on wayland (sway) #45

Closed ManIVIctorious closed 3 months ago

ManIVIctorious commented 3 years ago

The current Anki flatpak build

flatpak info net.ankiweb.anki
Anki - Powerful, intelligent flash cards

          ID: net.ankiweb.Anki
         Ref: app/net.ankiweb.Anki/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 2.1.40
     License: AGPL-3.0+
      Origin: flathub
  Collection: org.flathub.Stable
Installation: system
   Installed: 357.0 MB
     Runtime: org.kde.Platform/x86_64/5.15
         Sdk: org.kde.Sdk/x86_64/5.15

      Commit: fc649a49e40b5246e80c1a5a8ca01a48829fe04292dcb116a9c4e1d6e99d0466
      Parent: 7d7afb8b9600016704a14199cb346a697794b9b5b214ef9fc3b08d4a489ead61
     Subject: Update to Anki 2.1.40 and waf 2.0.22 (74c473bc)
        Date: 2021-04-02 14:35:47 +0000

does not seem to work under wayland (at least in sway enabling access to wayland socket is not enough to start the GUI), albeit the current arch linux package (version 2.1.35) seems to work properly, even on xdg_shell.

I spent about half an hour to investigate this but found no proper solution (a wayland enabled build would be highly appreciated). At least I could find a workaround to start the application via xwayland.

As an interim solution could you add the environment variable QT_QPA_PLATFORM=xcb to the flatpak build/manifest (not sure about the terminology here).

laolux commented 3 years ago

Maybe this is a sway issue? Using Fedora 34 beta and Gnome 40 I can use the latest anki flatpak without any problems. Trying with xeyes indicates that xwayland is used by the anki app. So for me it works great.

ManIVIctorious commented 3 years ago

I wouldn't be overly surprised if there is a slight misconfiguration of my environment so Anki tires to run in xdg-shell. Does Anki show a window for you when you force the backend to Wayland? (You have to enable access to the Wayland socket first)

What I can confirm is that the system package (which uses an older version btw) runs perfectly fine even without xwayland while I have to force the flatpak version to use the x11 backend (which is done via the environment variable), else there is no window shown.

So maybe I should rephrase the issue to: In contrast to the packaged version (arch Linux) the Anki flatpak does not have Wayland support. When tried to run on the Wayland backend no window is shown. I couldn't find out what causes this lack of xdg-shell support and would highly appreciate if you could have a look into it.

To enhance use experience until this functionality is fixed, it would be helpful to enforce the use of x11 by setting the QT_QPA_PLATFORM=xcb inside the sandbox to prevent from accidentally running into no window issues.

laolux commented 3 years ago

@ManIVIctorious I am sorry, but I am not very familiar with flatpaks. I tried running QT_QPA_PLATFORM=wayland flatpak run net.ankiweb.Anki and similar commands, but that crashes the app with

Qt info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. 
Qt critical: Failed to create wl_display (No such file or directory) 
Qt info: Could not load the Qt platform plugin "wayland" in "" even though it was found. 
Qt fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

And additionally I get some selinux errors. So, in conclusion I would think the Anki flatpak does not like wayland. However, it automatically runs via xwayland on my system.

P.S.: Just tried the ancient packaged Anki version of Fedora. That one uses wayland by default, without any issues.

rmader commented 3 years ago

Should be fixed by https://github.com/flathub/net.ankiweb.Anki/pull/46 Meh, not really.

WasabiPizza commented 2 years ago

Hi, with Anki 2.1.48 Wayland support can be enabled passing —env=ANKI_WAYLAND=1. Don’t forget to give permission to access the Wayland socket.

laolux commented 2 years ago

@WasabiPizza thanks for the hint, it does work, but I need to set two environment variables: ANKI_WAYLAND=1 and QT_QPA_PLATFORM=wayland, in addition to allowing the wayland socket.

ManIVIctorious commented 2 years ago

Thanks, ANKI_WAYLAND=1 did the trick for me

rayes0 commented 3 months ago

Closing as solved