waar19 / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

NPE in linked hash map in async tile provider. #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On jar 1.03 I got an android market bug report with the following stacktrace. 
I've seen a few reports like this in the past, but it only happens 
occasionally. I haven't dug more into what the cause might be, but thought I 
should pass it along.

java.lang.NullPointerException
at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:350)
at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:366)
at 
org.andnav.osm.tileprovider.OpenStreetMapAsyncTileProvider$TileLoader.nextTile(O
penStreetMapAsyncTileProvider.java:107)
at 
org.andnav.osm.tileprovider.OpenStreetMapAsyncTileProvider$TileLoader.run(OpenSt
reetMapAsyncTileProvider.java:148)
at java.lang.Thread.run(Thread.java:1102)

Original issue reported on code.google.com by bob.hage...@gmail.com on 16 Aug 2010 at 7:06

GoogleCodeExporter commented 9 years ago
I've also seen this occasionally.  I'm not exactly sure of the reason, but 
presumably a threading/synchronisation issue.  We should at least catch it, 
even if we can't fix it.

Original comment by neilboyd on 17 Aug 2010 at 7:41

GoogleCodeExporter commented 9 years ago
Catch the error in revision 317.

Original comment by neilboyd on 18 Aug 2010 at 7:12

GoogleCodeExporter commented 9 years ago
I've seen something similar too. Mine was "mPending.put(aTile, PRESENT);" in 
OpenStreetMapAsyncTileProvider.java (line 49 in my src) crashing in HashMap.put 
(LinkedHashMap.java:381).

Original comment by invisibl...@gmail.com on 18 Aug 2010 at 10:26

GoogleCodeExporter commented 9 years ago
I've caught that one as well in revision 318.

Original comment by neilboyd on 19 Aug 2010 at 7:25

GoogleCodeExporter commented 9 years ago
Received another one, mPending.clear() in clearQueue():

java.lang.NullPointerExceptionjava.lang.NullPointerException 
at java.util.LinkedHashMap.clear(LinkedHashMap.java:327)
at
org.andnav.osm.tileprovider.OpenStreetMapAsyncTileProvider.clearQueue(OpenSt
reetMapAsyncTileProvider.java:66)
at
org.andnav.osm.tileprovider.OpenStreetMapAsyncTileProvider.access$3(OpenStre
etMapAsyncTileProvider.java:65)
at
org.andnav.osm.tileprovider.OpenStreetMapAsyncTileProvider$TileLoader.run(Op
enStreetMapAsyncTileProvider.java:168)
at java.lang.Thread.run(Thread.java:1096)

Original comment by bob.hage...@gmail.com on 26 Aug 2010 at 2:21

GoogleCodeExporter commented 9 years ago
I also received one here:
java.lang.NullPointerException
at java.util.LinkedHashMap.makeTail(LinkedHashMap.java:271)
at java.util.LinkedHashMap.get(LinkedHashMap.java:257)
at 
org.andnav.osm.views.util.OpenStreetMapTileCache.getMapTile(OpenStreetMapTileCac
he.java:49)
at 
org.andnav.osm.views.util.OpenStreetMapTileProviderDirect.getMapTile(OpenStreetM
apTileProviderDirect.java:35)
at 
org.andnav.osm.views.overlay.OpenStreetMapTilesOverlay.onDraw(OpenStreetMapTiles
Overlay.java:123)
at 
org.andnav.osm.views.overlay.OpenStreetMapViewOverlay.onManagedDraw(OpenStreetMa
pViewOverlay.java:60)
at org.andnav.osm.views.OpenStreetMapView.onDraw(OpenStreetMapView.java:694)
...etc

Original comment by neilboyd on 27 Aug 2010 at 8:10

GoogleCodeExporter commented 9 years ago
Taking a stab at making the map use threadsafe in 
OpenStreetMapAsyncTileProvider and OpenStreetMapTileCache.

Original comment by bob.hage...@gmail.com on 28 Aug 2010 at 1:40

Attachments:

GoogleCodeExporter commented 9 years ago
We've had the discussion about synchronization vs performance many times, but 
the NPE's show that it's still not right. So let's try this fix and see if it's 
better - it looks simple enough to be good ;-)

We should probably remove the catches I added otherwise no-one will notice if 
we're still getting those errors.

Committed in revision 323.

Original comment by neilboyd on 30 Aug 2010 at 9:07

GoogleCodeExporter commented 9 years ago
I removed the catch NPE in revision 325.

Original comment by neilboyd on 2 Sep 2010 at 6:49

GoogleCodeExporter commented 9 years ago
I haven't seen any NPE's since I made this change, and I didn't notice any 
performance degradation, so I think I'll close this now.

Original comment by neilboyd on 10 Sep 2010 at 2:31