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

Segfault when running lottie animations in an Android Emulator on Linux using software graphics rendering #2550

Open
saucetom opened this issue Sep 17, 2024 · 4 comments

Comments

@saucetom
Copy link

saucetom commented Sep 17, 2024

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

Checklist

  1. Fork this repository into your account. ✅
  2. Reproduce your issue in the issue-repro module. Issues without a repro in the issue-repro
    module may be auto-closed. ✅

Link to fork with a repro in the issue-repro module
https://github.com/saucetom/lottie-android

Describe the bug
Android emulators on Linux machines using software graphics rendering crash when rendering Lottie Animations. This happens when trying to render multiple animations at once or when rendering a large animation. We've confirmed this behavior on various machines running Linux.

If we set renderMode = RenderMode.SOFTWARE in the LottieAnimation calls the crash doesn't happen. The crash also doesn't happen if we set android:hardwareAccelerated="false" in the AndroidManifest.xml file. I wonder if the logic in the useSoftwareRendering method should detect that the emulator is not using hardware acceleration and default to RenderMode.SOFTWARE?
https://github.com/saucetom/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/RenderMode.java#L16

Steps To Reproduce
Steps to reproduce the behavior:

  1. Launch an emulator on a Linux machine using the -gpu swiftshader_indirect flag
  2. Run the issue-repro-compose module from the fork linked above

Please let me know if there's any more information I can provide that would help facilitate resolving this bug. Thanks!

@gpeal
Copy link
Collaborator

gpeal commented Sep 29, 2024

I don't regularly work on a linux machine. Would you be open to taking a look and putting up a PR?

Which API levels have you seen this on?

I just tried this on a mac with -gpu swiftshader_indirect and forced RenderMode to hardware and it seemed to render fine

image

@saucetom
Copy link
Author

saucetom commented Oct 1, 2024

With the latest version of lottie-android I'm seeing this on all API levels >= 26, but yes it only happens on Linux machines.

It seems like it would make sense to default to Software Rendering if GPU hardware acceleration is not enabled, I'll take a look and see if that would be straightforward to implement.

@saucetom
Copy link
Author

saucetom commented Oct 9, 2024

@gpeal I don't think I'm able to detect from the code whether the test is running on an emulator using software graphics emulation. However I was able to trace the crash to this specific call to drawLayer. If I comment out that line the emulator doesn't hit the segfault.

I'm not familiar enough with the code to make any guesses about why that is, is there anything about this block of code or that specific drawLayer call that sticks out to you?

I will keep digging but any help or direction you could offer would be very appreciated.

@gpeal
Copy link
Collaborator

gpeal commented Oct 9, 2024

@saucetom That's basically the root method that'll draw everything in your animation so it doesn't narrow it down much.

What I like to do in cases like this is to progressively remove parts of the original animation to narrow down which part of it is crashing.

Lottie is definitely frequently used on Linux with software rendering so there has to be something specific to your linux distro, emulator, or animation that is triggering this.

For what it's worth, Lottie's CI snapshots run on linux and snapshot >2k animations using both software and hardware rendering without any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants