Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_viewport@33: error 2: source rectangle out of buffer bounds #905

Open
xhebox opened this issue Oct 7, 2024 · 6 comments
Open

wp_viewport@33: error 2: source rectangle out of buffer bounds #905

xhebox opened this issue Oct 7, 2024 · 6 comments

Comments

@xhebox
Copy link
Contributor

xhebox commented Oct 7, 2024

A similar issue as in SDL, please check libsdl-org/SDL#9285

EDIT: I don't read the source carefully, but the following patch worked:

--- a/profiler/src/BackendWayland.cpp	2024-07-17 00:38:15.000000000 +0800
+++ b/profiler/src/BackendWayland.cpp	2024-07-17 00:38:15.000000000 +0800
@@ -770,6 +771,8 @@
         s_fracSurf = wp_fractional_scale_manager_v1_get_fractional_scale( s_fractionalScale, s_surf );
         wp_fractional_scale_v1_add_listener( s_fracSurf, &fractionalListener, nullptr );
         s_viewport = wp_viewporter_get_viewport( s_viewporter, s_surf );
+				wp_viewport_set_source( s_viewport, 0, 0, -1, -1);
+				//wl_fixed_from_double( s_width * s_maxScale / 120. ), wl_fixed_from_double( s_height * s_maxScale / 120. ) );
     }
 
     SetupCursor();
@@ -918,7 +921,6 @@
         wl_egl_window_resize( s_eglWin, s_width * s_maxScale / 120, s_height * s_maxScale / 120, 0, 0 );
         if( s_fracSurf )
         {
-            wp_viewport_set_source( s_viewport, 0, 0, wl_fixed_from_double( s_width * s_maxScale / 120. ), wl_fixed_from_double( s_height * s_maxScale / 120. ) );
             wp_viewport_set_destination( s_viewport, s_width, s_height );
         }
     }
@wolfpld
Copy link
Owner

wolfpld commented Oct 7, 2024

What compositor is this happening with?

@xhebox
Copy link
Contributor Author

xhebox commented Oct 7, 2024

What compositor is this happening with?

Hyprland 0.44.0 will report wp_viewport#16: error 0: Box doesn't fit

@wolfpld
Copy link
Owner

wolfpld commented Oct 7, 2024

The change as proposed is invalid, as it breaks the protocol. If it works on Hyprland, then the compositor is badly implemented.

If all of x, y, width and height are -1.0, the source rectangle is unset instead. Any other set of values where width or height are zero or negative, or x or y are negative, raise the bad_value protocol error.

Either way the source viewport size is set for a reason and removing it breaks things.

The error value you get doesn't make much sense in context of what the protocol describes.

bad_value (0) - negative or zero values in width or height

@xhebox
Copy link
Contributor Author

xhebox commented Oct 7, 2024

Either way the source viewport size is set for a reason and removing it breaks things.

Got.

After some experiments, I think you are right. But the real problem may be Fractional scaling. If I set hiDPI to 2.0 instead of 1.6, the following patch will also work:

--- a/profiler/src/BackendWayland.cpp	2024-07-17 00:38:15.000000000 +0800
+++ b/profiler/src/BackendWayland.cpp	2024-07-17 00:38:15.000000000 +0800
@@ -770,6 +771,7 @@
         s_fracSurf = wp_fractional_scale_manager_v1_get_fractional_scale( s_fractionalScale, s_surf );
         wp_fractional_scale_v1_add_listener( s_fracSurf, &fractionalListener, nullptr );
         s_viewport = wp_viewporter_get_viewport( s_viewporter, s_surf );
+       wp_viewport_set_source( s_viewport, 0, 0, wl_fixed_from_double( s_width * s_maxScale / 120. ), wl_fixed_from_double( s_height * s_maxScale / 120. ) );
     }
 
     SetupCursor();

Without this line, wp_viewport#16: error 0: Box doesn't fit will be reported. This shows that call position of wp_viewport_set_source does matter.

EDIT: BTW, I initially got this error with Hyprland 0.38, in which wlroots is still used. That should be identical to an old-versioned sway.

@wolfpld
Copy link
Owner

wolfpld commented Oct 7, 2024

I initially got this error with Hyprland 0.38, in which wlroots is still used. That should be identical to an old-versioned sway.

This error message was never in wlroots. It's coming from hyprland.

@xhebox
Copy link
Contributor Author

xhebox commented Oct 7, 2024

I initially got this error with Hyprland 0.38, in which wlroots is still used. That should be identical to an old-versioned sway.

This error message was never in wlroots. It's coming from hyprland.

I mean this source rectangle out of buffer bounds, which is from wlroots. I met this with 0.38.

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

No branches or pull requests

2 participants