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
LayerManager exception while destruction #545
Comments
Yes you are in the correct place! Have you initialized properly the And also have you followed the proper library life cycle as mentioned there or the Samples app? |
Hi devemux86, Yes, I think everything is initialized as it is suggested and similarly to the Samples. It actually works fine 95% of times. I am not using the android:configChanges option in the manifest and it occurs always during the destruction-creation cycle of the activity. I have noticed also that an InterruptedException occurs first: W/System.err﹕ java.lang.InterruptedException I am using Bugsense (now called Splunk MINT) for exception-catching. I am using a map with quite a lot of different layers. I have also noticed that if I run the application with the basic map with no overlays, everything works fine and no exceptions are thrown. Maybe it is a race condition of trying to redraw a layer that was destroyed or something similar? Thank you |
Any particular reason for having the activity to restart at device orientation changes? Check also the ChangingBitmaps example at Samples with more info about handling the overlay marker bitmaps during the life cycle. |
I think this is most likely due to a missing incrementRefCount() on the bitmap, particularly if you are using the same bitmap for more than one marker. As Emux pointed out, the ChangingBitmaps example is perhaps closest to your case. |
Yes, I haven't found the bug yet but it is probably the case. Emux, I will work on the example you have mentioned and if I find a solution (probably a bug in my code) I will let you know. Thank you both! |
I think this problem has been resolved through the coding advice given, so I am closing this issue. |
Hi, I tracked the problem to the Marker.onDestroy() method. The problem was that this method decrements the ref count of the Bitmap, so when the application gets destroyed it gets ready to be released. However, when the application gets created again, the bitmap tries to be reused. I think that's why the exception is randomly thrown, because it gets destroyed when the garbage collector gets into action (I am just guessing). Thank you guys for your advice |
Hi,
I am randomly getting this exception when destroying my Android Activity:
FATAL EXCEPTION: LayerManager
Process: com.example, PID: 32261
java.lang.NullPointerException
at org.mapsforge.map.android.graphics.AndroidBitmap.getWidth(AndroidBitmap.java:113)
at org.mapsforge.map.layer.overlay.Marker.draw(Marker.java:72)
at org.mapsforge.map.layer.LayerManager.doWork(LayerManager.java:90)
at org.mapsforge.map.util.PausableThread.run(PausableThread.java:140)
I guess it is triggered by any of the destroy() functions usually called: Layer.destroy(), MapView.destroy() or TileCache.destroy(). I am using a cloned code from dev. Any guess??
By the way, I hope I am writing the issue in the correct place :)
Thank you
The text was updated successfully, but these errors were encountered: