moagrius / MapView

(Deprecated, prefer https://github.com/moagrius/TileView) Android widget roughly described as a hybrid between com.google.android.maps.MapView and iOS's CATiledLayer
http://moagrius.github.com/MapView/documentation
69 stars 35 forks source link

Parallel decoding #50

Closed mohlendo closed 11 years ago

mohlendo commented 11 years ago

While using the HTTP based tile decoder I had a lot of performance issues with the rendering of the tiles. The current implementation does the decoding of the tiles in one background thread and when all tiles have been decoded, the tiles are rendered on the UI thread. This means that you have to wait for all tiles to load, which might take some time when using HTTP, until they are rendered. In this pull request I have introduced another way of decoding the tiles. There is still one background thread that is started for the list of tiles, but this background thread starts new threads for every tile and downloads/renderes them individually. The enclosing background thread only manages the individual threads and cancels them if needed. For me this brings a lot of "visual" performance because every tile is now rendered directly after it was decoded and has not wait for the others.

moagrius commented 11 years ago

Looks very interesting! I'll definitely check it out in the next few days...

One clarifiaction though - the existing implementation does not wait for all tiles to be decoded before rendering them. As each is decoded, publishProgress is passed to the UI thread for rendering. That said, AsyncTask does use a single thread (which is easier to manage), but I'm very interested to see how the ExecutorService works in practice.

I'll post back - thanks.

moagrius commented 11 years ago

I've cloned the AsyncTask from API 11 that allows a ThreadPoolExecutor. This will be included in the next minor update, hopefully this week. Thanks!