Closed GoogleCodeExporter closed 8 years ago
The exception is raised in ItemizedOverlayWithBubble.draw method, in a section
identical to osmdroid ItemizedOverlay.draw method.
Look at this osmdroid issue:
http://code.google.com/p/osmdroid/issues/detail?id=365
Does it seems similar to your issue?
Original comment by mathieu....@gmail.com
on 10 Dec 2012 at 9:31
Yes, this seems like the same issue. So a fix is still ongoing?
Original comment by shameus....@gmail.com
on 11 Dec 2012 at 1:44
No update since August...
I just commited a new version of ItemizedOverlayWithBubble, introducing
synchronize blocks to avoid this race condition (osmbonuspack_v3.1.jar in the
Downloads).
It still works on my tests, but I never encountered your issue.
Can you test it?
Original comment by mathieu....@gmail.com
on 12 Dec 2012 at 9:39
12-12 17:01:32.215: E/AndroidRuntime(7575): FATAL EXCEPTION: main
12-12 17:01:32.215: E/AndroidRuntime(7575):
java.lang.IndexOutOfBoundsException: Invalid index 18, size is 16
12-12 17:01:32.215: E/AndroidRuntime(7575): at
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
java.util.ArrayList.get(ArrayList.java:311)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
org.osmdroid.views.overlay.ItemizedOverlay.getItem(ItemizedOverlay.java:149)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
org.osmdroid.bonuspack.overlays.ItemizedOverlayWithBubble.draw(ItemizedOverlayWi
thBubble.java:141)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
org.osmdroid.views.overlay.OverlayManager.onDraw(OverlayManager.java:119)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
org.osmdroid.views.MapView.dispatchDraw(MapView.java:872)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.View.draw(View.java:7022)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.widget.FrameLayout.draw(FrameLayout.java:357)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.View.draw(View.java:7022)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.widget.FrameLayout.draw(FrameLayout.java:357)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:191
7)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewRoot.draw(ViewRoot.java:1562)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewRoot.performTraversals(ViewRoot.java:1298)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1900)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.os.Handler.dispatchMessage(Handler.java:99)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.os.Looper.loop(Looper.java:130)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
android.app.ActivityThread.main(ActivityThread.java:3691)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
java.lang.reflect.Method.invokeNative(Native Method)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
java.lang.reflect.Method.invoke(Method.java:507)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
12-12 17:01:32.215: E/AndroidRuntime(7575): at
dalvik.system.NativeStart.main(Native Method)
It lasted longer but still failed after the update.
Original comment by shameus....@gmail.com
on 12 Dec 2012 at 10:02
Hummmm...
To be sure: I imagine you have threads. In your test, what are you doing in
these threads, while drawing?
Original comment by mathieu....@gmail.com
on 13 Dec 2012 at 11:17
I do have threads but I'm synchronizing access to the object that uses
ItemizedOverlayWithBubble. I've doubled checked it.
Original comment by shameus....@gmail.com
on 13 Dec 2012 at 5:14
[deleted comment]
At bottom level, the race condition occurs inside ItemizedOverlay.getItem(), at
this line: mInternalItemList.get(position);
At top level, this is called by ItemizedOverlayWithBubble.draw()
I don't think you can synchronize between your threads and the draw, because
you don't call the draw yourself (this is done by Android framework).
What I don't understand is why my fix doesn't work.
Could you provide a sample of your code?
Original comment by mathieu....@gmail.com
on 14 Dec 2012 at 2:41
Sorry for the delay.
My Eclipse environment got completely corrupted. I'm still trying to get back
up and running. Once that is done I'll verify that I'm using the correct lib
with the new changes.
Original comment by shameus....@gmail.com
on 14 Dec 2012 at 6:37
I'm still getting the exception.
I've verified I've built the rev 119 of the bonuspack.
12-16 10:44:19.190: E/AndroidRuntime(10290): FATAL EXCEPTION: main
12-16 10:44:19.190: E/AndroidRuntime(10290):
java.lang.IndexOutOfBoundsException: Invalid index 15, size is 13
12-16 10:44:19.190: E/AndroidRuntime(10290): at
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
java.util.ArrayList.get(ArrayList.java:311)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
org.osmdroid.views.overlay.ItemizedOverlay.getItem(ItemizedOverlay.java:149)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
org.osmdroid.bonuspack.overlays.ItemizedOverlayWithBubble.draw(ItemizedOverlayWi
thBubble.java:153)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
org.osmdroid.views.overlay.OverlayManager.onDraw(OverlayManager.java:119)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
org.osmdroid.views.MapView.dispatchDraw(MapView.java:872)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.View.draw(View.java:7022)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.widget.FrameLayout.draw(FrameLayout.java:357)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.View.draw(View.java:7022)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.widget.FrameLayout.draw(FrameLayout.java:357)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:191
7)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewRoot.draw(ViewRoot.java:1562)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewRoot.performTraversals(ViewRoot.java:1298)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1900)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.os.Handler.dispatchMessage(Handler.java:99)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.os.Looper.loop(Looper.java:130)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
android.app.ActivityThread.main(ActivityThread.java:3691)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
java.lang.reflect.Method.invokeNative(Native Method)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
java.lang.reflect.Method.invoke(Method.java:507)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
12-16 10:44:19.190: E/AndroidRuntime(10290): at
dalvik.system.NativeStart.main(Native Method)
Original comment by shameus....@gmail.com
on 16 Dec 2012 at 3:50
I think I might have found the problem with Index out of bounds exception. I
was creating a new ItemizedOverlayWithBubble object with every iteration of the
thread. I moved the creation into onCreate thus only being created once. I'll
do more testing.
During testing the below exception crept up when calling this,
RoadManager.buildRoadOverlay
12-16 14:06:55.050: E/AndroidRuntime(19734): FATAL EXCEPTION: main
12-16 14:06:55.050: E/AndroidRuntime(19734): java.lang.NullPointerException
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.DefaultResourceProxyImpl.getDisplayMetricsDensity(DefaultResourcePr
oxyImpl.java:133)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.views.overlay.Overlay.<init>(Overlay.java:64)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.views.overlay.PathOverlay.<init>(PathOverlay.java:66)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.views.overlay.PathOverlay.<init>(PathOverlay.java:62)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.bonuspack.routing.RoadManager.buildRoadOverlay(RoadManager.java:59)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.bonuspack.routing.RoadManager.buildRoadOverlay(RoadManager.java:79)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.Route.updateRoad(Route.java:110)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.Route$UpdateRoadTask.onPostExecute(Route.java:187)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
org.osmdroid.Route$UpdateRoadTask.onPostExecute(Route.java:1)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.os.AsyncTask.finish(AsyncTask.java:417)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.os.AsyncTask.access$300(AsyncTask.java:127)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.os.Handler.dispatchMessage(Handler.java:99)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.os.Looper.loop(Looper.java:130)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
android.app.ActivityThread.main(ActivityThread.java:3691)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
java.lang.reflect.Method.invokeNative(Native Method)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
java.lang.reflect.Method.invoke(Method.java:507)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
12-16 14:06:55.050: E/AndroidRuntime(19734): at
dalvik.system.NativeStart.main(Native Method)
Original comment by shameus....@gmail.com
on 16 Dec 2012 at 7:12
I really need related code sections to help you.
Original comment by mathieu....@gmail.com
on 17 Dec 2012 at 9:07
I believe the buildRoadOverlay crash is fixed. The code was using the default
OSMRoadManager. I changed the directions source to the MapQuestRoadManager and
it's not crashing. It could be that the OSM road manager was returning bogus
data perhaps.
Thanks for your help.
Original comment by shameus....@gmail.com
on 18 Dec 2012 at 2:03
To avoid risk of race conditions, more synchronize sections have been
implemented in ItemizedOverlayWithBubble in osmbonuspack v3.1.
I now set the issue to Fixed.
Original comment by mathieu....@gmail.com
on 10 Jan 2013 at 10:05
Original issue reported on code.google.com by
shameus....@gmail.com
on 10 Dec 2012 at 2:31