Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check composition exists when using software rendering (#2025)
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
- Loading branch information