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

Wayland issues #1767

Open
2 of 4 tasks
dae opened this issue Apr 3, 2022 · 46 comments
Open
2 of 4 tasks

Wayland issues #1767

dae opened this issue Apr 3, 2022 · 46 comments
Labels
qt Bug in the Qt5/Qt6 toolkit Anki uses

Comments

@dae
Copy link
Member

dae commented Apr 3, 2022

  • Qt 6.2.2, probably Qt5 too: editor sometimes pastes as text, sometimes pastes as html (mimeData.hasHtml() is returning intermittently false). Does not occur for me when using xwayland + QT_QPA_PLATFORM=xcb. Maybe related to https://bugreports.qt.io/browse/QTBUG-74330 (fixed in 6.3)
  • Qt 5/6.2.2/6.3: client side decorations are not supported, so when used on Gnome/Mutter, there are no borders/titlebars
  • Qt 5/6.2.2: window.raise() is not supported, so clicking on 'add' to bring an existing add window to the top does not work (fixed in 6.3 for Sway, but not Gnome)
  • Qt 5/6.2.2/6.3: fullscreen mode renders Anki transparent (confirmed on 2.1.51 RC2, Manjaro Gnome; doesn't happen with Sway)
    https://forums.ankiweb.net/t/blury-interface-with-gnome-wayland-and-fractional-scaling/19196/3?u=kleinerpirat

Anki will link users to this page when they run Anki on a Wayland system.

@dae dae added the qt Bug in the Qt5/Qt6 toolkit Anki uses label Apr 3, 2022
@kleinerpirat
Copy link
Contributor

Qt 5/6.2.2: fullscreen mode renders Anki transparent (confirmed on 2.1.51 RC2, Manjaro Gnome)
https://forums.ankiweb.net/t/blury-interface-with-gnome-wayland-and-fractional-scaling/19196/3?u=kleinerpirat

@kleinerpirat
Copy link
Contributor

Re 0b03919: on Qt 6.3 the warning about window.raise() doesn't pop up in the console anymore, but pressing A to bring up an existing add window still doesn't work on my end.

The transparency issue for Gnome on fullscreen still occurs on 6.3.

@dae
Copy link
Member Author

dae commented Apr 21, 2022

Thanks for testing. It changes focus for me when testing with Sway, so I suspect Mutter hasn't implemented the extension yet - if you have access to KDE to test with, maybe that would fare better?

@kleinerpirat
Copy link
Contributor

Sadly I don't have immediate access to KDE anymore, because I switched back to Gnome recently (smoother UX)...
Perhaps someone on the forum can help us out :)

@Koorosh-J
Copy link

Qt 5/6.2.2/6.3: client side decorations are not supported, so when used on Gnome/Mutter, there are no borders/titlebars

Also the sub-windows opens in top left corner instead of Center (like add tags to multiple cards, custom study, ...)
As in this link mentioned if we start Anki with ( $ WAYLAND_DISPLAY="" anki ) it will be fixed.

https://www.reddit.com/r/Anki/comments/tzpouv/anki_250_window_frame_on_linux/

@senorsmile
Copy link

I'm on nixos using sway. I just tried going from current stable (21.11) which points to anki 2.1.49 to unstable which currently points to 2.1.51. The former seems to open fine, but the latter has mostly windows that are blank for me. This renders the new version of Anki completely unusable for me. I have an old Manjaro laptop which also has sway on it. I updated and tried to open Anki and get the exact same thing.

When starting from a shell I get:

Qt warning: QApplication: invalid style override 'adwaita' passed, ignoring it.
	Available styles: Windows, Fusion 
mpv not found, reverting to mplayer
Qt warning: Wayland does not support QWindow::requestActivate() 

Let me know if I should open an entirely new issue or not.

@senorsmile
Copy link

I just confirmed that whatever changes were made in the 2.1.52 release from today makes it display things again for me in sway: senorsmile/nixpkgs@7b33d2c.

@penn5
Copy link

penn5 commented May 24, 2022

Anki 2.1.52 appears to have a regression since 2.1.50 on Flatpak (Fedora 35):

[penn@Ferao ~]$ flatpak run net.ankiweb.Anki --version
Anki starting...
Initial setup...
Preparing to run...
Anki 2.1.52
[penn@Ferao ~]$ flatpak run net.ankiweb.Anki
Anki starting...
Initial setup...
Preparing to run...
Wayland support is disabled by default due to bugs:
https://github.com/ankitects/anki/issues/1767
You can force it on with an env var: ANKI_WAYLAND=1
Qt info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. 
Qt warning: could not connect to display  
Qt info: Could not load the Qt platform plugin "xcb" 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.
 
