Skip to content
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

Fatal Exception: java.lang.OutOfMemoryError #304

Open
NKosyanchuk opened this issue Dec 16, 2022 · 4 comments
Open

Fatal Exception: java.lang.OutOfMemoryError #304

NKosyanchuk opened this issue Dec 16, 2022 · 4 comments

Comments

@NKosyanchuk
Copy link

Hi, faced with crash while using compose version of lib:

Fatal Exception: java.lang.OutOfMemoryError
Failed to allocate a 96 byte allocation with 916176 free bytes and 894KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC.

Here is full stacktrace:

android.graphics.drawable.VectorDrawable.mutate (VectorDrawable.java:389)
**nl.dionsegijn.konfetti.core.emitter.PartyEmitter.getRandomShape (PartyEmitter.kt:160)**
nl.dionsegijn.konfetti.core.emitter.PartyEmitter.createParticle (PartyEmitter.kt:79)
nl.dionsegijn.konfetti.core.emitter.PartyEmitter.createConfetti (PartyEmitter.kt:56)
nl.dionsegijn.konfetti.core.PartySystem.render (PartySystem.kt:32)
nl.dionsegijn.konfetti.compose.KonfettiViewKt$KonfettiView$1$2.invoke (KonfettiView.kt:63)
nl.dionsegijn.konfetti.compose.KonfettiViewKt$KonfettiView$1$2.invoke (KonfettiView.kt:45)
androidx.compose.runtime.MonotonicFrameClockKt$withFrameMillis$2.invoke (MonotonicFrameClock.kt:66)
androidx.compose.runtime.MonotonicFrameClockKt$withFrameMillis$2.invoke (MonotonicFrameClock.kt:66)
androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume (BroadcastFrameClock.kt:42)
androidx.compose.runtime.BroadcastFrameClock.sendFrame (BroadcastFrameClock.kt:71)
androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke (Recomposer.kt:510)
androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke (Recomposer.kt:503)
androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame (AndroidUiFrameClock.android.kt:34)
androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch (AndroidUiDispatcher.android.kt:109)
androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch (AndroidUiDispatcher.android.kt:41)
androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame (AndroidUiDispatcher.android.kt:69)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1229)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1239)
android.view.Choreographer.doCallbacks (Choreographer.java:899)
android.view.Choreographer.doFrame (Choreographer.java:827)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1214)
android.os.Handler.handleCallback (Handler.java:942)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loopOnce (Looper.java:201)
android.os.Looper.loop (Looper.java:288)
android.app.ActivityThread.main (ActivityThread.java:7898)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:936)
@tim4724
Copy link

tim4724 commented Dec 19, 2022

I encountered the same issue and I have a possible workaround.

You probably initialise the Emitter using the max() function.
emitter = Emitter(duration = 1000, TimeUnit.MILLISECONDS).max(2000)

The issue here is an integer division that clips to 0, tough correct would should be 0.5f.
This is the problematic line in the EmiterConfig.kt.

Quick Workaround:
The issue does not occur if I use the perSecond() function to initialise the Emitter.
emitter = Emitter(duration = 1000, TimeUnit.MILLISECONDS).perSecond(1000)

@dazza5000
Copy link

We have this issue even if we use perSecond

        emitter = Emitter(duration = 2000, TimeUnit.MILLISECONDS).perSecond(50),

@DanielMartinus
Copy link
Owner

Is it reproducible? If so, did you run the memory profiler? Can you reproduce it in a sample project?

Any info you can provide would be helpful.

@dazza5000
Copy link

I can check for some more details, but we get this in Firebase crash reports

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

No branches or pull requests

4 participants