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

wayland cannot work with weston #90612

Closed
Tracked by #88346
Roogephy opened this issue Apr 13, 2024 · 8 comments · Fixed by #91196
Closed
Tracked by #88346

wayland cannot work with weston #90612

Roogephy opened this issue Apr 13, 2024 · 8 comments · Fixed by #91196

Comments

@Roogephy
Copy link

Tested versions

Godot Engine v4.3.dev4.official.df78c0636 - https://godotengine.org/

System information

ubuntu 2204 with weston

Issue description

cannot open edit with weston, cmdline out is:
`Godot Engine v4.3.dev4.official.df78c0636 - https://godotengine.org/
WARNING: Can't obtain the XDG decoration manager. Libdecor will be used for drawing CSDs, if available.
at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3493)
WARNING: Can't obtain the XDG activation global. Attention requesting won't work!
at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3500)
wl_registry@2: error 0: invalid version for global xdg_wm_base (22): have 1, wanted 2
ERROR: Wayland protocol error 0 on interface wl_registry@2.
at: _poll_events_thread (platform/linuxbsd/wayland/wayland_thread.cpp:2540)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.3.dev4.official (df78c06)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f3a4fa42520] (??:0)
[2] godot4_3() [0x47e587] (??:0)
[3] godot4_3() [0x3c9fbe5] (??:0)
[4] godot4_3() [0x48e4963] (??:0)
[5] /lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7f3a4fa94ac3] (??:0)
[6] /lib/x86_64-linux-gnu/libc.so.6(+0x126850) [0x7f3a4fb26850] (??:0)
-- END OF BACKTRACE --
================================================================`

Steps to reproduce

  1. run weston
  2. in weston window, open a terminal, type:
    godot --display-driver wayland
    3.it crashes

Minimal reproduction project (MRP)

no

@Roogephy
Copy link
Author

roogephy@roogephy-ThinkBook-16-G5-IRH:~$ weston
Date: 2024-04-13 CST
[15:49:47.683] weston 9.0.0
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 9.0.0
[15:49:47.683] Command line: weston
[15:49:47.683] OS: Linux, 6.5.0-27-generic, #28~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 15 10:51:06 UTC 2, x86_64
[15:49:47.683] Starting with no config file.
[15:49:47.683] Output repaint window is 7 ms maximum.
[15:49:47.684] Loading module '/usr/lib/x86_64-linux-gnu/libweston-9/wayland-backend.so'
[15:49:47.711] Loading module '/usr/lib/x86_64-linux-gnu/libweston-9/gl-renderer.so'
[15:49:47.716] EGL client extensions: EGL_EXT_device_base
               EGL_EXT_device_enumeration EGL_EXT_device_query
               EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses
               EGL_EXT_client_extensions EGL_KHR_debug EGL_EXT_platform_device
               EGL_EXT_platform_wayland EGL_KHR_platform_wayland
               EGL_EXT_platform_x11 EGL_KHR_platform_x11 EGL_EXT_platform_xcb
               EGL_MESA_platform_gbm EGL_KHR_platform_gbm
               EGL_MESA_platform_surfaceless
[15:49:47.745] EGL version: 1.5
[15:49:47.745] EGL vendor: Mesa Project
[15:49:47.745] EGL client APIs: OpenGL OpenGL_ES 
[15:49:47.745] EGL extensions: EGL_ANDROID_blob_cache
               EGL_ANDROID_native_fence_sync EGL_EXT_buffer_age
               EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import
               EGL_EXT_image_dma_buf_import_modifiers
               EGL_EXT_protected_content EGL_EXT_present_opaque
               EGL_EXT_swap_buffers_with_damage EGL_IMG_context_priority
               EGL_KHR_cl_event2 EGL_KHR_config_attribs
               EGL_KHR_context_flush_control EGL_KHR_create_context
               EGL_KHR_create_context_no_error EGL_KHR_fence_sync
               EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace
               EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image
               EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image
               EGL_KHR_image_base EGL_KHR_no_config_context
               EGL_KHR_reusable_sync EGL_KHR_surfaceless_context
               EGL_KHR_swap_buffers_with_damage EGL_EXT_pixel_format_float
               EGL_KHR_wait_sync EGL_MESA_configless_context
               EGL_MESA_drm_image EGL_MESA_image_dma_buf_export
               EGL_MESA_query_driver EGL_WL_bind_wayland_display
               EGL_WL_create_wayland_buffer_from_image
[15:49:47.745] EGL_KHR_surfaceless_context available
[15:49:47.746] GL version: OpenGL ES 3.2 Mesa 23.2.1-1ubuntu3.1~22.04.2
[15:49:47.746] GLSL version: OpenGL ES GLSL ES 3.20
[15:49:47.746] GL vendor: Intel
[15:49:47.746] GL renderer: Mesa Intel(R) Graphics (RPL-P)
[15:49:47.746] GL extensions: GL_EXT_blend_minmax GL_EXT_multi_draw_arrays
               GL_EXT_texture_filter_anisotropic
               GL_EXT_texture_compression_s3tc GL_EXT_texture_compression_dxt1
               GL_EXT_texture_compression_rgtc GL_EXT_texture_format_BGRA8888
               GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24
               GL_OES_element_index_uint GL_OES_fbo_render_mipmap
               GL_OES_mapbuffer GL_OES_rgb8_rgba8 GL_OES_standard_derivatives
               GL_OES_stencil8 GL_OES_texture_3D GL_OES_texture_float
               GL_OES_texture_float_linear GL_OES_texture_half_float
               GL_OES_texture_half_float_linear GL_OES_texture_npot
               GL_OES_vertex_half_float GL_EXT_draw_instanced
               GL_EXT_texture_sRGB_decode GL_OES_EGL_image
               GL_OES_depth_texture GL_AMD_performance_monitor
               GL_OES_packed_depth_stencil GL_EXT_texture_type_2_10_10_10_REV
               GL_NV_conditional_render GL_OES_get_program_binary
               GL_APPLE_texture_max_level GL_EXT_discard_framebuffer
               GL_EXT_read_format_bgra GL_NV_pack_subimage GL_EXT_frag_depth
               GL_NV_fbo_color_attachments GL_OES_EGL_image_external
               GL_OES_EGL_sync GL_OES_vertex_array_object
               GL_OES_viewport_array GL_ANGLE_pack_reverse_row_order
               GL_ANGLE_texture_compression_dxt3
               GL_ANGLE_texture_compression_dxt5
               GL_EXT_occlusion_query_boolean GL_EXT_robustness
               GL_EXT_texture_rg GL_EXT_unpack_subimage GL_NV_draw_buffers
               GL_NV_read_buffer GL_NV_read_depth GL_NV_read_depth_stencil
               GL_NV_read_stencil GL_EXT_draw_buffers GL_EXT_instanced_arrays
               GL_EXT_map_buffer_range GL_KHR_debug GL_KHR_robustness
               GL_KHR_texture_compression_astc_ldr GL_NV_generate_mipmap_sRGB
               GL_NV_pixel_buffer_object GL_OES_depth_texture_cube_map
               GL_OES_required_internalformat GL_OES_surfaceless_context
               GL_EXT_color_buffer_float GL_EXT_debug_label
               GL_EXT_sRGB_write_control GL_EXT_separate_shader_objects
               GL_EXT_shader_framebuffer_fetch GL_EXT_shader_group_vote
               GL_EXT_shader_implicit_conversions GL_EXT_shader_integer_mix
               GL_EXT_tessellation_point_size GL_EXT_tessellation_shader
               GL_INTEL_conservative_rasterization GL_INTEL_performance_query
               GL_ANDROID_extension_pack_es31a GL_EXT_base_instance
               GL_EXT_compressed_ETC1_RGB8_sub_texture GL_EXT_copy_image
               GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex
               GL_EXT_gpu_shader5 GL_EXT_polygon_offset_clamp
               GL_EXT_primitive_bounding_box GL_EXT_render_snorm
               GL_EXT_shader_io_blocks GL_EXT_texture_border_clamp
               GL_EXT_texture_buffer GL_EXT_texture_cube_map_array
               GL_EXT_texture_norm16 GL_EXT_texture_view
               GL_KHR_blend_equation_advanced
               GL_KHR_blend_equation_advanced_coherent
               GL_KHR_context_flush_control
               GL_KHR_robust_buffer_access_behavior GL_NV_image_formats
               GL_NV_shader_noperspective_interpolation GL_OES_copy_image
               GL_OES_draw_buffers_indexed GL_OES_draw_elements_base_vertex
               GL_OES_gpu_shader5 GL_OES_primitive_bounding_box
               GL_OES_sample_shading GL_OES_sample_variables
               GL_OES_shader_io_blocks GL_OES_shader_multisample_interpolation
               GL_OES_tessellation_point_size GL_OES_tessellation_shader
               GL_OES_texture_border_clamp GL_OES_texture_buffer
               GL_OES_texture_cube_map_array GL_OES_texture_stencil8
               GL_OES_texture_storage_multisample_2d_array GL_OES_texture_view
               GL_EXT_blend_func_extended GL_EXT_buffer_storage
               GL_EXT_float_blend GL_EXT_geometry_point_size
               GL_EXT_geometry_shader GL_EXT_shader_samples_identical
               GL_EXT_texture_sRGB_R8 GL_KHR_no_error
               GL_KHR_texture_compression_astc_sliced_3d
               GL_NV_fragment_shader_interlock GL_OES_EGL_image_external_essl3
               GL_OES_geometry_point_size GL_OES_geometry_shader
               GL_OES_shader_image_atomic GL_EXT_clear_texture
               GL_EXT_clip_cull_distance GL_EXT_disjoint_timer_query
               GL_EXT_texture_compression_s3tc_srgb
               GL_MESA_shader_integer_functions GL_EXT_clip_control
               GL_EXT_color_buffer_half_float GL_EXT_memory_object
               GL_EXT_memory_object_fd GL_EXT_semaphore GL_EXT_semaphore_fd
               GL_EXT_texture_compression_bptc
               GL_EXT_texture_mirror_clamp_to_edge
               GL_KHR_parallel_shader_compile
               GL_NV_alpha_to_coverage_dither_control GL_EXT_EGL_image_storage
               GL_EXT_shader_framebuffer_fetch_non_coherent
               GL_EXT_texture_shadow_lod GL_INTEL_blackhole_render
               GL_MESA_framebuffer_flip_y GL_NV_compute_shader_derivatives
               GL_EXT_demote_to_helper_invocation GL_EXT_depth_clamp
               GL_EXT_texture_query_lod GL_MESA_bgra
