revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.07k stars 197 forks source link

fix(linux): Fix crash on resize with wayland #1083

Closed bryphe closed 3 years ago

bryphe commented 3 years ago

Issue: Revery / Onivim can crash when starting under wayland.

From Revery, this can be reproduced by running under sway and running the example with:

SDL_VIDEODRIVER=wayland esy '@examples' run

The application will hang after the first couple renders. Same issue as described in: https://github.com/onivim/oni2/issues/3646

Defect: Based on my testing - it seems this is a regression from https://github.com/revery-ui/revery/pull/1077 However, in pulling the callstack from the hanging app, the application is hanging when trying to re-acquire the runtime after calling SDL_GL_SwapWindows. My hypothesis is that there is a timing issue - the time where those SDL_AddEventWatcher events are dispatched might be different per platform, and could be being dispatched while the runtime lock isn't acquired, which would cause a variety of problems like this hang.

Fix: Scope the AddEventWatcher addition to OSX, where it was more thoroughly tested. A further fix may be to remove the release/acquire runtime aroud the swap windows call.