Wayland opaque region is sometimes too small with fractional scaling
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
People
(Reporter: xaver.hugl, Assigned: stransky, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 external file)
|
210.15 KB,
text/plain
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:155.0) Gecko/20100101 Firefox/155.0
Steps to reproduce:
Run Firefox with
WAYLAND_DEBUG=1 firefox 2>&1 | grep -E 'opaque|region|set_destination'
and slowly resize it.
The scale of my screen is set to 160%, in case it matters.
Actual results:
With some sizes, the opaque region is off by one pixel, which prevents offloading the surface to an underlay:
[23:36:46.632717] {Default Queue} -> wl_compositor#4.create_region(new id wl_region#99)
[23:36:46.632719] {Default Queue} -> wl_region#99.add(0, 0, 1713, 1056)
[23:36:46.632721] {Default Queue} -> wl_surface#74.set_opaque_region(wl_region#99)
[23:36:46.632723] {Default Queue} -> wl_region#99.destroy()
[23:36:46.636767] {Default Queue} -> wp_viewport#73.set_destination(1714, 1056)
Expected results:
The opaque region should match the surface size.
Comment 1•1 month ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•1 month ago
|
| Assignee | ||
Comment 2•1 month ago
|
||
Looks like a rounding error. Xaver, does it help if we create opaque region larger than the surface as a workaround?
Thanks.
| Assignee | ||
Updated•1 month ago
|
| Reporter | ||
Comment 3•1 month ago
|
||
Yeah, if you know the whole surface is opaque, you can set the opaque region to something like -INT_MIN/2, -INT_MIN/2, INT_MAX, INT_MAX and the compositor will clip it as needed.
Comment 4•24 days ago
|
||
The current code is rounding in to get a smaller region for safety. If an opaque region is too large, the compositor may ignore the alpha channel of pixels wrongly on edges. So, we may need to consider if the window is maximized to have no shadow and round corners, and make opaque region taking whole surface if the window is maximized, no shadow and round corners.
| Assignee | ||
Comment 5•24 days ago
|
||
Xaver, can you please run on terminal with MOZ_LOG="Widget:5,WaylandWayland:5" reproduce the issue and attach the log here?
I guess we're talking about toplevel and fullscreen/maximized state, right?
Thanks.
| Reporter | ||
Comment 6•24 days ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #5)
Xaver, can you please run on terminal with MOZ_LOG="Widget:5,WaylandWayland:5" reproduce the issue and attach the log here?
Sure.
I guess we're talking about toplevel and fullscreen/maximized state, right?
Yes, toplevel, but not maximized or fullscreen (though they might also be affected). This is windowed mode with a server side decoration.
| Reporter | ||
Comment 7•24 days ago
|
||
I resized Firefox to a size where it would trigger the issue, then closed it and started it again with the debug flag set
| Assignee | ||
Comment 8•23 days ago
|
||
(In reply to Xaver Hugl from comment #6)
(In reply to Martin Stránský [:stransky] (ni? me) from comment #5)
Xaver, can you please run on terminal with MOZ_LOG="Widget:5,WaylandWayland:5" reproduce the issue and attach the log here?
Sure.I guess we're talking about toplevel and fullscreen/maximized state, right?
Yes, toplevel, but not maximized or fullscreen (though they might also be affected). This is windowed mode with a server side decoration.
server side decoration? Do we really use that? I expect we're running in CSD by default i.e. the decoration is painted by us (but by Gtk underlying window). Firefox manages only the overlay GdkWindow.
Comment 9•23 days ago
|
||
I guess browser.tabs.inTitlebar=0. I have saw some people prefer not having tabs in the titlebar.
| Assignee | ||
Comment 10•23 days ago
|
||
browser.tabs.inTitlebar only switches widget titlebar rendering by Gtk3 but doesn't change toplevel decoration style.
| Assignee | ||
Updated•23 days ago
|
| Assignee | ||
Comment 11•23 days ago
•
|
||
Theres' the relevant part:
nsWindow::ResizeInt w:1652 h:1023
resized 0 aSize [1652, 1023] mLastSizeRequest [1652, 1023] bounds [1652, 1023]
not moved or resized, quit
nsWindow::GetRestoredBounds() (x=0, y=0, w=2643, h=1637)
nsWindow::UpdateOpaqueRegionInternal() set opaque region [0,0] -> [1651 x 1023]
| Assignee | ||
Updated•23 days ago
|
| Assignee | ||
Comment 12•23 days ago
|
||
Updated•23 days ago
|
| Reporter | ||
Comment 13•22 days ago
|
||
server side decoration? Do we really use that? I expect we're running in CSD by default i.e. the decoration is painted by us
Yes. It can be turned on in the "customize toolbar" settings.
About rounding the region, fully solving that is a difficult problem... fractional-scale-v2 might help, since it's pixels instead of logical units.
In general though, fully opaque vs. not fully opaque makes the biggest difference, so maybe that could be special-cased, to ensure a fully opaque buffer also gets a full Wayland opaque region?
| Assignee | ||
Comment 14•22 days ago
|
||
The stable rounding can't be reversed to the recent implementation is just an approximation. But I reproduced that with 133% scale / CSD too for maximized window. Will try to make something based on upscale.
| Assignee | ||
Updated•22 days ago
|
| Assignee | ||
Comment 16•14 days ago
|
||
Looks like we upscale/donwnscale the opaque region coordinates at WaylandSurface and nsWindow. We should use single approach and perhaps keep downscaled coordinates and upscale on request.
| Assignee | ||
Comment 17•14 days ago
|
||
The fix may also contain Bug 2089544.
| Assignee | ||
Updated•14 days ago
|
| Assignee | ||
Comment 18•14 days ago
•
|
||
Xaver, how KWin calculates logical -> pixel coordinates for opaque region? Is it the same as for buffer size, i.e. just round(x * scale), round(width * scale) ?
| Assignee | ||
Updated•14 days ago
|
| Reporter | ||
Comment 19•11 days ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #18)
Xaver, how KWin calculates logical -> pixel coordinates for opaque region? Is it the same as for buffer size, i.e. just round(x * scale), round(width * scale) ?
Currently the same way as it maps coordinates for rendering, which is to say, round(x * scale), round((x + width) * scale).
I think ultimately this bug boils down to your current code implicitly assuming that everything outside of the buffer "leaks" transparency into it.
If you map the translucent region instead of the opaque one, it should no longer happen:
translucent = fullRect - opaque
logicalTranslucent = roundOut(translucent / scale) & fullLogicalRect
logicalOpaque = fullLogicalRect - translucent
(or when mapping the region, explicitly check for top/bottom/left/right edges and don't round them inwards)
Also, I feel like we should add a buffer_opaque region to Wayland, all this mapping back and forth really shouldn't be necessary. Even with fractional-scale-v2 you could use a different viewport and the opaque region is kinda meaningless again.
| Assignee | ||
Comment 20•11 days ago
|
||
We're slowly moving to painting the decoration by Firefox itself so it should be useful for fullscreen/maximized mode only. But I'm bit hesitant to hardcode the window states there.
Description
•