Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0, dev
-
None
Description
Found this while working on QTBUG-113040.
If you try to obtain current window's DPR directly in <YourQuickItem>::componentComplete(),
via window()->effectiveDevicePixelRatio(), you'll get wrong result (always 1.0), no matter on which screen the window is shown. And only later there is a call of <YourQuickItem>::itemChange(), that notifies the item about actual DPR.
It's crucial for items like QQuickImage or QQuickText which use current DPR in their implementation.
Thus QQuickImage, when instantiated on a screen with scale factor other than 1.0, loads a pixmap twice.
First time from QQuickImageBase::componentComplete() with wrong DPI, and second time from QQuickImageBase::itemChange() with correct DPR.
This is not good at least in terms of performance.
First time (with DPR = 1.0):
1 QQuickPixmap::load qquickpixmapcache.cpp 1798 0x7ff804cb49d6 2 QQuickImageBase::loadPixmap qquickimagebase.cpp 307 0x7ff80480dc06 3 QQuickImageBase::load qquickimagebase.cpp 353 0x7ff80480de6b 4 QQuickImageBase::componentComplete qquickimagebase.cpp 429 0x7ff80480deed 5 QQmlObjectCreator::finalize qqmlobjectcreator.cpp 1487 0x7ff80a45d6ac 6 QQmlComponentPrivate::complete qqmlcomponent.cpp 1101 0x7ff80a30947b 7 QQmlComponentPrivate::completeCreate qqmlcomponent.cpp 1205 0x7ff80a307eab 8 QQmlComponent::completeCreate qqmlcomponent.cpp 1183 0x7ff80a304ad3 9 QQmlComponentPrivate::createWithProperties qqmlcomponent.cpp 922 0x7ff80a30a365 10 QQmlComponent::create qqmlcomponent.cpp 871 0x7ff80a3048b5 11 QQmlApplicationEnginePrivate::finishLoad qqmlapplicationengine.cpp 135 0x7ff80a2c223b 12 QQmlApplicationEnginePrivate::ensureLoadingFinishes qqmlapplicationengine.cpp 163 0x7ff80a2c24ee 13 QQmlApplicationEnginePrivate::startLoad qqmlapplicationengine.cpp 110 0x7ff80a2c1cae 14 QQmlApplicationEngine::load qqmlapplicationengine.cpp 324 0x7ff80a2c0c2e ...
Second time (with DPR = 1.25):
1 QQuickPixmap::load qquickpixmapcache.cpp 1798 0x7ff804cb49d6 2 QQuickImageBase::loadPixmap qquickimagebase.cpp 307 0x7ff80480dc06 3 QQuickImageBase::load qquickimagebase.cpp 353 0x7ff80480de6b 4 QQuickImageBase::itemChange qquickimagebase.cpp 416 0x7ff80480e03d 5 QQuickItemPrivate::itemChange qquickitem.cpp 6732 0x7ff8048370dc 6 updatePixelRatioHelper qquickwindow.cpp 387 0x7ff804a44ce0 7 updatePixelRatioHelper qquickwindow.cpp 389 0x7ff804a44d47 8 updatePixelRatioHelper qquickwindow.cpp 389 0x7ff804a44d47 9 QQuickWindow::physicalDpiChanged qquickwindow.cpp 401 0x7ff804a3da16 10 QQuickWindow::event qquickwindow.cpp 1550 0x7ff804a3d1d7 11 QCoreApplicationPrivate::notify_helper qcoreapplication.cpp 1282 0x7ff809e79332 12 doNotify qcoreapplication.cpp 1211 0x7ff809e7bbb3 13 QCoreApplication::notify qcoreapplication.cpp 1195 0x7ff809e75928 14 QGuiApplication::notify qguiapplication.cpp 1961 0x7ff805afad1f 15 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1115 0x7ff809e77937 16 QCoreApplication::sendEvent qcoreapplication.cpp 1534 0x7ff809e74f9b 17 QWindowPrivate::updateDevicePixelRatio qwindow.cpp 1357 0x7ff805c16e39 18 QGuiApplicationPrivate::processWindowScreenChangedEvent qguiapplication.cpp 2586 0x7ff805b032ef 19 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 2060 0x7ff805b03509 20 QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<QWindowSystemInterfacePrivate::WindowScreenChangedEvent,QWindow *,QScreen *> qwindowsysteminterface.cpp 107 0x7ff805c2e329 21 handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowScreenChangedEvent,QWindowSystemInterface::SynchronousDelivery,QWindow *,QScreen *> qwindowsysteminterface.cpp 139 0x7ff805c23d9e 22 QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery> qwindowsysteminterface.cpp 260 0x7ff805c30e7e 23 QWindowsWindow::initialize qwindowswindow.cpp 1540 0x7ff80eb68116 24 QWindowPrivate::create qwindow.cpp 533 0x7ff805c15d87 25 QWindow::create qwindow.cpp 684 0x7ff805c0e4b8 26 QWindowPrivate::setVisible qwindow.cpp 349 0x7ff805c153ed 27 QWindow::setVisible qwindow.cpp 657 0x7ff805c1190c 28 QQuickWindowQmlImpl::setVisible qquickwindowmodule.cpp 38 0x7ff804a642de 29 QQuickWindowQmlImpl::setWindowVisibility qquickwindowmodule.cpp 147 0x7ff804a65663 30 QQuickWindowQmlImpl::componentComplete qquickwindowmodule.cpp 90 0x7ff804a64ce0 31 QQmlObjectCreator::finalize qqmlobjectcreator.cpp 1487 0x7ff80c33d6ac 32 QQmlComponentPrivate::complete qqmlcomponent.cpp 1101 0x7ff80c1e947b 33 QQmlComponentPrivate::completeCreate qqmlcomponent.cpp 1205 0x7ff80c1e7eab 34 QQmlComponent::completeCreate qqmlcomponent.cpp 1183 0x7ff80c1e4ad3 35 QQmlComponentPrivate::createWithProperties qqmlcomponent.cpp 922 0x7ff80c1ea365 36 QQmlComponent::create qqmlcomponent.cpp 871 0x7ff80c1e48b5 37 QQmlApplicationEnginePrivate::finishLoad qqmlapplicationengine.cpp 135 0x7ff80c1a223b 38 QQmlApplicationEnginePrivate::ensureLoadingFinishes qqmlapplicationengine.cpp 163 0x7ff80c1a24ee 39 QQmlApplicationEnginePrivate::startLoad qqmlapplicationengine.cpp 110 0x7ff80c1a1cae 40 QQmlApplicationEngine::load qqmlapplicationengine.cpp 324 0x7ff80c1a0c2e 41 main main.cpp 42 0x7ff7bdbb2a57 42 qtEntryPoint qtentrypoint_win.cpp 50 0x7ff7bdbb67c7 43 WinMain qtentrypoint_win.cpp 60 0x7ff7bdbb65ce
To reproduce this just run attached sample dpi_issue.zip on a screen with scale factor other than 1.0 (e.g. 1.25)
and check output.
Current result:
itemChange() type = QQuickItem::ItemSceneChange itemChange() type = QQuickItem::ItemParentHasChanged componentComplete(): DPI = 1 <<<--- WRONG itemChange() type = QQuickItem::ItemDevicePixelRatioHasChanged DPI changed to 1.25 qml: Component.onCompleted()
Reproduced at least on Windows.
Attachments
Issue Links
- relates to
-
QTBUG-113040 Quick Text: SVG inline images have poor quality on High-DPI displays
- Reported
-
QTBUG-113236 [REG] QQuickItem::ItemDevicePixelRatioHasChanged is triggered with a wrong value
- Closed