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

Weird rendering of some SVG images #776

Closed
qadzek opened this issue Feb 11, 2024 · 6 comments
Closed

Weird rendering of some SVG images #776

qadzek opened this issue Feb 11, 2024 · 6 comments
Labels
bug Something isn't working qt Upstream Qt issue

Comments

@qadzek
Copy link

qadzek commented Feb 11, 2024

Hi,

First of all, thanks for fixing my previous issue #748; I can now enjoy SVG files in my favorite image viewer.

However, I noticed weird rendering in some cases. In the first screenshot, you can see the desired result on the left and Vimiv on the right. It seems there's an issue regarding the background color.

When I zoom in further, something even stranger happens (second screenshot): the image is no longer a rectangle, some parts are protruding.

I don't know if there's something wrong with my machine or if this is a general issue.

$ vimiv --version
vimiv v0.9.0

Python: 3.10.12
Qt: 5.15.3
PyQt: 5.15.6

Svg Support: True

vimiv1
vimiv2
bg-sidebar-desktop

@jcjgraf
Copy link
Contributor

jcjgraf commented Feb 11, 2024

Thanks for reporting. I can reproduce the issue even with PyQt6 (did not try PySide6 though, but I also do not know if this could possibly make a difference).

Vimiv relies on QT to do the rendering of the SVGs. So there is nothing we can do about this. AI, under my directives, has created a MVE that illustrates the issue (scroll using the mouse wheel):

import sys
from PyQt6.QtWidgets import QGraphicsView, QGraphicsScene, QApplication
from PyQt6.QtSvgWidgets import QGraphicsSvgItem
from PyQt6.QtGui import QColor, QPainter

SVG_PATH = "./vimiv_problem.svg"


class CustomGraphicsView(QGraphicsView):
    def __init__(self):
        super().__init__()
        self.setRenderHints(
            QPainter.RenderHint.Antialiasing | QPainter.RenderHint.SmoothPixmapTransform
        )
        self.setTransformationAnchor(QGraphicsView.ViewportAnchor.AnchorUnderMouse)
        self.setResizeAnchor(QGraphicsView.ViewportAnchor.AnchorUnderMouse)

    def wheelEvent(self, event):
        zoom_factor = 1.2

        if event.angleDelta().y() > 0:
            self.scale(zoom_factor, zoom_factor)
        else:
            self.scale(1 / zoom_factor, 1 / zoom_factor)


def display_svg_image(file_path):
    app = QApplication(sys.argv)
    view = CustomGraphicsView()
    scene = QGraphicsScene()
    scene.setBackgroundBrush(QColor("darkgray"))
    svg_item = QGraphicsSvgItem(file_path)
    scene.addItem(svg_item)
    view.setScene(scene)
    view.show()
    sys.exit(app.exec())


if __name__ == "__main__":
    display_svg_image(SVG_PATH)

I suggest that you try some non-QT based rendered to rule-out a faulty SVG. If the issue is with QT, report it to upstream QT.

@karlch
Copy link
Owner

karlch commented Feb 12, 2024

Thanks for reporting and thanks @jcjgraf for your quick and conclusive analysis! Exact same issues with PySide6.

I can only agree, and also remember that we had issues with Qt Svg before (see #423), so this is most likely a Qt issue. Especially as you show a perfectly fine screenshot with another imageviewer (Gtk-based I assume?) on the left.

I would second reporting upstream, that could be really helpful! The chance of us doing some internal workaround - or even not using Qt - are near zero. So I would flag and close this for now.

@karlch karlch added bug Something isn't working qt Upstream Qt issue labels Feb 12, 2024
@karlch karlch closed this as completed Feb 12, 2024
@qadzek
Copy link
Author

qadzek commented Feb 12, 2024

Thanks for the quick replies.

On the left, I was using Xviewer, which indeed seems Gtk-based.

Is there a GitHub repo where I can report this bug or should I do it on https://bugreports.qt.io? I have no experience with Qt.

@karlch
Copy link
Owner

karlch commented Feb 13, 2024

I don't know of any Github repo that is more than just a mirror.

https://bugreports.qt.io/ is the way to go, thank you 😊

@qadzek
Copy link
Author

qadzek commented Feb 18, 2024

Thanks. The bug was reported: https://bugreports.qt.io/browse/QTBUG-122413

@karlch
Copy link
Owner

karlch commented Mar 11, 2024

Thanks again for opening the issue on the Qt end. Sounds like this was actually recently solved by them. I currently don't have Qt 6.7 just yet, but will be sure to test it once I do and update here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working qt Upstream Qt issue
Projects
None yet
Development

No branches or pull requests

3 participants