lottie-android icon indicating copy to clipboard operation
lottie-android copied to clipboard

BaseLayer.applyMasks NullPointerException

Open Mihir3646 opened this issue 2 years ago • 6 comments

  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.

Getting Null pointer exception after android version 10 in lottie file in which opacity is used.

I am using 5.0.3 version of Lottie to test this

My app support min SDK 21 and target and compile SDK 32

here is the error log

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference com.airbnb.lottie.model.layer.BaseLayer.applyMasks (BaseLayer.java:433) com.airbnb.lottie.model.layer.BaseLayer.draw (BaseLayer.java:296) com.airbnb.lottie.model.layer.CompositionLayer.k (CompositionLayer.java:124) com.airbnb.lottie.model.layer.BaseLayer.applySubtractMask (BaseLayer.java:513) com.airbnb.lottie.model.layer.BaseLayer.applyMasks (BaseLayer.java:461) com.airbnb.lottie.model.layer.BaseLayer.draw (BaseLayer.java:296) com.airbnb.lottie.LottieDrawable.g (LottieDrawable.java:59) com.airbnb.lottie.LottieDrawable.draw (LottieDrawable.java:34)

Which indicated the error in this line BaseKeyframeAnimation<Integer, Integer> opacityAnimation = this.mask.getOpacityAnimations().get(i); in applyMasks Method of BaseLayer class

Mihir3646 avatar Jun 22 '22 05:06 Mihir3646

Does this happen 100% of the time or only sometimes? Can you attach your animation or a sample project? Was your animation exported with Bodymovin for After Effects or something else?

gpeal avatar Jun 27 '22 14:06 gpeal

Does this happen 100% of the time or only sometimes? Can you attach your animation or a sample project? Was your animation exported with Bodymovin for After Effects or something else?

Yes, this happens 100% of the time. Due to NDA, I can't upload the animation.

Mihir3646 avatar Jun 28 '22 06:06 Mihir3646

Without a repro animation, I won't be able to fix this. Are your designers using After Effects? If so, can you work with them to create a repro animation (preferable with the aep file) that crashes but uses simple shapes like square or something?

gpeal avatar Jun 28 '22 13:06 gpeal

Here is more detail about the crash - device, and os. Attached the screenshots Screenshot 2022-06-28 at 7 55 32 PM

Screenshot 2022-06-28 at 7 55 39 PM

Mihir3646 avatar Jun 28 '22 14:06 Mihir3646

@Mihir3646 I thought you said it happened 100% of the time. If that's true then OS/device metrics aren't important. Without a repro, I won't be able to help here, however.

gpeal avatar Jun 28 '22 15:06 gpeal

@Mihir3646 I thought you said it happened 100% of the time. If that's true then OS/device metrics aren't important. Without a repro, I won't be able to help here, however.

I will post that in a couple of days, that needs to be extracted with the help of my designing team.

Mihir3646 avatar Jun 29 '22 06:06 Mihir3646

Unfortunately, without a repro, it won't be possible to assist you here. This is the compiled bytecode -> decompiled java for that line

        for(int i = 0; i < this.mask.getMasks().size(); ++i) {
            Mask mask = (Mask)this.mask.getMasks().get(i);
            BaseKeyframeAnimation<ShapeData, Path> maskAnimation = (BaseKeyframeAnimation)this.mask.getMaskAnimations().get(i);
            BaseKeyframeAnimation<Integer, Integer> opacityAnimation = (BaseKeyframeAnimation)this.mask.getOpacityAnimations().get(i); // <-- This line

It isn't clear to me where there is an Integer that gets boxed to an int.

If you can attach a repro, I'd be happy to assist though.

gpeal avatar Nov 11 '22 19:11 gpeal