First of all I'm a new Android developer with an iOS background and this is my first post.
Now right to business, I'm developing an app using MapQuest SDK 1.0.5 that includes a MapView which is updated periodically with new data (like navigation history and a route to a destination).
My problem is after a number of invalidate() calls the app crashes. The invalidate call is required to update the map with new data. The call is done from the main thread.
private void updateMap()
{
// remove old data from the map
.....
// add new data to the map
// update map with new data
mapView.invalidate();
}
After some time I get warned:
E/Looper﹕ WARNING: The Looper class instance count has over a limit(100). There should be some leakage of Looper or HandlerThread.
E/Looper﹕ Looper class instance count = 304
E/Looper﹕ Current Thread Name: simplifier
The app usually crashes at ~300 on my test device with:
E/[EGL-ERROR]﹕ void __egl_platform_dequeue_buffer(egl_surface*):1779: failed to dequeue buffer from native window 0x61c14a28; err = -2147483646, buf = 0x0,max_allowed_dequeued_buffers 3
E/[EGL-ERROR]﹕ void __egl_platform_dequeue_buffer(egl_surface*):1779: failed to dequeue buffer from native window 0x61c14a28; err = -16, buf = 0x0,max_allowed_dequeued_buffers 3
W/MALI﹕ _gles_set_error:82: [WARNING]Mali GLES errorcode: 501
E/OpenGLRenderer﹕ GL_INVALID_VALUE
E/[EGL-ERROR]﹕ void __egl_platform_dequeue_buffer(egl_surface*):1779: failed to dequeue buffer from native window 0x61c14a28; err = -16, buf = 0x0,max_allowed_dequeued_buffers 3
E/[EGL-ERROR]﹕ void __egl_platform_dequeue_buffer(egl_surface*):1779: failed to dequeue buffer from native window 0x61c14a28; err = -16, buf = 0x0,max_allowed_dequeued_buffers 3
A/Looper﹕ Could not create wake pipe. errno=24
A/libc﹕ Fatal signal 6 (SIGABRT) at 0x000001e5 (code=-6), thread 3944 (simplifier)
I really don't know what to do, worked all day on this.
EDIT 30.06.2015
Managed to find the source of the problem, in the update method I'm adding and removing overlay items from the map, but when I'm adding new LineOverlay items a background thread is created and it never stops even if interupt it.
mapView.getOverlays().add(overlay);
The problem is that the thread is created only when I add LineOverlay items (subclass of Overlay), if I add DefaultItemizedOverlay for example everything works fine.
This is what i found in the docs for getOverlays():
Returns the overlay list object. Use this to add and remove overlays to/from MapView. The list is synchronized externally, however must be synchronized on the list instance if iterated.
I'm guessing that the part "synchronized externally" causes the problem.
Any suggestions?