I don't know nearly enough about wlroots to understand this bug, but in the meantime adding this hack inside of gles2_get_renderer_in_context at least prevents the crash. I'm sure the actual fix is elsewhere though as gles2_get_renderer_in_context is supposed to assume the context is already current, right?
if(!wlr_egl_is_current(renderer->egl)) {
wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL);
}
function calls leading up to the crash:
wlr_output_cursor_set_surface -> drm_connector_set_cursor -> drm_fb_lock_surface -> drm_surface_unset_current -> wlr_renderer_bind_buffer -> gles2_bind_buffer -> gles2_get_renderer_in_context
FWIW I see the assert only when external monitors are connected.
I can create a pull request if this is a satisfactory solution. Even with this change, I still get freezes from time to time when hotplugging external monitors. Not sure if that is related to this or some other change. (I haven't kept up with more recent changes to wlroots/sawy as I've not been using sway on a daily basis because of this issue.)
drm_surface_unset_current must only be called after making the surface current. Apparently that's not the case here.
Can you try https://github.com/swaywm/wlroots/pull/2520?