JagandeepBrar / lunasea

Self-hosted software controller built using Flutter
https://www.lunasea.app
GNU General Public License v3.0
1.28k stars 63 forks source link

[Bug] Jank on Animations After Initial Launch #242

Closed JagandeepBrar closed 2 years ago

JagandeepBrar commented 4 years ago

After the initial launch, the application can appear to be "janky". The first time you run some animations, such as popup menus or dialogs, the animations are not smooth. This is an issue with the Skia Shader Language (SkSL) shader warm-up.

On Android, the shaders are cached after the first install so the jank shouldn't occur after the first usage. On iOS however, shaders are not cached which means that LunaSea can appear janky on any fresh launch where the shaders have not been warmed up.

Need to consider adding SkSL warmup for devices: https://flutter.dev/docs/perf/rendering/shader

Main problem is that newer iOS devices that run metal currently do not support shader warm-ups. Could consider disabling metal rendering and fallback to OpenGL rendering which will allow for shader warm-up, but in turn will have a performance dip and higher CPU/GPU usage for devices.

viggy96 commented 4 years ago

For me, animations are always "janky" so to speak, even if I've been using the app for a while.

JagandeepBrar commented 4 years ago

@viggy96 Thanks for the feedback, can I ask what device & version you are currently running? From my experience once the animations have been "warmed up," the application stutters very rarely but I do have the latest iPhone & iPad as test devices. The application also rarely stutters once warmed-up on Android from my experience with a Moto G6 Play, which is a relatively low-tier device.

viggy96 commented 4 years ago

@JagandeepBrar I'm using a Moto X4, with Android 10.

JagandeepBrar commented 3 years ago

A follow-up on this, after a long period of time: The Flutter is currently working on integrating Metal Binary Archives which will allow for pre-compiled shaders to be added to the build, to heavily reduce (or potentially completely eliminate) the shader jank that occurs.

Because LunaSea becomes smooth after the animations have been triggered a few times, it is not a problem with LunaSea itself, but with the framework and sadly there isn't any intermediate solution. They hoped to have this implemented before the winter break (but that did not happen), so I am hoping that it drops in the near future!

JagandeepBrar commented 3 years ago

Now that Flutter has proper support for compiling with precompiled shaders on devices utilizing Apple's Metal API, the release after v5.0.0 will likely include precompiled shaders to heavily improve the first launch experience (especially on iOS)!

Currently the change has not hit any of the development channels except for master, but hopefully it reaches beta and/or dev in the near future!

JagandeepBrar commented 2 years ago

This has been mostly fixed now that LunaSea is compiled with iOS and Android prebuilt SkSL shaders.