window: don't allocate a swapchain for 0x0 windows, handle reconfigure/next failures - #130
Closed
kallegrens wants to merge 1 commit into
Closed
window: don't allocate a swapchain for 0x0 windows, handle reconfigure/next failures#130kallegrens wants to merge 1 commit into
kallegrens wants to merge 1 commit into
Conversation
|
Hi @kallegrens, Thanks for your contribution! Unfortunately, Hyprland and hypr* no longer To get vouched, please see our contributing guide at wiki.hypr.land/Contributing-and-Debugging This PR has been closed automatically and will not be re-opened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Wayland compositor may send
wp_fractional_scale_v1.preferred_scalebefore the first xdg configure, i.e. while the window's logical size is still 0x0. On such an event,CWaylandWindow's scale handler callsonScaleUpdate()→configure(m_waylandState.logicalSize)→resizeSwapchain({0,0}), which:CSwapchain::reconfigure()with.length = 2and a zero size — under current aquamarine this clears the swapchain but leavesoptions.length = 2with zero buffers,reconfigure()return value, andnext()results intoCWaylandBuffer, which would also dereference a null buffer atbuffer->dmabuf()ifnext()ever returnednullptr.The result is a guaranteed
std::out_of_rangecrash on the first render attempt:Reproduced 100% of the time with hyprpolkitagent under niri on a fractional-scaled (150%) output.
Fix
In
IWaylandWindow::resizeSwapchain():reconfigure()return value and bail out on failure instead of proceeding with a stale swapchain,next()fornullptrbefore constructing aCWaylandBuffer(which would null-deref otherwise).After this, the previously guaranteed crash under niri + 150% fractional scaling is gone and the window renders/authenticates correctly.
Note: there is also an aquamarine-side inconsistency (the swapchain clearing branch leaves
options.length > 0with zero buffers), which I've fixed separately in hyprwm/aquamarine — see hyprwm/aquamarine#379. The two are independent: either one alone stops the crash, but both should hold the invariant.