Sharas
Sharas

Reputation: 2135

crash with lottie animation on BottomSheetFragment

I've a BottomSheetDialogFragment with the following view:

<com.airbnb.lottie.LottieAnimationView
            android:id="@+id/myAnimation"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:contentDescription="@null"
            app:layout_constraintBottom_toTopOf="@id/title"
            app:layout_constraintStart_toStartOf="@id/image"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintEnd_toEndOf="@id/image"
            app:lottie_autoPlay="true"
            app:lottie_loop="true"
            app:lottie_rawRes="@raw/lottie_animation"
            tools:src="@raw/lottie_animation" />

When I open my bottomSheet and rotate it few times, after few rotations, it crashes with this error:

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 16124 (PixelCopy)

It doesn't crash if I run in on a Fragment. It doesn't crash in any way if i test in on a different (clean) sample app.

Other bottom sheets that use different (maybe lighter) lottie animations don't crash.

I wonder how can I find what makes it to crash.

Thanks.

Upvotes: 1

Views: 1334

Answers (1)

DC_Androidista
DC_Androidista

Reputation: 39

Welcome to SIGSEGV error, my friend😊. So SIGSEGV error is caused when a program tries to access a memory location outside the allocated memory.

Recently I have also started adding Lottie animations on my Android app and it crashes in slightly lower end devices after a few seconds with this error: Could not allocate X bytes.[In place of X, there's a big number shown in the logs]

So the solution is

  1. Either try to find a lighter Lottie animation
  2. Or try to generate a GIF out of the Lottie and then reduce the number of frames using some photo editing tool

If you don't do this, then your app will eat up a lot of RAM even if it doesn't crash.

Regards, Debayan

Upvotes: 1

Related Questions