ganzo55 / osmdroid

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

java.lang.IllegalArgumentException: Problem decoding into existing bitmap #505

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I see many 'Problem decoding into existing bitmap' decoding exceptions in 
osmdroid logs. 
When android cannot reuse bitmap, the decode method throws an 
IllegalArgumentException. This often happens when the server returns a tiles in 
different size, or not in PNG format. This is, for example, when Cloudmade 
(small tiles) layer is selected.

Proposed patch:
https://github.com/illarionov/OsmDroid/commit/90fb9ab31648478087f50b859ec18c9d59
2c9f92

Log:
E/o*.o*.t*.m*.MapTileDow*(17298): Error downloading MapTile: /11/19/1529
E/o*.o*.t*.m*.MapTileDow*(17298): java.lang.IllegalArgumentException: Problem 
decoding into existing bitmap
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:631)
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
org.osmdroid.tileprovider.tilesource.BitmapTileSourceBase.getDrawable(BitmapTile
SourceBase.java:135)
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileD
ownloader.java:213)
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTi
leModuleProviderBase.java:289)
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/o*.o*.t*.m*.MapTileDow*(17298):   at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/o*.o*.t*.m*.MapTileDow*(17298):   at java.lang.Thread.run(Thread.java:856)

Original issue reported on code.google.com by ls.illar...@gmail.com on 21 Dec 2013 at 3:14

GoogleCodeExporter commented 8 years ago
The same problem persists in osmdroid 4.1.

To reproduce, run the OpenStreetMapViewer and select the "Cloudmade (small 
tiles)" layer.

The proposed patch contains the following fixes:
1. Catch 'cannot use this bitmap' exception and fall-back to non-reusable 
bitmaps
2. Throw LowMemoryException on getDrawable(final String aFilePath)
3. Check return value of getDrawable() for null (when 
BitmapFactory.decodeStream() fails)

Throwing and IllegalArgumentException when the bitmap is not equal sized or not 
in JPG/PNG format - is a documented behavior. ( 
http://developer.android.com/reference/android/graphics/BitmapFactory.Options.ht
ml#inBitmap )

Original comment by ls.illar...@gmail.com on 27 Jan 2014 at 3:54

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The patch referenced in the description doesn't exist any more.  I suggest 
making a new issue in github if you want this to get some attention, preferably 
with a pull request.

Original comment by neilboyd on 27 Aug 2014 at 8:11