wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

EGL `create_surface` is unsound

Open mahkoh opened this issue 1 year ago • 1 comments

See https://github.com/gfx-rs/wgpu/blob/434f1974101daf26dc3fd15c1a356738d6720bff/wgpu-hal/src/gles/egl.rs#L938-L942

This function does not actually use the display_handle. However, the window_handle is only valid if used together with the display_handle.

For wayland, the code destroys the current context (on the first use). However, at that point the context has already been cloned into different objects that will continue to use it. The same happens if this function is ever called with two different display handles.

mahkoh avatar Sep 17 '24 13:09 mahkoh

This sounds very closely related to all the details outlined in #5505 and #6211 which all cover lack of proper usage of RawDisplayHandle to some extent, and papering over it with gems like https://github.com/gfx-rs/wgpu/blob/6f16ea460ab437173e14d2f5f3584ca7e1c9841d/wgpu-hal/src/gles/egl.rs#L935-L979 :)

MarijnS95 avatar Sep 25 '24 08:09 MarijnS95

Closing in favor of those issues

cwfitzgerald avatar Jan 11 '25 09:01 cwfitzgerald

Thanks @cwfitzgerald. Would be awesome to start tackling those issues, if there's sign-off to delete the current atrocity and rewrite it with glutin :grin:

MarijnS95 avatar Jan 11 '25 18:01 MarijnS95

Yeah if you can pull it off such that it works with our api, less code to maintain would be lovely!

cwfitzgerald avatar Jan 11 '25 19:01 cwfitzgerald