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

Check composition exists when using software rendering #2025

Merged
merged 1 commit into from
Feb 28, 2022

Conversation

romankivalin
Copy link
Contributor

@romankivalin romankivalin commented Feb 25, 2022

To reproduce crash, add the following to the IssueReproActivity:

binding.animationView.setCacheComposition(false)
binding.animationView.renderMode = RenderMode.SOFTWARE
binding.animationView.postDelayed({ binding.animationView.setAnimation(R.raw.heart) }, 1000)

When it tries to render with null composition, getIntrinsicWidth() and getIntrinsicHeight() return -1, and both renderWidth and renderHeight end up being negative, which results in a crash:

    java.lang.IllegalArgumentException: width must be > 0
        at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:378)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:684)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:653)
        at com.airbnb.lottie.LottieDrawable.ensureSoftwareRenderingBitmap(LottieDrawable.java:1452)
        at com.airbnb.lottie.LottieDrawable.renderAndDrawAsBitmap(LottieDrawable.java:1400)
        at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:515)

It does not crash if renderMode is hardware.

Fixes #2026

@LottieSnapshotBot
Copy link

Snapshot Tests
28: Report Diff

@gpeal
Copy link
Collaborator

gpeal commented Feb 27, 2022

Thanks, @romankivalin

@gpeal gpeal merged commit 9346684 into airbnb:master Feb 28, 2022
@romankivalin romankivalin deleted the software-rendering-crash branch March 1, 2022 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IllegalArgumentException (width must be > 0) occurs on Lottie 5.0.1
3 participants