airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
35.03k stars 5.41k forks source link

Crash on Android 5.1.1 (API 22) #1000

Closed RichardMaxd closed 4 years ago

RichardMaxd commented 5 years ago

Hello, my app crashes on Android 5.1 (API 22) when using Lottie animations. It occurs on an emulator, I do not have a device with this API version to test with. I did not test it on earlier API versions as 22 is our minimum.

The crash happens after a couple of seconds and not at a specific moment. I wonder if this only happens on emulators or also on devices.

The logs I get are: 11-14 14:05:01.279 30273-30273/test.test.lottietestapp E/art: Tried to mark 0x3 not contained by any spaces 11-14 14:05:01.280 30273-30273/test.test.lottietestapp E/art: Attempting see if it's a bad root 11-14 14:05:01.280 30273-30273/test.test.lottietestapp E/art: Found invalid root: 0x3 11-14 14:05:01.280 30273-30273/test.test.lottietestapp E/art: Type=RootJavaFrame thread_id=1 location=Visiting method 'void com.airbnb.lottie.model.layer.BaseLayer.setProgress(float)' at dex PC 0x0060 (native PC 0xa459d810) vreg=2 11-14 14:05:01.281 30273-30273/test.test.lottietestapp A/art: art/runtime/gc/collector/mark_sweep.cc:381] Can't mark invalid object

I was able to recreate this issue in a test project using Lottie only in XML and using a JSON file from LottieFiles. The layout looks like:

<com.airbnb.lottie.LottieAnimationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:lottie_rawRes="@raw/motorcycle"
    app:lottie_autoPlay="true"
    app:lottie_loop="true"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

I added the JSON file as an attachment. motorcycle.txt

Runman44 commented 5 years ago

I found some information about the stacktrace here: https://source.android.com/devices/tech/dalvik/gc-debug

gpeal commented 5 years ago

@RichardMaxd Can you attach the sample project?

RichardMaxd commented 5 years ago

lottietest.zip

Here you go

saurabhkpatel commented 5 years ago

Having the same issue, after androidx migration (v2.8)

Tried to mark 0x2 not contained by any spaces 11-30 12:24:30.386 E/art ( 5730): Attempting see if it's a bad root 11-30 12:24:30.386 E/art ( 5730): Found invalid root: 0x2 11-30 12:24:30.386 E/art ( 5730): Type=RootJavaFrame thread_id=1 location=Visiting method 'void com.airbnb.lottie.model.layer.BaseLayer.setProgress(float)' at dex PC 0x0060 (native PC 0xa4706070) vreg=2 11-30 12:24:30.386 F/art ( 5730): art/runtime/gc/collector/mark_sweep.cc:381] Can't mark invalid object 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] Runtime aborting... 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] Aborting thread: 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] "main" prio=4 tid=1 Runnable 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] | group="" sCount=0 dsCount=0 obj=0x73ebf000 self=0xb4025800 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] | sysTid=5730 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0xb77b8ea0 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] | state=R schedstat=( 0 0 0 ) utm=34 stm=14 core=0 HZ=100 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] | stack=0xbf426000-0xbf428000 stackSize=8MB 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] | held mutexes= "abort lock" "mutator lock"(shared held) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #00 pc 00005d03 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+83) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #01 pc 00003051 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+33) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #02 pc 003c9e67 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+135) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #03 pc 00393222 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+306) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #04 pc 00377944 /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+644) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #05 pc 00377ead /system/lib/libart.so (art::Runtime::Abort()+125) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #06 pc 000ec704 /system/lib/libart.so (art::LogMessage::~LogMessage()+1876) 11-30 12:24:30.472 F/art ( 5730): art/runtime/runtime.cc:289] native: #07 pc 001cb8d1 /system/lib/libart.so (bool art::gc::accounting::He

RichardMaxd commented 5 years ago

For me it occurs on v2.7.0 without androidx

saurabhkpatel commented 5 years ago

I was using lottie:2.5.1 version, migrated to lottie:2.8.0 and got this issue. No code change

gpeal commented 5 years ago

@RichardMaxd It didn't repro for me. What are the exact repro steps and how frequently does it repro?

RichardMaxd commented 5 years ago

I tested it on a real 5.1.1 device today and the crash did not occur.

The repro steps are quite simple:

It happens every time. Seems like an emulator issue to me..