[15:49:47.746] GL ES 2 renderer features:
               read-back format: BGRA
               wl_shm sub-image to texture: yes
               EGL Wayland extension: yes
[15:49:47.746] Registered plugin API 'weston_windowed_output_api_v1' of size 16
[15:49:47.746] Creating 1024x640 wayland output at (0, 0)
[15:49:47.750] wayland-backend: Using xdg_wm_base
[15:49:47.751] Chosen EGL config details: id:  41 rgba: 8 8 8 8 buf: 32 dep:  0 stcl: 0 int: 0-1 type: win vis_id: 0
[15:49:47.759] Output 'wayland0' enabled with head(s) wayland0
[15:49:47.759] Compositor capabilities:
               arbitrary surface rotation: yes
               screen capture uses y-flip: yes
               presentation clock: CLOCK_MONOTONIC_RAW, id 4
               presentation clock resolution: 0.000000001 s
[15:49:47.759] libwayland: unable to lock lockfile /run/user/1000/wayland-0.lock, maybe another compositor is running
[15:49:47.759] Loading module '/usr/lib/x86_64-linux-gnu/weston/desktop-shell.so'
[15:49:47.760] launching '/usr/lib/x86_64-linux-gnu/weston-keyboard'
[15:49:47.764] launching '/usr/lib/x86_64-linux-gnu/weston-desktop-shell'
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown parameter: ?2004
picked entry 1
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown parameter: ?2004
picked entry 2
Unknown parameter: ?2004
[15:52:06.743] libwayland: error in client communication (pid 25808)
Unknown parameter: ?2004
picked entry 1
picked entry 1

above is weston out put

@Riteo
Copy link
Contributor

Riteo commented Apr 25, 2024

All right. I've taken a look at it, collected some data and I'm working on a fix. I'll try to explain the situation in short.

For context, to implement certain features, we need to load certain extensions (named "protocols" in Wayland jargon).

Currently, we load only very specific versions of them and bail out when we can't find some of them, while we should instead be as flexible as possible. For example, certain extensions aren't strictly needed to play, e.g. a platformer game, so we should not error out, or we might get an older protocol that does not implement everything that we want and we should instead handle the situation more gracefully.

I was already aware of this issue, but I didn't either have the time or had other priorities. Now that the backend is (mostly) working I had a chance to look at it into detail.

Here follows the list of interfaces ("globals") that get accepted by the client, along with whether we bail out or not, in rough order of importance:

