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

IllegalArgumentException (width must be > 0) occurs on Lottie 5.0.1 #2026

Closed
hsahnv opened this issue Feb 25, 2022 · 1 comment · Fixed by #2025
Closed

IllegalArgumentException (width must be > 0) occurs on Lottie 5.0.1 #2026

hsahnv opened this issue Feb 25, 2022 · 1 comment · Fixed by #2025

Comments

@hsahnv
Copy link

hsahnv commented Feb 25, 2022

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

Checklist

  1. My animation doesn't use any unsupported features.
  2. I know what part of my animation doesn't work.
  3. I have created a simplified version of my animation
  4. I have attached the AEP file (as a zip file so it can be attached) that only has the part of the animation that doesn't work.

Describe the bug
A clear and concise description of what the bug is.

What version of Lottie did you test this on?
5.0.1

What version of Android did you test this on?
6.0.1, 7.0

63% Android 7
37% Android 6

Steps To Reproduce
Steps to reproduce the behavior:
I don't know steps, but see below details.

  • Crashes reported from Firebase Crashlytics.
  • No problems on Lottie 4.x.x. (4.2.2)

Devices:
50% Galaxy Note5
38% Galaxy Tab4 10.1
12% Galaxy A3(2016)

Stack trace:

Fatal Exception: java.lang.IllegalArgumentException: width must be > 0
       at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:435)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:824)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:793)
       at com.airbnb.lottie.LottieDrawable.ensureSoftwareRenderingBitmap(LottieDrawable.java:1449)
       at com.airbnb.lottie.LottieDrawable.renderAndDrawAsBitmap(LottieDrawable.java:1397)
       at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:515)
       at android.widget.ImageView.onDraw(ImageView.java:1268)
       at android.view.View.draw(View.java:18394)
       at android.view.View.updateDisplayListIfDirty(View.java:17372)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3953)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3933)
       at android.view.View.updateDisplayListIfDirty(View.java:17335)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3953)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3933)
       at android.view.View.updateDisplayListIfDirty(View.java:17335)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3953)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3933)
       at android.view.View.updateDisplayListIfDirty(View.java:17335)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.draw(View.java:18397)
       at android.view.View.updateDisplayListIfDirty(View.java:17372)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.updateDisplayListIfDirty(View.java:17367)
       at android.view.View.draw(View.java:18156)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3969)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3755)
       at android.view.View.draw(View.java:18397)
       at com.android.internal.policy.DecorView.draw(DecorView.java:942)
       at android.view.View.updateDisplayListIfDirty(View.java:17372)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:722)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:728)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:836)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:3181)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2977)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2565)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1550)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7190)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:959)
       at android.view.Choreographer.doCallbacks(Choreographer.java:734)
       at android.view.Choreographer.doFrame(Choreographer.java:670)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:945)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6776)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

Screenshots
None

gpeal pushed a commit that referenced this issue Feb 28, 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
@guywest
Copy link

guywest commented May 22, 2022

I had the same crashes. when downgraded back to: "com.airbnb.android:lottie-compose:4.2.0" it worked fine.
The crash occurs in the regular xml view.

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

Successfully merging a pull request may close this issue.

2 participants