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

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

Open
aryoda opened this issue Feb 3, 2023 · 15 comments
Assignees
Labels
Bug Feedback needs user response, may be closed after timeout without a response Notifications desktop, email, GUI/tray status messages Qt Qt bugs, code or features Reproduced

Comments

@aryoda
Copy link
Contributor

aryoda commented Feb 3, 2023

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 8495f9d (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 aryoda added Qt Qt bugs, code or features Bug labels Feb 3, 2023
@aryoda
Copy link
Contributor Author

aryoda commented Feb 3, 2023

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

  • Running make test errors out on filesystem Regex #981 (comment)
    (in 2019 by graysky - the AUR pkg maintainer)
  • System tray icon appears during the backup, but with no icon #1098 (comment)
    • seems to happen when started via cron since the user talks about "crontab"
    • Linux version 5.5.7-arch1-1
    • Budgie DE with Papirus icon theme
    • Another user reports: I have no DE (running Arch + Qtile) and the icon I use are Adwaita, Breeze and Papirus (with Papirus being the main one).
    • Another user reports:

      Also confirmed for KDE on Arch. For me the icon has been missing for a few years now.

    • One user reported a strange display server setting (but may be unrelated): Display Server=tty
  • Fix #1333: arch Linux build fails #1353 (comment)

    Manjaro VM: When I'm on a terminal emulator in the desktop environment make test is fine.
    But when I log into that same machine via SSH in a real terminal (without X11/Wayland involved)
    I got an error about QPainter which polutes the output and make a test fail.

@aryoda
Copy link
Contributor Author

aryoda commented Feb 3, 2023

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

#1098 (comment)

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

@aryoda aryoda changed the title backintime CLI shows Qt5 warning (QWidget::render: Cannot render with an inactive painter) backintime CLI shows Qt5 message (QWidget::render: Cannot render with an inactive painter) Feb 3, 2023
@aryoda aryoda changed the title backintime CLI shows Qt5 message (QWidget::render: Cannot render with an inactive painter) backintime CLI shows Qt5 warning (QWidget::render: Cannot render with an inactive painter) Feb 3, 2023
@aryoda
Copy link
Contributor Author

aryoda commented Feb 3, 2023

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):

self.pixmap = icon.BIT_LOGO.pixmap(24)
self.progressBar = QProgressBar()
self.progressBar.setMinimum(0)
self.progressBar.setMaximum(100)
self.progressBar.setValue(0)
self.progressBar.setTextVisible(False)
self.progressBar.resize(24, 6)
self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))

@scaramangado
Copy link

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
Copy link
Contributor Author

aryoda commented Feb 5, 2023

@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
Copy link

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
Copy link
Contributor Author

aryoda commented Feb 5, 2023

@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
Copy link
Contributor Author

aryoda commented Feb 5, 2023

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:

self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))

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:

self.status_icon.show()

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
Copy link
Contributor Author

aryoda commented Feb 5, 2023

@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 ;-)

@aryoda aryoda added the Feedback needs user response, may be closed after timeout without a response label Feb 6, 2023
@scaramangado
Copy link

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

@aryoda
Copy link
Contributor Author

aryoda commented Feb 7, 2023

@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...).

@aryoda aryoda added Notifications desktop, email, GUI/tray status messages Reproduced and removed Feedback needs user response, may be closed after timeout without a response labels Feb 7, 2023
@topas-rec
Copy link

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.

@buhtz buhtz added this to the 1.3.5 / 1.4.0 milestone Mar 19, 2023
@aryoda
Copy link
Contributor Author

aryoda commented Jul 17, 2023

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
Copy link
Contributor Author

aryoda commented Jan 10, 2024

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
Copy link
Member

buhtz commented Sep 17, 2024

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

@buhtz buhtz self-assigned this Sep 17, 2024
@buhtz buhtz added the Feedback needs user response, may be closed after timeout without a response label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Feedback needs user response, may be closed after timeout without a response Notifications desktop, email, GUI/tray status messages Qt Qt bugs, code or features Reproduced
Projects
None yet
Development

No branches or pull requests

4 participants