[penn@Ferao ~]$ ANKI_WAYLAND=1 flatpak run net.ankiweb.Anki
Anki starting...
Initial setup...
Preparing to run...
Qt info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. 
Qt warning: could not connect to display  
Qt info: Could not load the Qt platform plugin "xcb" 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.
 
[penn@Ferao ~]$ QT_QPA_PLATFORM=wayland ANKI_WAYLAND=1 flatpak run net.ankiweb.Anki
Anki starting...
Initial setup...
Preparing to run...
Qt info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. 
Starting main loop...
Qt warning: Wayland does not support QWindow::requestActivate() 

The application runs, but without scaling (this is expected according to this issue).
Debug info from 2.1.52

Anki 2.1.52 (ab1c2395) Python 3.9.10 Qt 5.15.2 PyQt 5.15.5
Platform: Linux
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2022-05-24 08:55:14


===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Remove card history ['2089200096', 2018-04-23T07:50, 'None', '']

===IDs of active AnkiWeb add-ons===
2089200096

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

I tried downgrading Anki to 2.1.50:

[penn@Ferao ~]$ flatpak run net.ankiweb.Anki --version
Anki starting...
Initial setup...
Preparing to run...
Anki 2.1.50
[penn@Ferao ~]$ flatpak run net.ankiweb.Anki
Anki starting...
Initial setup...
Preparing to run...
Qt info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. 
Starting main loop...

The debug info from the working 2.1.50:

Anki 2.1.50 (26d40c3a) Python 3.9.10 Qt 5.15.2 PyQt 5.15.5
Platform: Linux
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2022-05-24 08:52:22


===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Remove card history ['2089200096', 2018-04-23T07:50, 'None', '']

===IDs of active AnkiWeb add-ons===
2089200096

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

On 2.1.50, the application displays perfectly without these bugs. I suspect a bug in the code that blocks Wayland support, as it is apparently not used on my system anyway.
For now, I'm going to lock the version to 2.1.50, since it worked perfectly.

@dae
Copy link
Member Author

dae commented May 26, 2022

That appears to be an issue with the Flatpak, not Anki.

@hendursaga
Copy link

That appears to be an issue with the Flatpak

At any rate, with Ubuntu Jammy, under Sway, I can see borders and title bars perfectly fine, with ANKI_WAYLAND set to 1, as well as go fullscreen without any transparency.

@udoprog
Copy link

udoprog commented Feb 26, 2023

I'm using Anki on Fedora 38 (currently Beta) and Gnome through flatpak.

Anki Version ⁨2.1.60 (76d8807)⁩
Python 3.9.15 Qt 6.4.2 PyQt 6.4.0

Gnome details:
image

Anki runs fine with basic non-gnome window decorations using:

flatpak run --env=DISABLE_QT5_COMPAT=1 --env=ANKI_WAYLAND=1 --branch=stable --arch=x86_64 --command=anki --file-forwarding net.ankiweb.Anki

image

I'm not sure what's providing the window decorations, maybe it's some QT fallback.

@d-k-bo
Copy link

d-k-bo commented May 4, 2023

Starting with version 2.1.62 which updated to Qt 6.5, support for fractional scaling got worse on my machine. Everything that is rendered inside a webview looks fuzzy while the menu bar and the client side decorations look fine (except of a thin transparent line). Additionally, many views are shown too small, but get back to the right size after resizing the window.

I suspect this is because Qt 6.5 introduced support for fractional_scale_v1 and I'm using GNOME 44 which also supports this new protocol. I couldn't find any information whether Qt WebEngine supports fractional_scale_v1 at all, there is only this section about HiDPI support in general.


Screenshots

Bildschirmfoto vom 2023-05-04 17-51-13
Bildschirmfoto vom 2023-05-04 18-18-26


OS: Fedora 38
DE: GNOME 44.1 on Wayland with scale set to 125 %
Anki 2.1.62 (77dd1dc) Python 3.9.15 Qt 6.5.0 PyQt 6.5.0
installed via Flatpak, disabled X11 via Flatseal


Upstream bug report: https://bugreports.qt.io/browse/QTBUG-113574

@dae
Copy link
Member Author

dae commented May 8, 2023

I'm afraid I don't have GNOME on my system. Please reproduce this outside of Anki, then report the issue to the Qt developers.

You can run the sample app below with the following commands:

% python3 -m venv venv
% ./venv/bin/pip install pyqt6 pyqt6-webengine
% ./venv/bin/python test.py
import sys
from PyQt6.QtCore import QUrl
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWebEngineWidgets import QWebEngineView

class HelloWorldWebView(QWebEngineView):
    def __init__(self):
        super().__init__()

        html = '''
            <!DOCTYPE html>
            <html>
            <head>
                <meta charset="utf-8">
                <title>Hello World</title>
            </head>
            <body>
                <h1>Hello World</h1>
            </body>
            </html>
        '''

        self.setHtml(html)
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    web_view = HelloWorldWebView()
    sys.exit(app.exec())

You can report the bug on https://bugreports.qt.io/. It would be great if you could provide a link to it here.

@d-k-bo
Copy link

d-k-bo commented May 12, 2023

I was able to reproduce the problem using a similar test script on both GNOME and KDE, so I created a bug report upstream at https://bugreports.qt.io/browse/QTBUG-113574. Thank you for the advice!

@dae
Copy link
Member Author

dae commented May 15, 2023

Thanks for that. Someone's posted a workaround on that issue which can be used for now, and the next Anki update should apply it automatically on startup.

@ajvn
Copy link

ajvn commented May 22, 2023

Hello, using Flatpak version of Anki, 2.1.63 under Sway.
Import/export functionality doesn't work, in a sense that after clicking on Import nothing happens, where clicking Export shows Export format/Include popup, but clicking on Export button doesn't do anything, file explorer doesn't show.
Same Flatpak version under X server (i3) behaves properly.

Please let me know if any other details are needed, or if this was already reproduced in some other issue, I didn't manage to find any.

@dae
Copy link
Member Author

dae commented May 22, 2023

Exporting works fine for me with Sway+Wayland. If this issue is specific to the Flatpak, please report it to the Flatpak author.

@ajvn
Copy link

ajvn commented May 23, 2023

Seems like that's the case indeed, tested it with installation from the website, that one functions properly.

Thanks for checking.

@nihil-admirari
Copy link
Contributor

nihil-admirari commented May 25, 2023

Someone's posted a workaround on that issue which can be used for now, and the next Anki update should apply it automatically on startup.

The workaround broke rendering for non-Wayland users.

On Kubuntu with 150% scaling, after an upgrade to Anki 2.1.64, menus started looking like this (other parts of the interface got enlarged too):
workaround

Commenting out

if is_lin and qtmajor > 5:
    os.environ["QT_SCALE_FACTOR_ROUNDING_POLICY"] = "RoundPreferFloor"

restores the normal look:
no_workaround

Is there a way to limit the workaround only to Wayland?

@dae
Copy link
Member Author

dae commented May 29, 2023

Sigh, that's unfortunate. I'll limit the env change to the Wayland path in the next update to resolve this.

@LSeelig
Copy link

LSeelig commented Nov 17, 2023

I tried the official package, and it cannot find the wayland qt window decorations provided by my distro (fedora 39), nor my themes (only Windows and Fusion):

./anki
Anki starting...
Initial setup...
Preparing to run...
Qt warning: QApplication: invalid style override 'kvantum' passed, ignoring it.
	Available styles: Windows, Fusion 
Qt debug: doh set to ""  --  SystemOnly 
Starting main loop...
mpv not found, reverting to mplayer
Qt warning: Requested decoration  "adwaita"  not found, falling back to default 

@dae
Copy link
Member Author

dae commented Nov 20, 2023

The official package bundles its own version of Qt, so it won't be able to use your system Qt plugins. For that, you'd need to use your system Python and run Anki from the PyPi wheels instead.

@LSeelig
Copy link

LSeelig commented Nov 20, 2023

The official package bundles its own version of Qt, so it won't be able to use your system Qt plugins. For that, you'd need to use your system Python and run Anki from the PyPi wheels instead.

Could support for window decorations be implemented in anki's official package?

@dae
Copy link
Member Author

dae commented Nov 21, 2023

Sorry, this is not an area I'm familiar with. I don't know whether it would require a patched Qt (not practical), or whether it could be done with a style plugin (and whether such a plugin would work across distros or not).

@LSeelig
Copy link

LSeelig commented Nov 22, 2023

Ok. Thank you.

@expipiplus1
Copy link

I'm still bumping into this with 2.1.66, however setting QT_SCALE_FACTOR_ROUNDING_POLICY=RoundPreferFloor as suggested in the QT report seems to fix things

@Consonata
Copy link

Apologies for reviving this thread but I appear to be having similar issues with Wayland.

Anki 23.12 (97f43fb) (src)
Python 3.11.2 Qt 5.15.8 PyQt 5.15.9
Platform: Linux-6.1.0-rpi7-rpi-2712-aarch64-with-glibc2.36

