revery-ui / revery

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

feat(sdl2): bring back continuous resize patch #1077

Closed zbaylin closed 3 years ago

zbaylin commented 3 years ago

This seems to consistently work now (after #1072), and here is why I think that's the case:

Before, we would release the runtime lock before flushing events. These events would include things like mouse clicks, keyboard input, window resizes, etc. This meant that in the old patch, most resizes would require us to acquire the runtime lock since they were being "committed" in an event flush. However, last time we bumped up against a problematic resize: synchronous resizes, like Window.maximize. In this case, we already had the runtime lock when the event handler is called, so trying to acquire it again caused a deadlock.

Now we no longer release the runtime lock on event flushes 🎉. This means that in every case that we resize the window, the runtime lock is already acquired, so we don't have to acquire it.

@bryphe please let me know if you can think of another scenario where resizes would be triggered without the runtime lock, or if any of my reasoning sounds funny/wrong.

bryphe commented 3 years ago

Good idea to revisit this @zbaylin - 100% agree with your assessment, it should be safe now w/o the release/acquire dance around the PollEvent/WaitEvent.

Testing it (resizing the window, maximizing, etc) - seemed to work great!

I noticed one bug, though - the 'layer' in the canvas example seems to get stuck once the window is dragged below a minimum threshold: 2021-05-26 16 25 50

I wasn't able to reproduce this w/o the change here - although I'm guessing this is a bug with the layer/canvas and not the resize, but is being exacerbated by the higher frequency rendering.

bryphe commented 3 years ago

To follow up on my issue - I realized this isn't due to this change. In fact, it reproduces on Linux too which does smooth resizing even without this patch. So we shouldn't block this on that layer bug - seems like a separate issue.

Thanks for bringing this back @zbaylin - having the continuous resize is a big fit and finish improvement on OSX!