saurabhkpatel commented 5 years ago

@gpeal Is there any update on it? Any workaround? It happens on an emulator running Android 5.1.1 (API 22)

gpeal commented 5 years ago

@saurabhkpatel I can't get this to crash. I've tried the attached project and also the motorcycle animation in the sample app. I created a Nexus 5X API 22 x86_64 emulator.

atif-afridi commented 5 years ago

i had no animation , the animation was not visible with 2.8.0 on lollipop api 22 and it was fine on O.. i am using 2.7.0 now for all versions

RichardMaxd commented 5 years ago

@saurabhkpatel I can't get this to crash. I've tried the attached project and also the motorcycle animation in the sample app. I created a Nexus 5X API 22 x86_64 emulator.

Just tested it on a Nexus 5X API 22 x86_64 without Google API's and it didn't occur to me either. Seems like it does not happen on all API 22 emulators. On a Nexus 5X API 22 x86 with Google API's it happens to me all the time.

gpeal commented 5 years ago

@atif-afridi That is unrelated to this issue. Please file a new issue and attach your animation and I'll take a look.

@RichardMaxd I still can't reproduce it on my emulator 😢 I have motorcycle looping on a 5X API 22 Google APIs x86 (not 64).

romantiskt commented 5 years ago

I was using lottie:2.5.1 version, migrated to lottie:2.7.0 and got this issue. As mentioned above, it will crash only in the simulator now, but the real machine is only tested on its own phone, not in the production environment. This crash happens after the application is in the foreground for a period of time, and it will not crash immediately.

Type=RootJavaFrame thread_id=1 location=Visiting method 'void com.airbnb.lottie.model.layer.BaseLayer.setProgress(float)' at dex PC 0x0060 (native PC 0xe22f3730) vreg=2
art/runtime/gc/collector/mark_sweep.cc:381] Can't mark invalid object                                                                                                             
art/runtime/runtime.cc:289] Runtime aborting...                                                                                                                                   
art/runtime/runtime.cc:289] Aborting thread:                                                                                                                                      
art/runtime/runtime.cc:289] "main" prio=9 tid=1 Runnable                                                                                                                          
art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x74836000 self=0xf3c25800                                                                                        
art/runtime/runtime.cc:289]   | sysTid=2367 nice=-6 cgrp=default sched=0/0 handle=0xf77c8ea0                                                                                      
art/runtime/runtime.cc:289]   | state=R schedstat=( 65866587135 8091388911 79556 ) utm=4616 stm=1969 core=2 HZ=100                                                                
art/runtime/runtime.cc:289]   | stack=0xff4b4000-0xff4b6000 stackSize=8MB                                                                                                         
art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)                                                                                            
art/runtime/runtime.cc:289]   native: #00 pc 00005d03  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+83)                                     
art/runtime/runtime.cc:289]   native: #01 pc 00003051  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+33)                                         
art/runtime/runtime.cc:289]   native: #02 pc 003c9b97  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*,
andrea-liu87 commented 5 years ago

Hello. I happen to try this library today on my emulator. The crash never happened.

Emulator : API 22/ Android 5.1 Webp net-resizeimage

Android Gradle Plugin version : 3.5.0 Gradle version : 5.4.1 Lottie version : 3.0.7

soshial commented 5 years ago

This crash doesn't concern Android 5.0.2 (API 21)? I have a spare HUAWEI device to test on.

kukuku0517 commented 4 years ago
 // This can happen on older versions of Android because onVisibilityChanged gets called from the
    // constructor of View so this will get called before lottieDrawable gets initialized.
    // https://github.com/airbnb/lottie-android/issues/1143
    // A simple null check on lottieDrawable would not work because when using Proguard optimization, a
    // null check on a final field gets removed. As "usually" final fields cannot be null.
    // However because this is called by super (View) before the initializer of the LottieAnimationView
    // is called, it actually can be null here.
    // Working around this by using a non final boolean that is set to true after the class initializer
    // has run.

I was using 3.0.0-beta and upgraded to 3.0.7, the problem was solved. This comment was added to onVisibilityChanged in LottieAnimationView

RichardMaxd commented 4 years ago

Just updated Lottie from 2.8.0 to 3.3.0 in my sample project and the crash does not occur anymore.

gpeal commented 4 years ago

Great. I'm going to close this for now. You can reopen it if it occurs on 3.3.0+