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

NullPointer in SubsamplingScaleImageView.onDraw() #344

Closed
tobsinger opened this issue Aug 31, 2017 · 2 comments
Closed

NullPointer in SubsamplingScaleImageView.onDraw() #344

tobsinger opened this issue Aug 31, 2017 · 2 comments

Comments

@tobsinger
Copy link

tobsinger commented Aug 31, 2017

Hi,

first of all thank you for this very nice project. I really appreciate the work. Currently I am facing an error during the draw process of the SubsamplingScaleImageView.

It happens in this line:

float vFocusNowX = this.ease(this.anim.easing, scaleElapsed, this.anim.vFocusStart.x, this.anim.vFocusEnd.x - this.anim.vFocusStart.x, this.anim.duration);

java.lang.NullPointerException: Attempt to read from field 'float android.graphics.PointF.x' on a null object reference
                                                                    at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.onDraw(SubsamplingScaleImageView.java:969)

I already debugged into the line and figured out that this.anim.vFocusStart is null. Maybe a simple nullcheck before the call will fix the issue.

Thank you and keep up the good work.

@tobsinger tobsinger changed the title Nullpointer in SubsamplingScaleImageView.onDraw() NullPointer in SubsamplingScaleImageView.onDraw() Aug 31, 2017
@davemorrissey
Copy link
Owner

It's hard to see how this would happen in normal use. Can you describe when it happens, whether it's before load, after load, on touch, drag, zoom, fling, custom animation or whatever?

I think the only way vFocusStart can be null is the anim was started some time after it was constructed, and the view was reset in the meantime. I can guard against that but it would be good to know what the real cause is.

@davemorrissey
Copy link
Owner

I've added a basic fix for the NPE but not addressed any possible root cause. I suspect when this NPE happens the view is in a reset or loading state so the animation can be safely ignored. If you do find why this was happening let me know!

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

No branches or pull requests

2 participants