bit-team / backintime

Back In Time - An easy-to-use backup tool for GNU Linux using rsync in the back
https://backintime.readthedocs.io
GNU General Public License v2.0
2.03k stars 201 forks source link

backintime CLI shows Qt5 warning (QWidget::render: Cannot render with an inactive painter) #1404

Open aryoda opened 1 year ago

aryoda commented 1 year ago

This issue is based on user feedback on AUR for Arch Linux regarding a failing unit test of the new BiT release v1.3.3 which is basically cause by this unexpected additional output in the "actual" part of the unit test assertion:

QPainter::begin: Paint device returned engine == 0, type: 2
QWidget::render: Cannot render with an inactive painter

The exact output was:

FAIL: test_local_snapshot_is_successful (test.test_backintime.TestBackInTime)
end to end test - from BIT initialization through snapshot
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/myuser/.cache/paru/clone/backintime/src/backintime-8495f9dc3953343a0352bb3ffbdcfab7f93c10ad/common/test/test_backintime.py", line 147, in test_local_snapshot_is_successful
    self.assertRegex(filtered_log_output, re.compile(r'''INFO: Lock
AssertionError: Regex didn't match: 'INFO: Lock\nINFO: Take a new snapshot. Profile: 1 Main profile\nINFO: Call rsync to take the snapshot\nINFO: Save config file\nINFO: Save permissions\nINFO: Create info file\nINFO: Unlock\n' not found in 'INFO: Lock\nINFO: Take a new snapshot. Profile: 1 Main profile\nINFO: Call rsync to take the snapshot\nINFO: Save config file\nINFO: Save permissions\nINFO: Create info file\nQPainter::begin: Paint device returned engine == 0, type: 2\nQWidget::render: Cannot render with an inactive painter\nINFO: Unlock\n'

The AUR package is based on commit 8495f9dc3953343a0352bb3ffbdcfab7f93c10ad (which is our v1.3.3 Git tag for the release).

The unexpected output occurs not on every installation but only under unclear side conditions.

aryoda commented 1 year ago

There are several issues that mention the above "cannot render with an inactive painter" message in other contexts:

aryoda commented 1 year ago

To all affected users: Could you please provide me the output of this (very long ;-) command line to give me more context:

https://github.com/bit-team/backintime/issues/1098#issuecomment-1325794193

The output of backintime --diagnostics would also be very helpful for me!

aryoda commented 1 year ago

Internal developer note: The Qt5 source code that throws the warning is here (may be an older code version but good enough to dig deeper):

https://codebrowser.dev/qt5/qtbase/src/gui/painting/qpainter.cpp.html#1765

type: 2 seems to reference a Pixmap device:

https://codebrowser.dev/qt5/qtbase/src/corelib/global/qnamespace.h.html#QInternal::Pixmap

The only location where BiT is directly using and rendering a Pixmap is in the qtsystrayicon.py code which already was the primary suspect for this bug before (as it is called from the "show systray icon" plugin which can only work if a supported rendering device is available):

https://github.com/bit-team/backintime/blob/e22c7f253fa048fab9119f4cbea34c0fa8d1aba6/qt/qtsystrayicon.py#L102-L109

scaramangado commented 1 year ago

I encountered the issue on my Arch installation. Prior to 1.3.3 I installed multiple versions without error. When skipping the unit test during the install the applications runs fine as it always did in the past.

In case it is of importance (since the error message mentions a widget): I'm running a standalone WM and the BiT tray icon was never correctly displayed for me (see issue #1306).

$ backintime --diagnostics

{
    "backintime": {
        "name": "Back In Time",
        "version": "1.3.3-dev",
        "latest-config-version": 6,
        "local-config-file": "/home/UsernameReplaced/.config/backintime/config",
        "local-config-file-found": true,
        "global-config-file": "/etc/backintime/config",
        "global-config-file-found": false,
        "started-from": "/usr/share/backintime/common",
        "running-as-root": false,
        "user-callback": "/home/UsernameReplaced/.config/backintime/user-callback",
        "keyring-supported": false
    },
    "host-setup": {
        "platform": "Linux-6.1.9-arch1-1-x86_64-with-glibc2.36",
        "system": "Linux #1 SMP PREEMPT_DYNAMIC Wed, 01 Feb 2023 17:07:39 +0000",
        "os-release": {
            "NAME": "Arch Linux",
            "ID": "arch",
            "PRETTY_NAME": "Arch Linux",
            "BUILD_ID": "rolling",
            "ANSI_COLOR": "38;2;23;147;209",
            "HOME_URL": "https://archlinux.org/",
            "DOCUMENTATION_URL": "https://wiki.archlinux.org/",
            "SUPPORT_URL": "https://bbs.archlinux.org/",
            "BUG_REPORT_URL": "https://bugs.archlinux.org/",
            "PRIVACY_POLICY_URL": "https://terms.archlinux.org/docs/privacy-policy/",
            "LOGO": "archlinux-logo"
        },
        "display-system": "x11",
        "locale": "en_US, UTF-8",
        "PATH": "/home/UsernameReplaced/git_bin:/usr/local/texlive/2020/bin/x86_64-linux:/usr/bin:/sbin:/usr/sbin:/home/UsernameReplaced/.local/bin:/home/UsernameReplaced/.cargo/bin:/home/UsernameReplaced/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl",
        "RSYNC_OLD_ARGS": "(not set)",
        "RSYNC_PROTECT_ARGS": "(not set)"
    },
    "python-setup": {
        "python": "3.10.9 main Dec 19 2022 17:35:49 CPython GCC 12.2.0",
        "python-executable": "/usr/bin/python",
        "python-executable-symlink": true,
        "python-executable-resolved": "/usr/bin/python3.10",
        "sys.path": [
            "/usr/share/backintime/qt/plugins",
            "/usr/share/backintime/common/plugins",
            "/usr/share/backintime/plugins",
            "/usr/share/backintime/common",
            "/usr/lib/python310.zip",
            "/usr/lib/python3.10",
            "/usr/lib/python3.10/lib-dynload",
            "/usr/lib/python3.10/site-packages"
        ],
        "qt": "PyQt 5.15.8 / Qt 5.15.8"
    },
    "external-programs": {
        "rsync": {
            "program": "rsync",
            "version": "3.2.7",
            "protocol": "31.0",
            "copyright": "(C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.",
            "url": "https://rsync.samba.org/",
            "capabilities": {
                "file_bits": 64,
                "inum_bits": 64,
                "timestamp_bits": 64,
                "long_int_bits": 64,
                "socketpairs": true,
                "symlinks": true,
                "symtimes": true,
                "hardlinks": true,
                "hardlink_specials": true,
                "hardlink_symlinks": true,
                "IPv6": true,
                "atimes": true,
                "batchfiles": true,
                "inplace": true,
                "append": true,
                "ACLs": true,
                "xattrs": true,
                "secluded_args": "optional",
                "iconv": true,
                "prealloc": true,
                "stop_at": true,
                "crtimes": false
            },
            "optimizations": {
                "SIMD_roll": true,
                "asm_roll": false,
                "openssl_crypto": true,
                "asm_MD5": false
            },
            "checksum_list": [
                "xxh128",
                "xxh3",
                "xxh64",
                "md5",
                "md4",
                "sha1",
                "none"
            ],
            "compress_list": [
                "zstd",
                "lz4",
                "zlibx",
                "zlib",
                "none"
            ],
            "daemon_auth_list": [
                "sha512",
                "sha256",
                "sha1",
                "md5",
                "md4"
            ],
            "license": "GPLv3",
            "caveat": "rsync comes with ABSOLUTELY NO WARRANTY"
        },
        "ssh": "OpenSSH_9.2p1, OpenSSL 3.0.7 1 Nov 2022",
        "sshfs": "3.7.3",
        "encfs": "1.9.5",
        "shell": "/bin/zsh",
        "shell-version": "zsh 5.9 (x86_64-pc-linux-gnu)"
    }
}
aryoda commented 1 year ago

@scaramangado THX for your diagnostics info!

I'm running a standalone WM

Which WM do you use (and what exactly do you mean with "standalone WM")?

scaramangado commented 1 year ago

Which WM do you use (and what exactly do you mean with "standalone WM")?

I use the awesome window manager, standalone as in "no full desktop environment".

aryoda commented 1 year ago

@scaramangado THX a lot, after installing awesome with sudo pacman -S --needed xorg-server xorg-xinit xterm awesome and restarting into the awesome Xsession I can reproduce the failing unit test now with exactly the same error! I think I can debug this now in my VM.

BTW: Tiling and ad-hoc window configuration is unbelievably cool and easy in awesome, I have never seen it like this before.

PS: I am just struggling to change the keyboard layout to "DE" ;-) Edit: Found it: setxkbmap -layout "de,us"

aryoda commented 1 year ago

Gotcha! The unit test indeed fails due to a missing dependency: There is no supported theme installed that provides a BiT logo icon for the system tray icon.

The Qt5 warnings are thrown by this line of code:

https://github.com/bit-team/backintime/blob/e22c7f253fa048fab9119f4cbea34c0fa8d1aba6/qt/qtsystrayicon.py#L109

The pixmap contains the BiT logo but if it is not installed it cannot be rendered.

The bug can also be reproduced without the failing unit test by calling

backintime backup

(requires at least one configured backup profile) and shows one more output line that clearly indicates the problem:

QPainter::begin: Paint device returned engine == 0, type: 2
QWidget::render: Cannot render with an inactive painter
...
QSystemTrayIcon::setVisible: No Icon set

The last line is thrown when this line of code is executed:

https://github.com/bit-team/backintime/blob/e22c7f253fa048fab9119f4cbea34c0fa8d1aba6/qt/qtsystrayicon.py#L134

Why this last warning is not contained in the actual unit test output is unknown to me, esp. because it is also a Qt5 warning:

https://codebrowser.dev/qt5/qtbase/src/widgets/util/qsystemtrayicon.cpp.html#316

aryoda commented 1 year ago

@scaramangado Could you please install the package oxygen-icons (which is the BiT fallback icon set that is activated if nothing else is found)?

The unit test should then succeed and the BiT logo correctly shown in the application as well as in the system tray.

If you have already installed BiT you can simply test it with

backintime backup

if at least one profile is configured (otherwise only the unit test can tell us if the failure still occurs)...

If you don't want to reinstall BiT you can call the unit tests directly in the AUR clone folder (if it still exists):

cd <AUR clone parent folder>/backintime/src/backintime-*/common
make test

The unit tests should succeed now and none of the above Qt5 warnings be shown...

With backintime backup the system tray icon of BiT should also appear for at least half a second...

If you uninstall oxygen-icons again the problem should re-occur ;-)

scaramangado commented 1 year ago

Installing the icon package does fix the tests for me indeed.

aryoda commented 1 year ago

@scaramangado THX a lot for investing your time to hunt this annoying bug down. I will fix this together with the master issue #1306 (together with all the other systray and icon issues that other users reported). I think I need at least until end of next week for this (requires a lot of testing on different VMs and scenarios...).

topas-rec commented 1 year ago

Could you please install the package oxygen-icons (which is the BiT fallback icon set that is activated if nothing else is found)?

The unit test should then succeed

Doesn't work on my machine. If this should be investigated before releasing the fix I'll test things on my machine if you tell me what to do. Otherwise I'll wait for the fix - I don't need to upgrade immediately.

aryoda commented 1 year ago

I have fixed all known systray and app icon issues (hopefully) with my PR #1480 (on dev branch) and this could also solve this issue.

Re-testing and feed-back welcome!

aryoda commented 8 months ago

Not sure but I think we could this issue after the upcoming release (mid to end of Jan 2024) and if no re-test fails.

buhtz commented 1 week ago

Asked on "bit-dev" if someone experience the error since version 1.3.4.