Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.2, 5.12.10, 5.15.2
-
None
-
Qt 5.15 on Android (Moto G5S). Occurs on other devices, such as Pixel 4a
Description
This is a remaining un-solved issue after closing QTBUG-62191
On my Moto G5 S, with a 1080 x 1920 pixels screen, the most simple QML app filling the sreen with a black square have a remaining white line at the bottom. It is present on the screen shot below even though hard to see on a white background).
I attach a small project reproducing the issue on my device: bug-white-line.zip
The reason for this is problem was very well described in QTBUG-62191 (caused by the pixel ratio error). Unfortunately the provided fix (https://codereview.qt-project.org/#/c/202498/10) is not going to solve the issue at least for this phone.
On my device, the ratio reported by QPlatformScreen pixelDensity() is 2.55 px/dp, and it is then recalculated by Victor-Andrei Variu's patch to be 2.5487622106249166 px/dp
The reported ps size is 424 x 753 dp (after Victor-Andrei Variu's fix) and multiplied by the ratio, this gives: 1080.5577.. x 1919.009433.. which rounds to 1081 x 1919 and match what I observe, with a 1px delta in height (and I guess one column of pixel rendered outside of the screen but it's not visible).
The problem is that using the same pixel ratio for both width and height is never going to be always working if the ratio is > 2 and not integer (I think, I may be wrong).
The only clean fix I can think of would be to use 2 different pixels ratio for width and height, at least when converting QSize from dp to px.
That said, the current solution can be slightly improved by changing this line in QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen):
qreal hFactor = qreal(screenGeometry.height()) / qRound(screenGeometry.height() / pixelDensity);
into
qreal hFactor = qreal(screenGeometry.height()) / qRound(screenGeometry.height() / wFactor);
This allows to reduce the number of failing devices from 4 to 3 in the unit test provided in Victor-Andrei Variu's bug report.