image
with the:

Qt warning: Wayland does not support QWindow::requestActivate()

Not quite sure if this is a RPi issue or a Qt one.

@HubKing
Copy link

HubKing commented Dec 18, 2023

I have the same problem as d-k-bo above. Arch/Gnome 45.2/Wayland/Fractional Scaling (125%). I had installed this AUR package https://aur.archlinux.org/packages/anki-bin .

This makes the app unusable for me.

Screenshot from 2023-12-18 00-47-36

@1over137
Copy link
Contributor

1over137 commented Jan 8, 2024

The workaround QT_SCALE_FACTOR_ROUNDING_POLICY=RoundPreferFloor did not work for me on 23.12.1- the image quality of the webview remains degraded, but not the Qt interface. I simply reverted to using qt5, which doesn't have true fractional scaling but looks better.

@Pierre-Colin
Copy link

Hi.

On my machine, Anki crashes at random when closing a window. It does not occur without Wayland, and this issue doesn’t list it.

Observed this on both a build from the instructions to build Anki from source and the Linux Qt6 release with ANKI_WAYLAND=1.

My machine runs Arch Linux. I updated the system and restarted my compositor today. This is how I built and ran the Git version.

$ git clone --depth=1 https://github.com/ankitects/anki.git
$ cd anki
$ ./run

App starts. Click "Stats" button and close the window over and over again. Each time, Wayland prints warnings related to the event queue. After a few times, it crashes. Below is the terminal output with all the HTTP logs stripped.

Preparing to run...
Serving on http://127.0.0.1:40000

