Lottie-android: Crash: java.lang.IllegalStateException Unable to create layer for LottieAnimationView, size 1088x-448 max size 8192 color type 4 has context 1

Created on 12 Sep 2019  路  34Comments  路  Source: airbnb/lottie-android

I just upgrade lottie version from 2.7.0 to 3.0.7.
I got some new crash in the latest version app.

StackTrace in Android 9:

main(2)

java.lang.IllegalStateException

Unable to create layer for LottieAnimationView, size 1088x-448 max size 16384 color type 4 has context 1

1聽android.os.MessageQueue.nativePollOnce(Native Method)

2聽android.os.MessageQueue.next(MessageQueue.java:330)
3聽android.os.Looper.loop(Looper.java:169)
4聽android.app.ActivityThread.main(ActivityThread.java:7083)
5聽java.lang.reflect.Method.invoke(Native Method)
6聽com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
7聽com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)

Anyone is try to fix this problem?

Non-Rendering Bug

Most helpful comment

I only see this crash on Samsung devices with Android 9 - J4+ and J6+

All 34 comments

Face the same issue锛寃hen will this problem to be solved?

@lchad @GeeJoe Can you attach a sample project that reproduces this?

it is really hard to reproduce.
in a one million DAU App, crash about 10 times everyday.

+1 , now we have 5000+ crash report.

3.x use gpu , is this the same problem?
https://stackoverflow.com/questions/26626344/scene-transition-with-hero-elements-throws-layer-exceeds-max-dimensions-support


StackTrace in Android 5.0/5.1:

java.lang.IllegalStateException: Unable to create layer for LottieAnimationView @62b16e5
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:122)
at android.app.ActivityThread.main(ActivityThread.java:5418)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

it is really hard to reproduce.
in a one million DAU App, crash about 10 times everyday.

+1 @gpeal @lchad

on my situation, it crash only on Android 5.0 and 5.1

@GeeJoe @Sanjay-F You can use setRenderMode(RenderModel.SOFTWARE) to get around this.

@gpeal , where should i set this "setRenderMode(RenderModel.SOFTWARE)"

@DineshBabuYadav on your LottieAnimationView

Seeing this crash exclusively on Android 9 devices, even after setting the rendering mode to Software in the XML:

Fatal Exception: java.lang.IllegalStateException: Unable to create layer for LottieAnimationView, size 1024x0 max size 8192 color type 4 has context 1
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:326)
       at android.os.Looper.loop(Looper.java:181)
       at android.app.ActivityThread.main(ActivityThread.java:7050)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

Update: Upgrading to 3.1.0 and using software rendering mode seems to have fixed the crash.

I only see this crash on Samsung devices with Android 9 - J4+ and J6+

Any updates on this? is this related to the dirty xml layout & animation as well for below API 5.0? In my case, I've scrollview <- recycler view <- inside nested recyclerview

3.0.7 + setRenderMode(RenderModel.SOFTWARE) can not fix this problem.

3.1.0 , Face the same issue锛寃hen will this problem to be solved?
java.lang.IllegalStateException
Unable to create layer for LottieAnimationView @564d826
1 android.os.MessageQueue.nativePollOnce(Native Method)
2 android.os.MessageQueue.next(MessageQueue.java:148)
3 android.os.Looper.loop(Looper.java:151)
4 android.app.ActivityThread.main(ActivityThread.java:5714)
5 java.lang.reflect.Method.invoke(Native Method)
6 java.lang.reflect.Method.invoke(Method.java:372)
7 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
8 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

3.1.0 , Face the same issue锛寃hen will this problem to be solved?
java.lang.IllegalStateException
Unable to create layer for LottieAnimationView @564d826
1 android.os.MessageQueue.nativePollOnce(Native Method)
2 android.os.MessageQueue.next(MessageQueue.java:148)
3 android.os.Looper.loop(Looper.java:151)
4 android.app.ActivityThread.main(ActivityThread.java:5714)
5 java.lang.reflect.Method.invoke(Native Method)
6 java.lang.reflect.Method.invoke(Method.java:372)
7 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
8 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

tried setRenderMode(RenderModel.SOFTWARE) ?

I'm seeing this as well in Crashlytics. Already have it using app:lottie_renderMode="software" in the layout xml for the LottieAnimationView, and using implementation 'com.airbnb.android:lottie:3.1.0' in the build.gradle.

Note that for me it's only happening on LG devices with Android 9.

@dandroidbluecrew Are you sure it isn't caused by another animation?

@gpeal This is really the only animation in the app, and the crash started showing up in Crashlytics in the exact build where we first integrated the Lottie SDK and added the animation.
I suppose we might be doing something that's forcing the error, here's more info on the setup:

