Skip to content

Making LavaBeats shader time relative to the STARTED lifecycle state - #434

Open
JuanSMartinez wants to merge 1 commit into
android:mainfrom
JuanSMartinez:lavabeats-timefix
Open

Making LavaBeats shader time relative to the STARTED lifecycle state#434
JuanSMartinez wants to merge 1 commit into
android:mainfrom
JuanSMartinez:lavabeats-timefix

Conversation

@JuanSMartinez

Copy link
Copy Markdown
Contributor

Making LavaBeats shader time relative to the STARTED lifecycle state

This makes sure that the runtime shader time is always relative to the lifecycle of the app, avoiding the storage of very large numbers over time as the device is left on for a long period of time. The latter makes the effect laggy and janky due to computations with large numbers

This makes sure that the shader time is always relative to the lifecycle
of the app, avoiding the storage of very large numbers over time as the
device is left on for a long period of time. The latter makes the effect
laggy and janky due to computations with large numbers
} else {
time = frameTime / 1000f - firstTime
LaunchedEffect(lifecycleOwner) {
lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using RESUMED state instead?

@JuanSMartinez JuanSMartinez Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this at first, but because RESUME occurs later, this resulted in a visible pause between the UI rendering and the animation actually starting. It is mostly a visual preference, as the most important part is to let the time reset once the user leaves the app. If RESUME gives us more performance benefits I could do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants