RFP new window size is off because of roundings on partial values
Categories
(Core :: Window Management, defect)
Tracking
()
People
(Reporter: pierov, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
STR:
- enable
privacy.resistFingerprinting
- set system scaling to 1.25 (other scales might have slightly different results)
- open Firefox
- open the inspector, and notice the inner window width is 1399.2 CSS px rather than the expected 1400 CSS px. If LB is enabled, margins will be visible (in particular, the screenshot has the patches for Bug 1556016 applied)
Expected result: a window whose width is 1400 CSS px also when scaling is used.
Other configuration have problems with height rather than width (or maybe both).
I tried to debug and understand the cause.
nsContentUtils::CalcRoundedWindowSizeForResistingFingerprinting
correctly returns a target width of 1750 dev px.
Then, the combination of AppWindow::SetPrimaryContentSize
and AppWindow::SizeShellToWithLimit
adds an offset of 17 dev px, given by the difference of the current window size and the shell width.
I think these 17px are wrong because partial values are rounded. I checked this stack trace:
xul.dll!mozilla::dom::Element::ClientHeight() Line 1586
at C:\mozilla-source\mozilla-unified\obj-x86_64-pc-windows-msvc\dist\include\mozilla\dom\Element.h(1586)
xul.dll!mozilla::AppWindow::GetPrimaryRemoteTabSize(int * aWidth, int * aHeight) Line 2106
at C:\mozilla-source\mozilla-unified\xpfe\appshell\AppWindow.cpp(2106)
xul.dll!mozilla::AppWindow::GetPrimaryContentSize(int * aWidth, int * aHeight) Line 2092
at C:\mozilla-source\mozilla-unified\xpfe\appshell\AppWindow.cpp(2092)
In particular, on my VM (1920x1080 resolution with 1.25 scaling):
- https://searchfox.org/mozilla-central/rev/7c573d9eb97e7b1ba383239bfac9260b26983544/dom/base/Element.h#1582-1587:
GetClientAreaRect()
is 91296x43920 AU, i.e., 1521.6x732 CSS px, but it gets rounded to 1522x732 - https://searchfox.org/mozilla-central/rev/7c573d9eb97e7b1ba383239bfac9260b26983544/xpfe/appshell/AppWindow.cpp#2107-2108: we round the above after applying scaling to convert to dev px: 1522x732 CSS px is rounded from 1902.5x732 dev px to 1903x732 dev px
- 1521.6 CSS px would be exactly 1902 dev px, i.e. a 18px difference rather than 17px, and a final outer width of 1768px. I tried to set that value from the debugger, and with it the inner width would be the expected 1400 CSS px.
Reporter | ||
Comment 1•25 days ago
|
||
Notice that this should help to fix the behavior on Windows, that has different inner and outer sizes.
Currently there's some bug on Linux as well, but I think it's due to some bad rounding in GTK.
Reporter | ||
Comment 2•25 days ago
|
||
Updated•25 days ago
|
Comment 3•12 days ago
|
||
The severity field is not set for this bug.
:enndeakin, could you have a look please?
For more information, please visit BugBot documentation.
Description
•