We have it in the layout XML nested within some other layout elements:

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/root_layout"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/white">

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.airbnb.lottie.LottieAnimationView
                android:id="@+id/top_background_animation"
                android:layout_width="match_parent"
                android:layout_height="227dp"
                android:background="@color/brand_blue"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:lottie_fileName="animations/confetti.json"
                app:lottie_loop="false"
                app:lottie_autoPlay="false"
                app:lottie_renderMode="software"
                 />

          //...................

Devices affected:

Screen Shot 2019-12-10 at 7 21 49 PM

Here is the stack trace that shows up in Crashlytics:

Fatal Exception: java.lang.IllegalStateException: Unable to create layer for ConstraintLayout, size 768x5568 max size 8192 color type 4 has context 1
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next + 326(MessageQueue.java:326)
       at android.os.Looper.loop + 170(Looper.java:170)
       at android.app.ActivityThread.main + 6993(ActivityThread.java:6993)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 493(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main + 884(ZygoteInit.java:884)

@lchad @GeeJoe @DineshBabuYadav @andrewmunn Can you share the complete set of devices this is happening on?

image

@gpeal

Any updates on this? is this related to the dirty xml layout & animation as well for below API 5.0? In my case, I've scrollview <- recycler view <- inside nested recyclerview

Yes, its related to same, as RecyclerView inside scrollview or nestedscrollview try to load all items at once. As RecyclerView loads all items also that are not visible. If you put log inside onBindViewHolder of RecylerView you find that all items loads at the start instead of based on the visibility of the item. This causes the parent LinearLayout (inside the ScrollView) to throw exception. I had also issue related to same with Recyclerview without animation.

I just ordered an LG Aristo 3 Plus. Let's see if I can reproduce this. @dandroidbluecrew Could you attach the animation that crashes? If you can't attach it here, send it to [email protected]

@gpeal Thank you for continuing to look into this!

Here's the animation:

confetti.json.zip

Also, here's the current device list in Crashlytics for our latest build:

Screen Shot 2019-12-26 at 10 50 37 AM

@lchad @dandroidbluecrew @mochadwi @nokite The Aristo 3+ arrived running Pie and I am unable to reproduce the crash with the attached animation. I tried different combinations of hardware/software rendering and rendering many animations or animations that are larger than the screen (or both), landscape and portrait.

One theme I see in the stack traces where the full message was posted is that one dimension was either larger than the screen dimension (1088 or 5568) or 0. Can you try and adjust your layouts such that this never happens?

Any other information you can provide (animations, layouts, etc.) would be helpful.

Thanks for providing an answer @gpeal , I see, so we need to configure multi-dimension to overcome this issue?

does this also related to this issue?

he solved the issue by creating a container (child item layout) for the recyclerview or any ohter layout that nested inside NestedRecyclerView

@mochadwi It totally depends in the layout itself. Just try to make sure it is constrained to the screen size however you construct your layouts. This may or may not require landscape layouts depending on the specifics of your app.

@lchad @GeeJoe @DineshBabuYadav @andrewmunn Can you share the complete set of devices this is happening on?

I tried setRenderMode(RenderModel.SOFTWARE) and it worked for me

But I get a new crash on Android 7.0 recently. Here is the stack of the crash
image

It is similar to this https://github.com/airbnb/lottie-android/issues/1199,which the recommend answer is also setRenderMode(RenderModel.SOFTWARE)

I haven't try it锛宼he stack is confused
@gpeal

im also having this issue, only on Android 9.
1800 DAU, i got like 18 crashes.
i'll try with render mode software. do you recommend doing it only on android 9?

The LottieView is inside a RelativeLayout, nothing fancy, not inside a recyclerview

Fatal Exception: java.lang.IllegalStateException: Unable to create layer for LottieAnimationView, size 1088x-320 max size 16384 color type 4 has context 1
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next + 326(MessageQueue.java:326)
at android.os.Looper.loop + 181(Looper.java:181)
at android.app.ActivityThread.main + 6986(ActivityThread.java:6986)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main + 1445(ZygoteInit.java:1445)

@gpeal
these are the failing devices:
SM-J260A
Galaxy J7 Prime2
Galaxy S9
Galaxy J7 Neo
Xiaomi Poco F1
FIG-LX1
Y9 Prime 2019

@carloshs94 1088 is slightly taller than 1080 which might be the resolution for some of those devices. Could you check your layout and see if there is anything that could cause it to be taller than the screen?

Why does this happen on these specific samsung and lg devices? Is it the screen size or hardware config or something else? A good video on this which kinda explains some of it : https://www.youtube.com/watch?v=wIy8g8yNhNk&feature=youtu.be&list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE&t=247

Similar crash : https://issuetracker.google.com/issues/118714995

For me it's happening only for HUAWEI devices (nova, honor 6x, P9 lite) on Android 7.0. I'm using lottie in react-native "lottie-react-native": "3.1.1" which internally uses com.airbnb.android:lottie:3.0.0

Occurring for me on Vodafone 895

Was this page helpful?
0 / 5 - 0 ratings