Anki crashes or freezes randomly

I recently changed my WM, and since then Anki crashes quite often.
Sometimes, with this error:

$ anki
Qt warning: QApplication: invalid style override 'adwaite-dark' passed, ignoring it.
	Available styles: Windows, Fusion
mpv not found, reverting to mplayer
  File "runanki.py", line 4, in <module>
  File "aqt/__init__.py", line 437, in run
  File "aqt/__init__.py", line 620, in _run
  File "aqt/main.py", line 130, in __init__
  File "aqt/main.py", line 890, in setupAddons
  File "aqt/addons.py", line 230, in loadAddons
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/__init__.py", line 41, in <module>
    from . import main  # noqa: F401
  File "<frozen importlib._bootstrap>", line 1042, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/main.py", line 40, in <module>
    from .gui.options import initializeOptions
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/gui/options.py", line 48, in <module>
    from ..config import config, heatmap_colors, heatmap_modes
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/config.py", line 43, in <module>
    from .libaddon.anki.configmanager import ConfigManager
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/libaddon/anki/configmanager.py", line 42, in <module>
    from anki.utils import json
  File "anki/utils.py", line 41, in __getattr__
add-on should import json directly, not from anki.utils
  File "runanki.py", line 4, in <module>
  File "aqt/__init__.py", line 437, in run
  File "aqt/__init__.py", line 620, in _run
  File "aqt/main.py", line 130, in __init__
  File "aqt/main.py", line 890, in setupAddons
  File "aqt/addons.py", line 230, in loadAddons
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/__init__.py", line 41, in <module>
    from . import main  # noqa: F401
  File "<frozen importlib._bootstrap>", line 1042, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/main.py", line 41, in <module>
    from .views import initializeViews
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/views.py", line 53, in <module>
    from .heatmap import HeatmapCreator
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/Anki2/addons21/723520343/heatmap.py", line 41, in <module>
    from anki.utils import json
  File "anki/utils.py", line 41, in __getattr__
add-on should import json directly, not from anki.utils
addons21/723520343/activity.py:179:'schedVer' is deprecated: please use 'sched_ver'
conf key heatmap should be fetched with col.get_config(), and saved with col.set_config()
conf key heatmap should be fetched with col.get_config(), and saved with col.set_config()
named arguments in queries will go away in the future:
SELECT
STRFTIME('%s', 'now', 'localtime', 'start of day') + (due - :today) * 86400
AS day, -COUNT() -- negative to support heatmap legend
FROM cards
WHERE did IN (1602082270182,1604945816164,1,1599582215785,1599065358203,1602781802501) AND queue IN (2,3)
 AND day >= 1636070400
GROUP BY day ORDER BY day
addons21/723520343/activity.py:179:'schedVer' is deprecated: please use 'sched_ver'
named arguments in queries will go away in the future:
SELECT
STRFTIME('%s', 'now', 'localtime', 'start of day') + (due - :today) * 86400
AS day, -COUNT() -- negative to support heatmap legend
FROM cards
WHERE did IN (1602781802501,1604945816164,1602082270182,1599065358203,1,1599582215785) AND queue IN (2,3)
 AND day >= 1636070400
GROUP BY day ORDER BY day
Qt warning: Wayland does not support QWindow::requestActivate()
conf key imgocc should be fetched with col.get_config(), and saved with col.set_config()
conf key imgocc should be fetched with col.get_config(), and saved with col.set_config()
addons21/1374772155/config.py:115:'byName' is deprecated: please use 'by_name'
conf key imgocc should be fetched with col.get_config(), and saved with col.set_config()
Qt warning: render glyph failed err=13 face=0x2562170, glyph=32
Qt warning: render glyph failed err=13 face=0x2562170, glyph=32
Qt warning: render glyph failed err=13 face=0x2562170, glyph=32
Qt warning: render glyph failed err=13 face=0x2562170, glyph=32
anki: ../nouveau/pushbuf.c:728: nouveau_pushbuf_data: Assertion `kref' failed.
$

Sometimes, it just hangs forever.

These bugs can start directly on launch, when clicking on a specific button or out of nowhere…

nouveau is known to be buggy, and you may have more luck with software rendering in the preferences screen.

Unfortunately, it is already configured as Software.

Not sure why you’d be getting that message in that case. Maybe installing nvidia’s drivers will help?

My new WM is Sway, which works under Wayland and does not work too well with NVidia proprietary drivers, unfortunately (although NVidia has promised improving compatibility), so for now I cannot use them.

Maybe the qt6 build will fare better? New toolkit and packaging test (round 2)

I am afraid I cannot try. This version of Anki is not packaged in my distribution (NixOS), and the packaging of Anki seems quite complicated (as seems to indicate this issue), and I don’t have enough time nor experience to do it by myself. I could try to copy the package for an other source, but the problem is that the NixOS packagers have stopped (for the time being) building Anki from source, and only provide the latest version through binaries.
Also, I cannot simply download the binary and try to run it because in NixOS, most programs need wrappers to be executed (due to non-standard path to libraries).

This seems a like deep-rooted issue which would require quite some time to be solved (the packaging story), so I guess for now I’ll simply use Anki from other computers, even though eventually someone (maybe me) will have to properly package Anki for Nixos…

The packaged version is mostly self-contained, so it’s worth at least trying it.

Now that I’ve mentioned this issue on an other thread, I remember where we were stuck: at the time, I couldn’t try out the newest Qt6 versions because they were not packaged. Well, now I can and it still hard crashes…