wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
10.07k stars 667 forks source link

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

Open xhebox opened 2 weeks ago

xhebox commented 2 weeks ago

A similar issue as in SDL, please check https://github.com/libsdl-org/SDL/pull/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 commented 2 weeks ago

What compositor is this happening with?

xhebox commented 2 weeks ago

What compositor is this happening with?

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

wolfpld commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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.