The Wayback Machine - https://web.archive.org/web/20200914175934/https://github.com/airbnb/lottie-android/issues/1387
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

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

Open
lchad opened this issue Sep 12, 2019 · 34 comments

Comments

@lchad
Copy link

@lchad lchad commented Sep 12, 2019

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?

@GeeJoe
Copy link

@GeeJoe GeeJoe commented Sep 12, 2019

Face the same issue,when will this problem to be solved?

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Sep 12, 2019

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

@lchad
Copy link
Author

@lchad lchad commented Sep 17, 2019

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

@Sanjay-F
Copy link

@Sanjay-F Sanjay-F commented Sep 19, 2019

+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)

@GeeJoe
Copy link

@GeeJoe GeeJoe commented Sep 23, 2019

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

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Sep 23, 2019

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

@DineshBabuYadav
Copy link

@DineshBabuYadav DineshBabuYadav commented Oct 1, 2019

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

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Oct 1, 2019

@DineshBabuYadav on your LottieAnimationView

@andrewmunn
Copy link

@andrewmunn andrewmunn commented Oct 13, 2019

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)
@andrewmunn
Copy link

@andrewmunn andrewmunn commented Oct 18, 2019

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

@nokite
Copy link

@nokite nokite commented Oct 28, 2019

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

@mochadwi
Copy link

@mochadwi mochadwi commented Nov 21, 2019

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

@lchad
Copy link
Author

@lchad lchad commented Nov 21, 2019

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

@lylissuperman
Copy link

@lylissuperman lylissuperman commented Dec 9, 2019

3.1.0 , Face the same issue,when 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)

@lchad
Copy link
Author

@lchad lchad commented Dec 9, 2019

3.1.0 , Face the same issue,when 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) ?

@dandroidbluecrew
Copy link

@dandroidbluecrew dandroidbluecrew commented Dec 10, 2019

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.

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Dec 10, 2019

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

@dandroidbluecrew
Copy link

@dandroidbluecrew dandroidbluecrew commented Dec 11, 2019

@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)
@gpeal
Copy link
Collaborator

@gpeal gpeal commented Dec 11, 2019

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

@lchad
Copy link
Author

@lchad lchad commented Dec 17, 2019

image

@lchad
Copy link
Author

@lchad lchad commented Dec 17, 2019

@tilalapradip
Copy link

@tilalapradip tilalapradip commented Dec 26, 2019

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.

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Dec 26, 2019

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 lottietestapps@gmail.com

@dandroidbluecrew
Copy link

@dandroidbluecrew dandroidbluecrew commented Dec 26, 2019

@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

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Jan 4, 2020

@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.

@mochadwi
Copy link

@mochadwi mochadwi commented Jan 6, 2020

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

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Jan 6, 2020

@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.

@GeeJoe
Copy link

@GeeJoe GeeJoe commented Jan 19, 2020

@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

@GeeJoe
Copy link

@GeeJoe GeeJoe commented Jan 19, 2020

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,the stack is confused
@gpeal

@carloshs94
Copy link

@carloshs94 carloshs94 commented Feb 2, 2020

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

@gpeal
Copy link
Collaborator

@gpeal gpeal commented Feb 16, 2020

@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?

@li-gjhawar
Copy link

@li-gjhawar li-gjhawar commented Feb 20, 2020

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

@JaEdmuva
Copy link

@JaEdmuva JaEdmuva commented Apr 2, 2020

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

@urgentx
Copy link

@urgentx urgentx commented Jul 29, 2020

Occurring for me on Vodafone 895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.