Skip to content

fix: dpms cycle causes blurred wallpaper#176

Open
Anaethelion wants to merge 2 commits intodanyspin97:mainfrom
Anaethelion:fix/dpms_cycle_blurred_wallpaper
Open

fix: dpms cycle causes blurred wallpaper#176
Anaethelion wants to merge 2 commits intodanyspin97:mainfrom
Anaethelion:fix/dpms_cycle_blurred_wallpaper

Conversation

@Anaethelion
Copy link

When DPMS turns off and back on, the EGL context is recreated via check_context but no configure event follows. EglContext::new always created a 10x10 placeholder surface, so the wallpaper rendered at that size and was stretched — appearing blurred.

Fix: Use real display dimensions in EglContext::new when known. Assign the context before drawing and remove frame callback requests from error paths to prevent a tight error loop.

For context, here is the backtrace triggered by cycling dpms off/on:

ERROR [wpaperd::surface]
   0: Failed to draw on display DP-1
   1: Failed to draw the wallpaper
   2: Failed to swap EGL buffers
   3: Failed to draw the content of the GL buffer
   4: An Surface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 3 frames hidden ⋮
   4: wpaperd::render::egl_context::EglContext::draw::h2cfd419ad98f7a10
      at <unknown source file>:<unknown line>
   5: wpaperd::surface::Surface::try_drawing::h13784a2ae9118c8c
      at <unknown source file>:<unknown line>
   6: <core::slice::iter::IterMut<T> as core::iter::traits::iterator::Iterator>::for_each::hac05d0588b70c788
      at <unknown source file>:<unknown line>
   7: wpaperd::main::h2d7449a618b4ff0d
      at <unknown source file>:<unknown line>
   8: std::sys::backtrace::__rust_begin_short_backtrace::hddf1794ab0d6f4f6
      at <unknown source file>:<unknown line>
   9: std::rt::lang_start::{{closure}}::h1492e302212c8192
      at <unknown source file>:<unknown line>
  10: std::rt::lang_start_internal::hb84cc625940d332a
      at <unknown source file>:<unknown line>
  11: main<unknown>
      at <unknown source file>:<unknown line>
  12: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  13: _start<unknown>
      at <unknown source file>:<unknown line>

Tested on Hyprland 0.54.1 built from branch v0.54.1 at commit 4b07770b9ef1cceb2e6f56d33538aaffb9186b9c


This fix was developed with AI assistance (Claude), feel free to disregard and close.

@danyspin97
Copy link
Owner

Hello @Anaethelion and thank you for the PR! I now get the bug on NVIDIA drivers, but I am not sure about some changes, I'll comment more on the actual code. On a sidenote, there is also #177 that attempt to fix the same thing. Can you please give it a try and let me know if it works the same?

};

if display_info.is_configured() {
renderer
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we resizing after creating a surface with the correct size?

// callback here to avoid a tight error loop when the surface is
// temporarily invalid (e.g. after DPMS off/on).
self.context = None;
self.wl_surface.frame(qh, self.wl_surface.clone());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only schedule the compositor to call frame callback on this surface the next time it needs to be drawn. So calling it here shouldn't lead to a loop, I guess.

}

self.context = match EglContext::new(
match EglContext::new(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cosmetic change, not needed, imho.

@danyspin97
Copy link
Owner

I think we need both this PR and #177, as they fix different things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants