ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
11.34k stars 512 forks source link

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. #960

Open kovasap opened 9 months ago

kovasap commented 9 months ago

Describe the bug

I just updated to https://github.com/ActivityWatch/activitywatch/releases/tag/v0.12.3b10 because of https://github.com/ActivityWatch/aw-watcher-window/issues/89 and now I do not see the aw tray icon when starting up. I think this may be a dupe of https://github.com/ActivityWatch/activitywatch/issues/660, but i do not see the offending library in my install directory.

Logs

2023-10-02 18:41:17 [INFO ]: Started aw-qt...  (aw_qt.main:53)
2023-10-02 18:41:17 [WARNING]: Found matching file but was not executable: /home/kovas/activitywatch/aw-qt.desktop  (aw_qt.manager:64)
2023-10-02 18:41:17 [WARNING]: Found matching file but was not executable: /home/kovas/activitywatch/aw-server-rust/aw-server.service  (aw_qt.manager:64)
2023-10-02 18:41:17 [INFO ]: Found 6 bundled modules  (aw_qt.manager:85)
2023-10-02 18:41:17 [INFO ]: Found 0 system modules  (aw_qt.manager:119)
2023-10-02 18:41:17 [INFO ]: Starting module aw-server  (aw_qt.manager:148)
2023-10-02 18:41:17 [INFO ]: Starting module aw-watcher-window  (aw_qt.manager:148)
2023-10-02 18:41:17 [INFO ]: Starting module aw-watcher-afk  (aw_qt.manager:148)
2023-10-02 18:41:17 [INFO ]: Creating trayicon...  (aw_qt.trayicon:206)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

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

2023-10-02 18:41:17 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
2023-10-02 18:41:17 [INFO ]: aw-watcher-afk started  (aw_watcher_afk.afk:60)
2023-10-02 18:41:17 [INFO ]: Using storage method: peewee  (aw_server.main:33)
2023-10-02 18:41:17 [INFO ]: Starting up...  (aw_server.main:41)
2023-10-02 18:41:17 [INFO ]: Using database file: /home/kovas/.local/share/activitywatch/aw-server/peewee-sqlite.v2.db  (aw_datastore.storages.peewee:150)
 * Serving Flask app 'aw-server'
 * Debug mode: off
2023-10-02 18:41:17 [INFO ]: WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://localhost:5600  (werkzeug:187)
2023-10-02 18:41:17 [INFO ]: Press CTRL+C to quit  (werkzeug:187)
2023-10-02 18:41:18 [INFO ]: window-watcher stopped because parent process died  (aw_watcher_window.main:101)
2023-10-02 18:41:18 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:436)
2023-10-02 18:41:18 [INFO ]: afkwatcher stopped because parent process died  (aw_watcher_afk.afk:80)
2023-10-02 18:41:18 [INFO ]: Connection to aw-server established by aw-watcher-afk  (aw_client.client:436)
2023-10-02 18:41:24 [INFO ]: 404 (127.0.0.1): GET /js/index.5320cfa8.js HTTP/1.1  (flask:25)
kovasap commented 7 months ago

I don't see this issue with a clean install of https://github.com/ActivityWatch/activitywatch/releases/tag/v0.12.2.

jackdbd commented 6 months ago

I had the same issue with an ActivityWatch pre-release (it was a v0.12.3b, but I'm not sure if it was exactly the v0.12.3b10 release) on Xubuntu 23.04. I'm also experiencing this issue on NixOS 23.11, which uses ActivityWatch version 0.12.2.

The whole thing originates from aw-qt that tries to create a tray icon using the Qt libraries (PyQt6, as you can see in trayicon.py).

I am not very familiar with the Qt ecosystem, but as far as I understand Qt has a plugin system that allows you to load plugins either at runtime or at build time. I guess most application developers opt for creating a dynamically linked executable, so their application can load Qt plugins at runtime.

I'm not sure about this - because I'm not familiar with Qt - but it seems that Qt search for runtime plugins in QT_PLUGIN_PATH (see also this).

It seems that aw-qt is not the only application with this issue.

I wouldn't call this a solution, but as you can see from this line if you launch aw-qt with --no-gui, trayicon.py will not be imported. You will have no tray icon, but you will have no Qt issues.