DevTools listening on ws://127.0.0.1:8080/devtools/browser/c851ef13-2a95-474b-a25b-9d25460e3775
Qt debug: doh set to ""  --  SystemOnly 
Starting main loop...
Qt warning: Remote debugging server started successfully. Try pointing a Chromium-based browser to http://127.0.0.1:8080 
blocked main thread for 536ms:
  File "/home/user/code/anki/tools/run.py", line 14, in <module>
    aqt.run()
  File "/home/user/code/anki/qt/aqt/__init__.py", line 509, in run
    _run()
  File "/home/user/code/anki/qt/aqt/__init__.py", line 717, in _run
    app.exec()
  File "/home/user/code/anki/qt/aqt/progress.py", line 118, in handler
    func()
  File "/home/user/code/anki/qt/aqt/main.py", line 218, in on_window_init
    fn()
  File "/home/user/code/anki/qt/aqt/main.py", line 317, in setupProfile
    self.loadProfile()
  File "/home/user/code/anki/qt/aqt/main.py", line 474, in loadProfile
    if not self.loadCollection():
  File "/home/user/code/anki/qt/aqt/main.py", line 610, in loadCollection
    self._loadCollection()
  File "/home/user/code/anki/qt/aqt/main.py", line 646, in _loadCollection
    self.col = Collection(cpath, backend=self.backend)
  File "/home/user/code/anki/pylib/anki/collection.py", line 150, in __init__
    self.reopen()
  File "/home/user/code/anki/pylib/anki/collection.py", line 291, in reopen
    self._backend.open_collection(
  File "/home/user/code/anki/out/pylib/anki/_backend_generated.py", line 133, in open_collection
    raw_bytes = self._run_command(3, 0, message.SerializeToString())
  File "/home/user/code/anki/pylib/anki/_backend.py", line 162, in _run_command
    print("".join(traceback.format_stack()))

Traceback (most recent call last):
  File "/home/user/code/anki/qt/aqt/sound.py", line 854, in setup_audio
    mpvManager = MpvManager(base_folder, media_folder)
  File "/home/user/code/anki/qt/aqt/sound.py", line 408, in __init__
    super().__init__(window_id=None, debug=False)
  File "/home/user/code/anki/qt/aqt/mpv.py", line 441, in __init__
    super().__init__(*args, **kwargs)
  File "/home/user/code/anki/qt/aqt/mpv.py", line 103, in __init__
    self._start_socket()
  File "/home/user/code/anki/qt/aqt/mpv.py", line 193, in _start_socket
    raise MPVProcessError("unable to start process")
aqt.mpv.MPVProcessError: unable to start process

mpv too old or failed to open, reverting to mplayer
warning: queue 0x25d0bb0 destroyed while proxies still attached:
  wl_callback@75 still attached
  wl_buffer@80 still attached
  wl_buffer@78 still attached
  wl_buffer@76 still attached
  wl_buffer@73 still attached
warning: queue 0x2524410 destroyed while proxies still attached:
  wl_callback@91 still attached
  wl_buffer@90 still attached
  wl_buffer@88 still attached
  wl_buffer@86 still attached
  wl_buffer@83 still attached
warning: queue 0x2551860 destroyed while proxies still attached:
  wl_callback@97 still attached
  wl_buffer@98 still attached
  wl_buffer@96 still attached
  wl_buffer@94 still attached
  wl_buffer@85 still attached
Tried to add event to destroyed queue
./run: line 19: 244442 Aborted                 (core dumped) ./out/pyenv/bin/python tools/run.py $*

Running coredumpctl debug reveals the following stack trace. Not sure this will help though since Qt symbols are missing and there’s no Python stack frames.

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f22d3dbf8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f22d3d6f668 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f22d3d574b8 in __GI_abort () at abort.c:79
#4  0x00007f22c9e754f2 in wl_abort (fmt=fmt@entry=0x7f22c9e7a6d8 "Tried to add event to destroyed queue\n") at ../wayland-1.22.0/src/wayland-util.c:462
#5  0x00007f22c9e777e2 in queue_event (len=<optimized out>, display=0xde9830) at ../wayland-1.22.0/src/wayland-client.c:1575
#6  read_events (display=0xde9830) at ../wayland-1.22.0/src/wayland-client.c:1670
#7  wl_display_read_events (display=0xde9830) at ../wayland-1.22.0/src/wayland-client.c:1753
#8  0x00007f22bd2dfe6c in  () at /home/user/code/anki/out/pyenv/lib/python3.9/site-packages/PyQt6/Qt6/plugins/platforms/../../lib/libQt6WaylandClient.so.6
#9  0x00007f22ceef29dd in  () at /home/user/code/anki/out/pyenv/lib/python3.9/site-packages/PyQt6/Qt6/lib/libQt6Core.so.6
#10 0x00007f22d3dbd9eb in start_thread (arg=<optimized out>) at pthread_create.c:444
#11 0x00007f22d3e417cc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

On the release, the Python warnings and stack traces, the HTTP logs and the mpv warning don’t print. But the part about Wayland event queues do, and the same crash occurs.

On a side note, is there any reason why Git builds enable Wayland by default while releases don’t?

Of course, let me know if this needs its own issue.

@dae
Copy link
Member Author

dae commented Jan 19, 2024

This is handled by Qt, so not something we can fix directly. It doesn't seem to happen on my system (using Sway as a WM).

On a side note, is there any reason why Git builds enable Wayland by default while releases don’t?

Developers are more likely to see the console output, and being using Wayland.

@LSeelig
Copy link

LSeelig commented Feb 20, 2024

The official package bundles its own version of Qt, so it won't be able to use your system Qt plugins. For that, you'd need to use your system Python and run Anki from the PyPi wheels instead.

Is there any reference on how to do this?

@dae
Copy link
Member Author

dae commented Feb 21, 2024

@LSeelig
Copy link

LSeelig commented Feb 21, 2024

https://betas.ankiweb.net/#via-pypipip

I saw, but I couldn't get a binary executable without aqt.

@NameLessGO
Copy link

NameLessGO commented Feb 26, 2024

Chromebook specific issue:

Qt warning: The wayland connection broke. did the wayland compositor die?

Affects Flatpak build: flathub/net.ankiweb.Anki#135

Reported on forums: https://forums.ankiweb.net/t/cant-download-anki-on-terminal-linux/41563/18

Chromebook Wayland protocol: Sommelier
https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/vm_tools/sommelier/

Alternative: Making an Anki package in https://github.com/chromebrew/chromebrew and document for CB users

@1over137
Copy link
Contributor

@NameLessGO I'm not sure that's a Chromebook issue. I develop another PyQt5 app (https://github.com/FreeLanguageTools/vocabsieve) and I've seen this sometimes on Wayland on Linux. I think this usually happens when there is a blocking operation.

@LSeelig
Copy link

LSeelig commented Mar 6, 2024

The window decorations and theming issues seem to span other pyqt5 and pyqt6 apps as well. I checked the library files in pyenv and found the system installed themes are just not installed. Adding the .so file for the libadwaita qt decorations to the folder in py-qt with the libbradient (default qt) decorations caused the app to launch without decorations.

The bottom line is, I think this is upstream, but it could be fixed or at least mitigated in aqt by adding in the window decorations that align with gnome, plasma and other common DE's default themes.

@1over137
Copy link
Contributor

1over137 commented Mar 6, 2024

Window decoration is ugly in GNOME because GNOME refuses to do server-side decoration on Wayland so it falls back to the default one from Qt6. The Qt5 version doesn't show this because Qt5 defaults to run under X11 on GNOME. On environments that support SSD (KDE plasma, etc) this all works as expected. A fix from Anki would probably be a basic GNOME-themed CSD, which should not be shown on environments that can do SSD so it doesn't look bad on Plasma/Sway/Hyprland.

@LSeelig
Copy link

LSeelig commented Mar 6, 2024

Window decoration is ugly in GNOME because GNOME refuses to do server-side decoration on Wayland so it falls back to the default one from Qt6. The Qt5 version doesn't show this because Qt5 defaults to run under X11 on GNOME. On environments that support SSD (KDE plasma, etc) this all works as expected. A fix from Anki would probably be a basic GNOME-themed CSD, which should not be shown on environments that can do SSD so it doesn't look bad on Plasma/Sway/Hyprland.

This occurs regardless of qt5 or qt6. The libbradient decorations appear on wayland and cannot be replaced. If I manually add libadwaita decorations to the library folder for pyqt5 or qt6 from my system's qt5 and qt6 libraries, it causes the decorations to disappear completely.

The basic CSD is exactly what I'd recommend, specifically QAdwaitaDecorations and QGnomePlatform. If the libraries are built correctly, they should apply just like libbradient seeing as the env variable is set by default on some distros or can be set by users and is read by anki. However, I understand if anki doesn't try this, as this is really a PyQT issue.

Do you know if PyQT is typically able to use user themes? Both themes and wayland decorations function as QT plugins, so I assume it's the same system.

@1over137
Copy link
Contributor

1over137 commented Mar 6, 2024

By default Qt5 wouldn't use Wayland on GNOME, unless you have QT_QPA_PLATFORM=wayland. With a qt6 distro package it still uses the default (non interactive, thin) window titlebar and no shadow. The current theming tools like qt6ct seems to not have no direct way of handling this.

PyQt or PySide is no different from Qt and can use system themes if it is linked to your system Qt library (distro packages of Anki or pip), but not if statically linked (such as official Anki builds). I have a PyQt5 application (https://github.com/FreeLanguageTools/vocabsieve), and it is able to use Qt themes when installed normally systemwide, but not in an appimage or virtualenv.

Honestly GNOME is the one who should be fixing this by adding SSD or someone should make a patch for it. Having builtin CSD is going to look non-native most of the times and will stand out on a GNOME system. Libadwaita actually have themable colors and if Anki assumes the default scheme, it will look out of place again. It can't be that difficult to do since it works on Xwayland windows just fine.

@neofight78
Copy link

On Ubuntu 22.04, a manual install appears to work ok with the environment variable set but crashes on syncing. However, the flatpack version seems to work fine.

@LSeelig
Copy link

LSeelig commented Apr 2, 2024

I still can't fix my issues with the official download or pywheels, but I partially fixed it with the unofficial flatpak. If I use --runtime=org.kde.Platform/x86_64/6.6, wayland window decorations work. However, this does not fix the cursor issue (which affects non-python qt apps) and the theme. In fact, it's even weirder. Now, the warning reads:

Qt warning: QApplication: invalid style override 'kvantum' passed, ignoring it.
	Available styles: HighContrastInverse, HighContrast, Adwaita-HighContrastInverse, Adwaita-HighContrast, Adwaita-Dark, Adwaita, kvantum-dark, kvantum, Windows, Fusion 

This is weird because only Windows and Fusion still work; the others are now shown as available but are warned as an invalid override. I can't find anything online where the top error occurred but the invalid style was in the available styles.

@xlash123
Copy link

I was able to get Anki to crash when trying to login to sync. I was about to post a new issue, but saw this one. After switching to using XWayland, it did not crash. Here's the crash log I had:

Preparing to run...
Qt warning: QGuiApplication::setDesktopFileName: the specified desktop file name ends with .desktop. For compatibility reasons, the .desktop suffix will be removed. Please specify a desktop file name without .desktop suffix 
2024-04-18 21:02:49,269:INFO:aqt.mediasrv: Serving on http://127.0.0.1:33057
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
2024-04-19T01:02:49.796082Z DEBUG resolving host="ankiweb.net"
2024-04-19T01:02:49.812706Z DEBUG connecting to 162.55.238.74:443
2024-04-19T01:02:50.033501Z DEBUG connected to 162.55.238.74:443
2024-04-19T01:02:50.444495Z DEBUG flushed 148 bytes
2024-04-19T01:02:50.647700Z DEBUG parsed 8 headers
2024-04-19T01:02:50.647751Z DEBUG incoming body is content-length (6 bytes)
2024-04-19T01:02:50.647774Z DEBUG incoming body completed
2024-04-19T01:02:50.647910Z DEBUG pooling idle connection for ("https", ankiweb.net)
2024-04-19T01:03:00.583032Z DEBUG resolving host="sync.ankiweb.net"
2024-04-19T01:03:00.628811Z DEBUG connecting to 162.55.238.74:443
2024-04-19T01:03:00.785480Z DEBUG connected to 162.55.238.74:443
2024-04-19T01:03:01.198044Z DEBUG flushed 281 bytes
2024-04-19T01:03:01.604988Z DEBUG parsed 8 headers
2024-04-19T01:03:01.605109Z DEBUG incoming body is chunked encoding
2024-04-19T01:03:01.605183Z DEBUG incoming chunked header: 0x23 (35 bytes)
2024-04-19T01:03:01.605741Z DEBUG incoming body completed
2024-04-19T01:03:01.605882Z DEBUG pooling idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.610462Z DEBUG fetching meta...
2024-04-19T01:03:01.610865Z DEBUG reuse idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.612179Z DEBUG flushed 298 bytes
2024-04-19T01:03:01.809808Z DEBUG parsed 8 headers
2024-04-19T01:03:01.809861Z DEBUG incoming body is empty
2024-04-19T01:03:01.809996Z DEBUG pooling idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.810065Z DEBUG redirect to new location endpoint="https://sync19.ankiweb.net/"
2024-04-19T01:03:01.810316Z DEBUG resolving host="sync19.ankiweb.net"
2024-04-19T01:03:01.853725Z DEBUG connecting to 88.198.59.10:443
2024-04-19T01:03:02.015847Z DEBUG connected to 88.198.59.10:443
2024-04-19T01:03:02.424687Z DEBUG flushed 300 bytes
2024-04-19T01:03:02.628724Z DEBUG parsed 8 headers
2024-04-19T01:03:02.628781Z DEBUG incoming body is chunked encoding
2024-04-19T01:03:02.628802Z DEBUG incoming chunked header: 0x68 (104 bytes)
2024-04-19T01:03:02.628979Z DEBUG incoming body completed
2024-04-19T01:03:02.629050Z DEBUG pooling idle connection for ("https", sync19.ankiweb.net)
2024-04-19T01:03:02.629064Z DEBUG meta remote=SyncMeta { modified: TimestampMillis(0), schema: TimestampMillis(1713315149680), usn: Usn(0), current_time: TimestampSecs(1713488582), server_message: "", should_continue: true, host_number: 19, empty: true, media_usn: Usn(0), v2_scheduler_or_later: false, v2_timezone: false }
2024-04-19T01:03:02.629131Z DEBUG meta local=SyncMeta { modified: TimestampMillis(1713487203869), schema: TimestampMillis(1713234135580), usn: Usn(0), current_time: TimestampSecs(1713488581), server_message: "", should_continue: true, host_number: 0, empty: false, media_usn: Usn(0), v2_scheduler_or_later: true, v2_timezone: true }
2024-04-19T01:03:02.629140Z DEBUG fetched state=ClientSyncState { required: FullSyncRequired { upload_ok: true, download_ok: false }, server_message: "", host_number: 19, new_endpoint: Some("https://sync19.ankiweb.net/"), local_is_newer: true, usn_at_last_sync: Usn(0), server_usn: Usn(0), pending_usn: Usn(-1), server_media_usn: Usn(0) }
munmap_chunk(): invalid pointer

System: EndeavorOS, Linux 6.8.7-zen
QT: 6.7.0
DE: KDE Plasma 6.0.4
KDE Frameworks: 6.1.0
Wayland: 6.0.4

@fuattatar
Copy link

This issue still valid.
System: Ubuntu 24.04

@voczi
Copy link
Contributor

voczi commented Aug 5, 2024

Gnome 43, local build of Anki: Everything works fine, except for smaller things like decorations as already mentioned. Then there's also some UI lag here and there, not sure what to make of it but I do honestly find Anki usable in this state.

@pSchwietzer
Copy link

I was able to get Anki to crash when trying to login to sync. I was about to post a new issue, but saw this one. After switching to using XWayland, it did not crash. Here's the crash log I had:

Preparing to run...
Qt warning: QGuiApplication::setDesktopFileName: the specified desktop file name ends with .desktop. For compatibility reasons, the .desktop suffix will be removed. Please specify a desktop file name without .desktop suffix 
2024-04-18 21:02:49,269:INFO:aqt.mediasrv: Serving on http://127.0.0.1:33057
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
2024-04-19T01:02:49.796082Z DEBUG resolving host="ankiweb.net"
2024-04-19T01:02:49.812706Z DEBUG connecting to 162.55.238.74:443
2024-04-19T01:02:50.033501Z DEBUG connected to 162.55.238.74:443
2024-04-19T01:02:50.444495Z DEBUG flushed 148 bytes
2024-04-19T01:02:50.647700Z DEBUG parsed 8 headers
2024-04-19T01:02:50.647751Z DEBUG incoming body is content-length (6 bytes)
2024-04-19T01:02:50.647774Z DEBUG incoming body completed
2024-04-19T01:02:50.647910Z DEBUG pooling idle connection for ("https", ankiweb.net)
2024-04-19T01:03:00.583032Z DEBUG resolving host="sync.ankiweb.net"
2024-04-19T01:03:00.628811Z DEBUG connecting to 162.55.238.74:443
2024-04-19T01:03:00.785480Z DEBUG connected to 162.55.238.74:443
2024-04-19T01:03:01.198044Z DEBUG flushed 281 bytes
2024-04-19T01:03:01.604988Z DEBUG parsed 8 headers
2024-04-19T01:03:01.605109Z DEBUG incoming body is chunked encoding
2024-04-19T01:03:01.605183Z DEBUG incoming chunked header: 0x23 (35 bytes)
2024-04-19T01:03:01.605741Z DEBUG incoming body completed
2024-04-19T01:03:01.605882Z DEBUG pooling idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.610462Z DEBUG fetching meta...
2024-04-19T01:03:01.610865Z DEBUG reuse idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.612179Z DEBUG flushed 298 bytes
2024-04-19T01:03:01.809808Z DEBUG parsed 8 headers
2024-04-19T01:03:01.809861Z DEBUG incoming body is empty
2024-04-19T01:03:01.809996Z DEBUG pooling idle connection for ("https", sync.ankiweb.net)
2024-04-19T01:03:01.810065Z DEBUG redirect to new location endpoint="https://sync19.ankiweb.net/"
2024-04-19T01:03:01.810316Z DEBUG resolving host="sync19.ankiweb.net"
2024-04-19T01:03:01.853725Z DEBUG connecting to 88.198.59.10:443
2024-04-19T01:03:02.015847Z DEBUG connected to 88.198.59.10:443
2024-04-19T01:03:02.424687Z DEBUG flushed 300 bytes
2024-04-19T01:03:02.628724Z DEBUG parsed 8 headers
2024-04-19T01:03:02.628781Z DEBUG incoming body is chunked encoding
2024-04-19T01:03:02.628802Z DEBUG incoming chunked header: 0x68 (104 bytes)
2024-04-19T01:03:02.628979Z DEBUG incoming body completed
2024-04-19T01:03:02.629050Z DEBUG pooling idle connection for ("https", sync19.ankiweb.net)
2024-04-19T01:03:02.629064Z DEBUG meta remote=SyncMeta { modified: TimestampMillis(0), schema: TimestampMillis(1713315149680), usn: Usn(0), current_time: TimestampSecs(1713488582), server_message: "", should_continue: true, host_number: 19, empty: true, media_usn: Usn(0), v2_scheduler_or_later: false, v2_timezone: false }
2024-04-19T01:03:02.629131Z DEBUG meta local=SyncMeta { modified: TimestampMillis(1713487203869), schema: TimestampMillis(1713234135580), usn: Usn(0), current_time: TimestampSecs(1713488581), server_message: "", should_continue: true, host_number: 0, empty: false, media_usn: Usn(0), v2_scheduler_or_later: true, v2_timezone: true }
2024-04-19T01:03:02.629140Z DEBUG fetched state=ClientSyncState { required: FullSyncRequired { upload_ok: true, download_ok: false }, server_message: "", host_number: 19, new_endpoint: Some("https://sync19.ankiweb.net/"), local_is_newer: true, usn_at_last_sync: Usn(0), server_usn: Usn(0), pending_usn: Usn(-1), server_media_usn: Usn(0) }
munmap_chunk(): invalid pointer

System: EndeavorOS, Linux 6.8.7-zen QT: 6.7.0 DE: KDE Plasma 6.0.4 KDE Frameworks: 6.1.0 Wayland: 6.0.4

I have the same issue, tried it in Gnome and Hyprland.

System: Nixos 24.05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qt Bug in the Qt5/Qt6 toolkit Anki uses
Projects
None yet
Development

No branches or pull requests