britzl / monarch

Monarch is a Defold screen manager with transition support and a straight forward API
MIT License
157 stars 22 forks source link

Asynchronous window sliding #91

Open Morgerion opened 1 year ago

Morgerion commented 1 year ago

Thanks to the upgraded monarch, I was able to make sliding windows.

https://user-images.githubusercontent.com/7888071/230682291-110c84e1-4e7c-4326-ba30-35fd7efe2bab.mp4

... But the following problem has come to light - the windows slide unevenly. You can see it in the video if you look closely. This can also be seen in the screenshots: Скриншот 2023-04-08 00 21 13 Скриншот 2023-04-08 00 21 26

Apparently, for some windows, the transition is triggered a couple of frames later. This could be remedied by passing some sort of start time to all transitions, and compensating the delay via a negative delay in the gui.animation().

Morgerion commented 1 year ago

This effect is very noticeable on the mobile: https://www.dropbox.com/s/poa3dee3kpvclm8/20230408_022714.mp4?dl=0

Morgerion commented 1 year ago

I was able to get rid of the background shift when sliding. I had to do some trickery with skipping frames before animation, but now it's stable. :) However, when it comes to the GUI specifically, it still lags:

https://user-images.githubusercontent.com/7888071/230740177-48e3268b-5503-48c0-b69c-32e9ee04d9fa.mp4

The fact is that the middle window consists of two entities - the 3D scene and the GUI itself. I slide the 3D scene into the background on its own, and there is no problem here. But there is still a delay with the GUI sliding, and it is clearly within Monarch.

britzl commented 1 year ago

I'm not sure if/how to solve this with the current design in Monarch. I can take one final look if you can prepare a minimal project where this problem can be seen. The other solution is to not use Monarch for the problematic screens or for those kinds of transitions.

Morgerion commented 1 year ago

here's the project: __test_slide_GUI.zip

and here's a video (from this project) that shows where the lag in synchronization is noticeable:

https://github.com/britzl/monarch/assets/7888071/a50e2758-7308-4ab9-bc00-ddc1f3e37d17

Morgerion commented 1 year ago

Let's say we always have two windows when sliding:

This problem can be solved without using the standard transitions from monarch. But even in this case you will have to manage the delay of 1 frame on PC and 2 frames on mobile devices (i don't know why this happens).