Object Name Minimum Version Accepted Maximum Version Implemented Mandatory? Notes
wl_compositor 4 4 y surface creation
xdg_wm_base 2 6 y desktop windows
wl_shm 1 1 y cursor buffer handling
wl_data_device_manager 3 3 y clipboard and drag&drop
wl_subcompositor 1 1 y useless, to be removed
wl_output 2 2 n screen info, can be registered multiple times
wl_seat 5 5 n basic input, can be registered multiple times
wp_viewporter 1 1 n buffer "stretching", fractional scaling dependency
wp_fractional_scale_manager_v1 1 1 n fractional scaling
zwp_primary_selection_device_manager_v1 1 1 n primary clipboard
zwp_pointer_constraints_v1 1 1 y pointer constraints
zwp_relative_pointer_manager_v1 1 1 n relative pointer input, especially useful when paired with pointer constraints
zwp_pointer_gestures_v1 1 1 n touchpad gestures
zwp_tablet_manager_v2 1 1 n drawing tablet support
zxdg_decoration_manager_v1 1 1 n manual server-side decorations handling (libdecor-less fallback)
zxdg_activation_v1 1 1 n attention requesting
zwp_idle_inhibit_manager_v1 1 1 n idle inibition (non-GNOME)
zxdg_exporter_v1 1 1 n dbus desktop integration, stored in the backend's code as wl_exporter

Note: extensions newer than the max version load fine but any new features are obviously non-working.

Taking a look at this list, it becomes more obvious why you get this error:

wl_registry@2: error 0: invalid version for global xdg_wm_base (22): have 1, wanted 2 

I'll push a PR soon to lower the requirement for all globals (adding any compatibility code as needed), making the list of mandatory protocols as small as possible (zwp_pointer_constraints_v1 sticks out in particular) and remove the wl_subcompositor leftover.

Thank you for your patience.

@Riteo
Copy link
Contributor

Riteo commented Apr 26, 2024

All right, I pushed a fix as PR #91196. @Roogephy, could you please try it and confirm whether it fixes the issue you're having?

@akien-mga akien-mga added this to the 4.3 milestone Apr 29, 2024
@Riteo
Copy link
Contributor

Riteo commented Apr 29, 2024

Well, the PR got merged. I can now run the engine on Weston so I'll consider the issue fixed but if it isn't the case for you, please let me know, I'd be glad to help further :D

@Roogephy
Copy link
Author

Roogephy commented Apr 30, 2024

Great news, the new code is now working under Weston with Wayland. The window is successfully displayed without any errors related to Wayland. However, since my board only supports OpenGL ES 3.2, I'm unable to run a particular demo. Next, I need to investigate how to switch to OpenGL ES under Wayland's driver. Of course, that's another issue altogether. Does anyone have any good suggestions on this?

Godot Engine v4.3.dev.custom_build.89850d553 (2024-04-29 13:20:42 UTC) - https://godotengine.org
wl_registry_on_global wl_subcompositor
wl_registry_on_global wl_compositor
wl_registry_on_global wp_viewporter
wl_registry_on_global zxdg_output_manager_v1
wl_registry_on_global wp_presentation
wl_registry_on_global zwp_relative_pointer_manager_v1
wl_registry_on_global zwp_pointer_constraints_v1
wl_registry_on_global zwp_input_timestamps_manager_v1
wl_registry_on_global wl_data_device_manager
wl_registry_on_global wl_shm
wl_registry_on_global wl_drm
wl_registry_on_global wl_seat
wl_registry_on_global zwp_linux_dmabuf_v1
wl_registry_on_global zwp_linux_explicit_synchronization_v1
wl_registry_on_global wl_output
wl_registry_on_global wl_output
wl_registry_on_global wl_output
wl_registry_on_global wl_output
wl_registry_on_global zwp_input_panel_v1
wl_registry_on_global zwp_input_method_v1
wl_registry_on_global zwp_text_input_manager_v1
wl_registry_on_global xdg_wm_base
wl_registry_on_global zxdg_shell_v6
wl_registry_on_global wl_shell
wl_registry_on_global weston_desktop_shell
wl_registry_on_global weston_screenshooter
WARNING: Can't obtain the XDG decoration manager. Libdecor will be used for drawing CSDs, if available.
     at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3559)
WARNING: Can't obtain the XDG activation global. Attention requesting won't work!
     at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3566)
