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

NPE: Attempt to read from field 'float android.graphics.PointF.x' on a null object reference #2194

Closed
danmov26 opened this issue Dec 2, 2022 · 10 comments · Fixed by #2197
Closed

Comments

@danmov26
Copy link

danmov26 commented Dec 2, 2022

Non-fatal Exception: java.lang.NullPointerException: Attempt to read from field 'float android.graphics.PointF.x' on a null object reference
       at com.airbnb.lottie.animation.keyframe.TransformKeyframeAnimation.getMatrix(TransformKeyframeAnimation.java:232)
       at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:248)
       at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:128)
       at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:250)
       at com.airbnb.lottie.LottieDrawable.drawDirectlyToCanvas(LottieDrawable.java:1354)
       at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:517)
       at android.widget.ImageView.onDraw(ImageView.java:1453)
       at android.view.View.draw(View.java:23901)
       at android.view.View.updateDisplayListIfDirty(View.java:22776)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.updateDisplayListIfDirty(View.java:22762)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.draw(View.java:23904)
       at android.view.View.updateDisplayListIfDirty(View.java:22776)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.updateDisplayListIfDirty(View.java:22762)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.updateDisplayListIfDirty(View.java:22762)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.updateDisplayListIfDirty(View.java:22762)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.updateDisplayListIfDirty(View.java:22762)
       at android.view.View.draw(View.java:23631)
       at android.view.ViewGroup.drawChild(ViewGroup.java:5336)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:5093)
       at android.view.View.draw(View.java:23904)
       at com.android.internal.policy.DecorView.draw(DecorView.java:1282)
       at android.view.View.updateDisplayListIfDirty(View.java:22776)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:579)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:585)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:662)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:5042)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4749)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3866)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2618)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9971)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010)
       at android.view.Choreographer.doCallbacks(Choreographer.java:809)
       at android.view.Choreographer.doFrame(Choreographer.java:744)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Got a message from Firebase Crashlytics - Galaxy A10. Using latest 5.2.0 version.
I see you have already fixed this in the same method getMatrix() for positionValue:
positionValue != null && (positionValue.x != 0 || positionValue.y != 0)

Сould you please fix it for anchorPointValue that way? Now:
anchorPointValue.x != 0 || anchorPointValue.y != 0
TO
anchorPointValue != null && (anchorPointValue.x != 0 || anchorPointValue.y != 0)

@gpeal
Copy link
Collaborator

gpeal commented Dec 2, 2022

Is it only happening with a specific anything? Only on specific devices, Android versions, manufacturers, etc?

@danmov26
Copy link
Author

danmov26 commented Dec 2, 2022

Hello. Thanks for answer. This only happened once on this phone Galaxy A10 (Android 11).

Here is layout:

<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/img_logo1"
    android:layout_width="@dimen/_300sdp"
    android:layout_height="0dp"
    android:layout_weight="1"
    app:lottie_autoPlay="true"
    app:lottie_loop="false"
    app:lottie_rawRes="@raw/data"
    app:lottie_speed="1.5" />

build.gradle:
implementation("com.airbnb.android:lottie:5.2.0")

This is lottie_rawRes:
data.zip

My app (use VPN from Russia or Great Britain to install it):
https://play.google.com/store/apps/details?id=com.financialaccounting.fincircle

Crashlytics:
Crash

@danmov26
Copy link
Author

danmov26 commented Dec 2, 2022

In this video I show you Lottie animation, and it is working well on my Galaxy S22.

Screen_Recording_20221202_204219_Fincircle.mp4

@danmov26
Copy link
Author

danmov26 commented Dec 2, 2022

I just tested on Samsung Galaxy A10 in BrowserStack emulator. No errors.

gpeal added a commit that referenced this issue Dec 5, 2022
Not sure why this is happening but it seems similar to #1955.

Fixes #2194
@danmov26
Copy link
Author

danmov26 commented Dec 7, 2022

Hello. Can you please tell me how can I get this change? The version also remained 5.2.0. I see that you corrected the repository in the master branch, but I look in android studio and there is no change.

I tried also to write implementation("com.github.airbnb:lottie-android:master")

Снимок экрана (17)

@gpeal
Copy link
Collaborator

gpeal commented Dec 7, 2022

5.3.0-SNAPSHOT has it

@danmov26
Copy link
Author

danmov26 commented Dec 7, 2022

I offer a thousand apologies. Android studio cannot find this version. Help me please.
Снимок экрана 2022-12-08 005139

@gpeal
Copy link
Collaborator

gpeal commented Dec 8, 2022

You have to add the maven snapshot repository https://oss.sonatype.org/content/repositories/snapshots/

@danmov26
Copy link
Author

danmov26 commented Dec 8, 2022

Thank you very much!

@danmov26
Copy link
Author

Good day, gpeal!

I got new same error but from another place:

java.lang.NullPointerException: Attempt to read from field 'float android.graphics.PointF.x' on a null object reference
       at com.airbnb.lottie.animation.content.EllipseContent.getPath(EllipseContent.java:86)
       at com.airbnb.lottie.animation.content.BaseStrokeContent.draw(BaseStrokeContent.java:201)
       at com.airbnb.lottie.animation.content.StrokeContent.draw(StrokeContent.java:48)
       at com.airbnb.lottie.animation.content.ContentGroup.draw(ContentGroup.java:185)
       at com.airbnb.lottie.animation.content.ContentGroup.draw(ContentGroup.java:185)
       at com.airbnb.lottie.model.layer.ShapeLayer.drawLayer(ShapeLayer.java:36)
       at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:250)
       at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:128)
       at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:250)
       at com.airbnb.lottie.LottieDrawable.drawDirectlyToCanvas(LottieDrawable.java:1354)
       at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:517)
       at android.widget.ImageView.onDraw(ImageView.java:1367)
       at android.view.View.draw(View.java:19275)
       at android.view.View.updateDisplayListIfDirty(View.java:18225)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.updateDisplayListIfDirty(View.java:18216)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.draw(View.java:19278)
       at android.view.View.updateDisplayListIfDirty(View.java:18225)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.updateDisplayListIfDirty(View.java:18216)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.updateDisplayListIfDirty(View.java:18216)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.updateDisplayListIfDirty(View.java:18216)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.updateDisplayListIfDirty(View.java:18216)
       at android.view.View.draw(View.java:19003)
       at android.view.ViewGroup.drawChild(ViewGroup.java:4240)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4026)
       at android.view.View.draw(View.java:19278)
       at com.android.internal.policy.DecorView.draw(DecorView.java:788)
       at android.view.View.updateDisplayListIfDirty(View.java:18225)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:676)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:682)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:790)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:3013)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2817)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2370)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1403)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6790)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
       at android.view.Choreographer.doCallbacks(Choreographer.java:778)
       at android.view.Choreographer.doFrame(Choreographer.java:713)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6528)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Снимок экрана 2022-12-10 173725

This user still uses library version 5.2.0

And here is the code from EllipseContent.java:86

85: PointF size = sizeAnimation.getValue();
86: float halfWidth = size.x / 2f;
87: float halfHeight = size.y / 2f;

It seems that we need to add a check for null here too.

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