Lottie-android: SIGSEGV on Android 7.0 with Lottie 3.0.1

Created on 30 Apr 2019  Â·  18Comments  Â·  Source: airbnb/lottie-android

We saw a huge uptick in crashes after updating to 3.0.1. I'm not 100% on the particular animation and will update when I find out what it is. This crashes primarily on 7.0 and I can reproduce using a 7.0 emulator. Rolling back to 2.8.0 fixes the issue.

Stacktrace:

SIGSEGV: Segmentation violation (invalid memory reference)
        at 0xb493829a(/system/lib/libhwui.so:397978)
        at 0xb493799d(/system/lib/libhwui.so:395677)
        at 0xb49375d9(/system/lib/libhwui.so:394713)
        at 0xb48f8e63(/system/lib/libhwui.so:138851)
        at 0xb48fa8b7(/system/lib/libhwui.so:145591)
        at android::uirenderer::renderthread::RenderThread::threadLoop()(/system/lib/libhwui.so:159059)
        at android::Thread::_threadLoop(void*)(/system/lib/libutils.so:58343)
        at android::AndroidRuntime::javaThreadShell(void*)(/system/lib/libandroid_runtime.so:363395)
        at 0xb3bf2655(/system/lib/libc.so:292437)
        at 0xb3bc4def(/system/lib/libc.so:105967)

Most helpful comment

@pmecho alright, I was able to fix it thanks to your repro _and_ it improved performance of that animation by almost 20% as a result!
https://github.com/airbnb/lottie-android/pull/1246

All 18 comments

@pmecho Can you attach a project that reproduces this?

I have the same issue on 7.0 when drawing drawable with this animation directly on canvas.

chats_archive.zip

The problem is not in animation itself, there is a bug with canvas.clipRect

canvas.clipRect(tx, 0, getMeasuredWidth(), getMeasuredHeight()); translationDrawable.draw(canvas);

if clipRect intersects with drawable, it will crash on Android 7.0

@pmecho @DrKLO Can you provide more details or provide a sample project that reproduces this?

@gpeal Sorry for the delay on this. I'll work on getting a sample project tomorrow. I think I know the specific asset that causes this.

I have the same issue on 7.0 by Lottie 3.0.3

lottie json files link:https://github.com/airbnb/lottie-android/files/3190662/22.zip

@gpeal

@pmecho @todo-fixme neither of these crash on my 7.0 emulator. Any tips to repro it?

@gpeal I found the Lottie asset but I am unsure if I can post publicly due to copyright restrictions. Can I send it via email or another non-public way?

If you have private repos, putting it in a private repo and giving @gpeal access to the repo would be a safe way to exchange it without either of you having to publicly post your e-mail

@pmecho I second this ^. Share a private repro with me and I'll take a look.

What a great idea! Created one and added you @gpeal

@pmecho I got the animation. However, it pays fine on my 7.0 emulator. How were you able to repro it?

@gpeal The first time it displays and animates fine but when I navigate to another fragment (or activity, I'd have to check) and then return to the original fragment it will crash when the animation happens again. I'll add a gif to that project this evening that illustrates the crash in our app. I'll also try to put together a sample project that reproduces it based on how our code is set up. I'm not super familiar with that area so it will take some time if I can't immediately reproduce it.

@pmecho Hmm, I'm trying to repro with the Lottie Sample app and navigated back to MainActivity with it animating, came back and it worked fine. If you could repro with the LottieSample app, that would be ideal.

@gpeal I was able to repro on the sample app. I uploaded a patch file to apply to the v3.0.1 tag to that private repo as it contains the asset. Reproduction steps are in the commit comment but for ease they are:

  1. Launch sample app (with patch applied to v3.0.1 tag)
  2. Open Lottiefiles tab
  3. Crash may occur
  4. If no crash, tap learn tab
  5. Tap off the share dialog to close
  6. Tap Lottiefiles tab again
  7. Should crash. If not, repeat steps 4-7

@pmecho Thanks for the info. I'm able to reproduce this now which is _extremely_ helpful!

So far, disabling hardware acceleration with setRenderMode fixes it which should help in the short term. It's also related to mattes and scaling. It renders fine with a large scale (~1000%) but if I scale it down, with setScale it crashes.

@DrKLO Can you also just disable hardware acceleration on 7.0 for the animation causing issues for now? I'l continue to investigate.

@pmecho alright, I was able to fix it thanks to your repro _and_ it improved performance of that animation by almost 20% as a result!
https://github.com/airbnb/lottie-android/pull/1246

Woot! Thanks for the fix and super bonus performance increase!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nabeel-khalid picture Nabeel-khalid  Â·  4Comments

nick1Jian picture nick1Jian  Â·  3Comments

anitoledo picture anitoledo  Â·  4Comments

dfpalomar picture dfpalomar  Â·  5Comments

mateusgrb picture mateusgrb  Â·  5Comments