-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Raster canvas items render at wrong scale with High DPI devices #46882
Comments
I am experiencing the same issue on Windows with QGIS 3.22.3 @gioman could you please update the issue removing the macOS label? There is any test that I can do in order to help? |
I did test on a Lenovo laptop, Windows 10, 2880x1800 resolution and 200% scaling reported in the Display settings, and it rendered correctly. I suspect it may be hardware or driver specific on Windows then. My laptop has both Intel Xe and NVidia MX450 graphics, I'm not sure which is being used at the time. @fgianoli Can you update with your hardware details and scaling? I was unable to test on Linux as my distro is only on 3.22.0. I'll try dig into the devicePixelRatio() code some more to see where it's getting the details from. |
Thanks @jlayt I have a DELL XPS 7390, running Windows 10 Pro |
I don't know if these settings could be related to the issues, but I added some Windows Env variables in order to see correctly the QGIS GUI as described in this post post QT_AUTO_SCREEN_SCALE_FACTOR = 0 |
Looking at QgsMapSettings::devicePixelRatio(), it is a float that defaults to 1.0 unless overridden. This appears to happen in QgsMapCanvas::updateDevicePixelFromScreen() where it always gets set from QPaintDevice::devicePixelRatio(). Note that this returns an integer value, QPaintDevice::devicePixelRatioF() should be used to get a float, I'm not sure if that affects anything though as it's usually 2.0 for high dpi. Next, QgsMapCanvas::updateDevicePixelFromScreen() checks if QgsSettingsRegistryGui::settingsRespectScreenDPI is set, and if so sets QgsMapSettings::outputDpi() to the physical DPI of the screen, otherwise to the logical DPI. The latter is commented as "Fallback: compatibility with QGIS <= 3.20; always assume low dpi screens". `Does this mean QgsMapSettings has an inconsistent devicePixelRatio set to a High DPI ratio, but an outputDpi set to a low DPI? Again, not sure if that's an issue or not, as setting settingsRespectScreenDPI seems to make no difference for me (but Macs do fake a lot of this stuff...). It still seems a little weird that in QgsMapRendererJob::allocateImage() the QImage already has the devicePixelRatio set from the QgsMapSettings, so why the extra * devicePixelRatio is needed to set the dotsPerMeter I'm not sure. If I had to guess, I'd say 7c97dbb needs reverting? Then again, all this dpi stuff does hurts my brain, there's a reason I mostly hacked on QtCore! I am trying to run the nightly to get debug output that logs the various numbers involved, but can't seem to produce it, anyone have hints on how that works on Mac? |
Should be fixed by #46931 |
Tested the nightly and can confirm this resolves out issues, many thanks Nyall! |
What is the bug or the crash?
In the latest 3.22.3 release on Retina Macs, GeoTIFFs are being rendered on canvas at the wrong scale and position and very fuzzy. Using the query tool shows that the data itself still has the correct extent. Using the measure tool the scale appears to be out by a factor of 2 times, which I believe is the usual scaling factor applied by Macs on Retina / High DPI screens? Setting "Respect Screen DPI" and restarting has no effect.
QGIS 3.22.2 and 3.16.16 render correctly, as do non-Retina Macs using v3.22.3. Tested on both macOS 11.6 and 12.1. I am unable to test on Windows or Linux High DPI devices at this time, but could do so this evening if required.
I suspect some recent patches to use devicePixelRatio to set dotsPerMeter may be at fault, see commits 7c97dbb and 9a8824e in PR #46515 to fix Issue #44426, which appears in 3.22.3 but is not in 3.16.16.
Steps to reproduce the issue
Versions
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: