Skip to content

deltaMs includes time when the app is on the background #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mekutluca opened this issue Mar 28, 2025 · 0 comments · May be fixed by #341
Open

deltaMs includes time when the app is on the background #340

mekutluca opened this issue Mar 28, 2025 · 0 comments · May be fixed by #341

Comments

@mekutluca
Copy link

On Compose, when rendering particles, time is read from: withFrameMillis { frameMs ->
and deltaMs is calculated via val deltaMs = if (frameTime.value > 0) (frameMs - frameTime.value) else 0

I have emitter defined as Emitter(duration = 2000, TimeUnit.MILLISECONDS).perSecond(50)

While the particles are spawning, if you take the app to the background, wait for some time and come back, deltaMs would also include the time in the background. Let's say the app was in the background for 60 seconds. After we launch the app, it will create 60 * 50 = 3000 new particles. The greater the wait time, the more particle creation occurs. This causes ANR on some occasions.

I'd suggest either don't include the time when the app is on the background, or set default max particle as 2 * 50 = 100 in this example.

P.S. changing emitter does not respect max configuration either. Emitter(duration = 2000, TimeUnit.MILLISECONDS).perSecond(50).max(100) won't work.

@mekutluca mekutluca linked a pull request Apr 2, 2025 that will close this issue
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 a pull request may close this issue.

1 participant