airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
34.92k stars 5.4k forks source link

[6.3.0] use compatible lottie resource but crash #2484

Closed ariazz98 closed 4 months ago

ariazz98 commented 5 months ago

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

If you don't use this template, your issue will be closed. Delete this text once completed.

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? 6.3.0 What version of Android did you test this on? 8.1.1 - 12 Steps To Reproduce Steps to reproduce the behavior:

My application previously relied on Lottie version 2.7.0, where numerous animations necessitated compatibility mode output in order to prevent crashes. Upon updating to version 6.3.0 recently, I've encountered instances where some of the animations exported in compatibility mode are now causing crashes. The following is the exception stack trace.

java.lang.IllegalStateException: Unable to parse composition
    at com.airbnb.lottie.LottieAnimationView.lambda$static$0(LottieAnimationView.java:74)
    at com.airbnb.lottie.LottieAnimationView.$r8$lambda$AW1943Wq77PiX8nINFaTdc7Xm9s(LottieAnimationView.java:0)
    at gma.onResult(gma.java:2)
    at com.airbnb.lottie.LottieAnimationView$WeakFailureListener.onResult(LottieAnimationView.java:119)
    at com.airbnb.lottie.LottieAnimationView$WeakFailureListener.onResult(LottieAnimationView.java:98)
    at com.airbnb.lottie.LottieTask.notifyFailureListeners(LottieTask.java:172)
    at com.airbnb.lottie.LottieTask.lambda$notifyListeners$0(LottieTask.java:148)
    at com.airbnb.lottie.LottieTask.$r8$lambda$Rpnx63cLRLCF9DbgjiFM7rp0Vik(LottieTask.java:0)
    at gna.run(gna.java:2)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7053)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
    at com.airbnb.lottie.model.content.GradientColor.getColorForPosition(GradientColor.java:104)
    at com.airbnb.lottie.model.content.GradientColor.copyWithPositions(GradientColor.java:67)
    at com.airbnb.lottie.model.animatable.AnimatableGradientColorValue.ensureInterpolatableKeyframe(AnimatableGradientColorValue.java:33)
    at com.airbnb.lottie.model.animatable.AnimatableGradientColorValue.ensureInterpolatableKeyframes(AnimatableGradientColorValue.java:20)
    at com.airbnb.lottie.model.animatable.AnimatableGradientColorValue.<init>(AnimatableGradientColorValue.java:15)
    at com.airbnb.lottie.parser.AnimatableValueParser.parseGradientColor(AnimatableValueParser.java:69)
    at com.airbnb.lottie.parser.GradientStrokeParser.parse(GradientStrokeParser.java:80)
    at com.airbnb.lottie.parser.ContentModelParser.parse(ContentModelParser.java:60)
    at com.airbnb.lottie.parser.ShapeGroupParser.parse(ShapeGroupParser.java:41)
    at com.airbnb.lottie.parser.ContentModelParser.parse(ContentModelParser.java:54)
    at com.airbnb.lottie.parser.LayerParser.parse(LayerParser.java:175)
    at com.airbnb.lottie.parser.LottieCompositionMoshiParser.parseAssets(LottieCompositionMoshiParser.java:168)
    at com.airbnb.lottie.parser.LottieCompositionMoshiParser.parse(LottieCompositionMoshiParser.java:89)
    at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSyncInternal(LottieCompositionFactory.java:430)
    at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(LottieCompositionFactory.java:420)
    at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:366)
    at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:358)
    at com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(LottieCompositionFactory.java:234)
    at com.airbnb.lottie.LottieCompositionFactory.lambda$fromAsset$1(LottieCompositionFactory.java:194)
    at com.airbnb.lottie.LottieCompositionFactory.$r8$lambda$EPZUkNeLNW8MZnQsCH5SfDkhQaA(LottieCompositionFactory.java:0)
    at oma.call(oma.java:6)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

Maybe the problem is due to an error in the JSON resources being outputted in compatibility mode, and I am considering whether it would be more appropriate to change the statement from insertionPoint == colors.length - 1 to insertionPoint >= colors.length - 1 within the GradientColor#getColorForPosition method? ps:I cannot provide the specific JSON due to company restrictions, but I can only describe that the crash was caused by a certain gradient effect. Screenshots

gpeal commented 4 months ago

Can you attach your animation?

ariazz98 commented 4 months ago

I'm sorry but I cant provide the animation as it is company property.

ariazz98 commented 4 months ago

I've analyzed the error log, and it appears that the crash was caused by improperly formatted animation resources.

gpeal commented 4 months ago

Okay, I'll close this out then.