libdecor-0.so.0: cannot open shared object file: No such file or directory
libspeechd.so.2: cannot open shared object file: No such file or directory
1: #version 330
2: #define USE_GLES_OVER_GL
3: 
4: #define MODE_SIMPLE_COPY
5: 
6: #ifdef USE_MULTIVIEW
7: #if defined(GL_OVR_multiview2)
8: #extension GL_OVR_multiview2 : require
9: #elif defined(GL_OVR_multiview)
10: #extension GL_OVR_multiview : require
11: #endif
12: layout(num_views=2) in;
13: #define ViewIndex gl_ViewID_OVR
14: #define MAX_VIEWS 2
15: #else
16: #define ViewIndex uint(0)
17: #define MAX_VIEWS 1
18: #endif
19: precision highp float;
20: precision highp int;
21: 
22: layout(location = 0) in vec2 vertex_attrib;
23: 
24: out vec2 uv_interp;
25: /* clang-format on */
26: 
27: #if defined(USE_COPY_SECTION) || defined(MODE_GAUSSIAN_BLUR)
28: // Defined in 0-1 coords.
29: uniform highp vec4 copy_section;
30: #endif
31: #if defined(MODE_GAUSSIAN_BLUR) || defined(MODE_COPY_FROM)
32: uniform highp vec4 source_section;
33: #endif
34: 
35: void main() {
36: 	uv_interp = vertex_attrib * 0.5 + 0.5;
37: 	gl_Position = vec4(vertex_attrib, 1.0, 1.0);
38: 
39: #if defined(USE_COPY_SECTION) || defined(MODE_GAUSSIAN_BLUR)
40: 	gl_Position.xy = (copy_section.xy + uv_interp.xy * copy_section.zw) * 2.0 - 1.0;
41: #endif
42: #if defined(MODE_GAUSSIAN_BLUR) || defined(MODE_COPY_FROM)
43: 	uv_interp = source_section.xy + uv_interp * source_section.zw;
44: #endif
45: }
46: 
47: /* clang-format off */
48: 
49: 
ERROR: CopyShaderGLES3: Vertex shader compilation failed:
Compile failed.
ERROR: 0:1: Syntax error, version 330 not supported
1 compilation errors. No code generated.


   at: _display_error_with_code (drivers/gles3/shader_gles3.cpp:253)
ERROR: Method/function failed.
   at: _compile_specialization (drivers/gles3/shader_gles3.cpp:347)

@akien-mga
Copy link
Member

We should now actually support OpenGL ES on Linux desktop too, but I'm not sure it's selected automatically if needed.

On the other hand, it doesn't seem to be exposed for Wayland, only X11, which might be an oversight? @Riteo

  --display-driver <driver>         R  Display driver (and rendering driver) ["x11" ("vulkan", "opengl3", "opengl3_es"), "wayland" ("vulkan", "opengl3"), "headless" ("dummy")].

Interestingly, despite not being listed as an option for wayland, godot --display-driver wayland --rendering-driver opengl3_es is recognized, but it segfaults:

#0  0x0000000000000000 in ?? ()
#1  0x0000000009afe4bb in RendererCompositor::create () at ./servers/rendering/renderer_compositor.cpp:42
#2  0x0000000009b7bf67 in RenderingServerDefault::RenderingServerDefault (this=0xb93a0b0, p_create_thread=false) at ./servers/rendering/rendering_server_default.cpp:404
#3  0x0000000005b2cec5 in Main::setup2 () at main/main.cpp:2775
#4  0x0000000005b2b159 in Main::setup (execpath=0x7fffffffdb8f "/home/akien/.local/bin/godot-git", argc=4, argv=0x7fffffffd700, p_second_phase=true) at main/main.cpp:2428
#5  0x0000000005a78065 in main (argc=5, argv=0x7fffffffd6f8) at platform/linuxbsd/godot_linuxbsd.cpp:74

On the other hand it works with x11:

$ godot-git --display-driver x11 --rendering-driver opengl3_es
Godot Engine v4.3.dev.custom_build.89850d553 (2024-04-29 13:20:42 UTC) - https://godotengine.org
OpenGL API OpenGL ES 3.2 Mesa 24.0.5 - Compatibility - Using Device: AMD - AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 18.1.1, DRM 3.57, 6.8.7-300.1.copr.fc40.x86_64)

@Riteo
Copy link
Contributor

Riteo commented Apr 30, 2024

On the other hand, it doesn't seem to be exposed for Wayland, only X11, which might be an oversight? @Riteo

Yup, indeed. It got added later and I didn't realize for some reason that it had to be plumbed in by Wayland too. Shouldn't take too much.

Perhaps a new ticket might be useful, as I look at the tracker for big things to do, if I'm not misusing it :P

@akien-mga
Copy link
Member

Done: #91371

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

Successfully merging a pull request may close this issue.

4 participants