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

Random NPE #4

Closed
ryust opened this issue Jun 21, 2019 · 12 comments
Closed

Random NPE #4

ryust opened this issue Jun 21, 2019 · 12 comments
Labels
bug Something isn't working

Comments

@ryust
Copy link

ryust commented Jun 21, 2019

Periodically, I'll get a NullPointerException when closing a map with a curve and then reopening it to show the curve again. I haven't isolated a pattern yet. Here is the stack trace:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.makesense.labs.curvefit.interfaces.UiThreadCallback.publishToUiThread(android.os.Message)' on a null object reference
at com.makesense.labs.curvefit.impl.WorkerHandlerThread$1.handleMessage(WorkerHandlerThread.java:83)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)

@sarweshkumar47
Copy link
Owner

Periodically, I'll get a NullPointerException when closing a map with a curve and then reopening it to show the curve again. I haven't isolated a pattern yet. Here is the stack trace:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.makesense.labs.curvefit.interfaces.UiThreadCallback.publishToUiThread(android.os.Message)' on a null object reference
at com.makesense.labs.curvefit.impl.WorkerHandlerThread$1.handleMessage(WorkerHandlerThread.java:83)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)

I'm trying to reproduce the issue. In WorkerHandlerThread class, I have used a WeakReference object to hold a callback reference to the CurveManager class. Therefore, it is eligible for garbage collection. This could be causing some issue, but I'm still not sure. If you could provide me little more details like, steps to reproduce the issue or sending some dummy apk would be helpful to understand the problem better.

@ryust
Copy link
Author

ryust commented Jun 22, 2019

I'll look into it some more, but so far no pattern other than opening/closing map with curves. I set the CurveManager to null on map close so something with the weak reference could be the issue. I'm trying to delay showing the curves after map loaded to see if that fixes it.

@ryust
Copy link
Author

ryust commented Jul 14, 2019

I'm still getting periodic bug reports with this NPE. Any possibility of wrapping the code with a try/catch so the error doesn't cause a crash?

It's so random I can't offer any more information and the app is so large there is no way to provide you with a test case.

@sarweshkumar47
Copy link
Owner

Hi,
I am unable to reproduce the issue of what you are facing right now. By this weekend, I'll release a new beta version of the library which will be compatible with Maps 3.0 beta. Please wait for that release.

@sarweshkumar47
Copy link
Owner

Sorry for the delay.

This bug has been fixed in new 2.0.0 beta version. Please try using that.

@sarweshkumar47 sarweshkumar47 added the bug Something isn't working label Aug 2, 2019
@ryust
Copy link
Author

ryust commented Aug 2, 2019

I can't implement the Android Maps beta yet... any way you can add the fix to the current 1.1.0 release for those of us that need to run without the beta?

@ryust
Copy link
Author

ryust commented Aug 5, 2019

If you can tell me what was changed, I'll try to fix it myself on the non-beta version... it's frustrating to have NPEs in a production app for a nice library like this.

@sarweshkumar47
Copy link
Owner

Sorry for late reply. I was on leave due to medical emergency. I will add the fix to the non beta version soon.

@sarweshkumar47
Copy link
Owner

The patch is applied. Curve-Fit 1.1.1 is available now.

@ryust
Copy link
Author

ryust commented Aug 6, 2019

Well, 1.1.1 is actually worse. Not getting NPE, but also 95% of the time the curves do not render on the map. When it rarely renders, then multiple close/open of the map doesn't seem to ever show curves again until the app is restarted.

Is CurveManager.unregister necessary? I haven't been using it.

@ryust
Copy link
Author

ryust commented Aug 6, 2019

I think I have it working now. I made sure the unregister was done after the map closed and that may have fixed the issue I had with curves not showing. Thanks for the fix and nice library!

@sarweshkumar47
Copy link
Owner

Calling unregister method at the end is necessary. Otherwise, memory leaks will occur for sure. Also, the old GoogleMap object will not be garbage collected and the Handler uses this reference (old) to draw the PolyLine (which will not have any effect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants