Loading time MBtiles on SDK 4.0.0 takes long

114 views
Skip to first unread message

rfidt...@gmail.com

unread,
Feb 27, 2017, 4:55:39 AM2/27/17
to Nutiteq-dev
I used SDK 3.3.2 on Android Studio few months ago. I upgraded (my project) to SDK 4.0.0.
Now I a have a big "problem" with loading MBTiles on my MbtilesActivity.
I always use the same MBtile file on 3.3.2 and on 4.0.0 so I can compare the loading time.
On 3.3.2 , the MBTiles is loading very fast but on 4.0.0 It takes too long. I don't know why ?
A problem with memory management ?
I know in the former SDK we used CompressedCacheTileDataSource (or PersistentCacheTileDataSource) and in the new this class [CompressedCacheTileDataSource] does not exist.
I really need help on this topic.

Best regards

aa...@cartodb.com

unread,
Feb 27, 2017, 5:28:22 AM2/27/17
to Nutiteq-dev, rfidt...@gmail.com
Hey,

CompressedCacheTileDataSource  is now called MemoryCacheTileDataSource, using the cache should definitely improve performance.

Best wishes,
Aare
CARTO Mobile

rfidt...@gmail.com

unread,
Feb 27, 2017, 7:12:36 AM2/27/17
to Nutiteq-dev, rfidt...@gmail.com
Hi,
Thank you for your return.
But I use MBTilesTileDataSource and each (MemoryCacheTileDataSource or PersistentCacheTileDataSource) returns TileDataSource.
MBTilesTileDataSource implements TileDataSource, so I can cast MBTilesTileDataSource to TileDataSource (the reverse is not possible). I have to use MBTilesTileDataSource. :(
If you have sample to that (MBTilesTileDataSource + cache) I will be really delighted.

aa...@cartodb.com

unread,
Feb 27, 2017, 8:45:54 AM2/27/17
to Nutiteq-dev, rfidt...@gmail.com

I'll sooon to get to creating an example for you, but in the mean time...

Could you share the files you are having problems with, and perhaps even a code sample? There are actually other reasons the load time might be slower and I'd like to test out my ideas.

rfidt...@gmail.com

unread,
Feb 27, 2017, 10:23:04 AM2/27/17
to Nutiteq-dev, rfidt...@gmail.com
You can find the file at : https://www.dropbox.com/sh/mcmztmrdlldtb24/AADefj1cy8R4AsaSYBP3CuLLa?dl=0

I use the same code on MBTilesActivity : https://github.com/nutiteq/hellomap3d-android/blob/master/com.nutiteq.advancedmap3/src/com/nutiteq/advancedmap3/MbtilesActivity.java

It is urgent for me to find the solution.
Tell me if you can get the Mbtile file.

Best regards

aa...@cartodb.com

unread,
Feb 27, 2017, 10:42:30 AM2/27/17
to Nutiteq-dev, rfidt...@gmail.com

Yeah, I can get the file, thanks. We'll look into it and get back to you soon

rfidt...@gmail.com

unread,
Feb 28, 2017, 11:09:36 AM2/28/17
to Nutiteq-dev, rfidt...@gmail.com
Do you have an answer for this point please ?

aa...@cartodb.com

unread,
Feb 28, 2017, 11:38:53 AM2/28/17
to Nutiteq-dev, rfidt...@gmail.com
Hey,

I'm sorry, I haven't quite gotten around to it just yet.

However, here's an example of how to load .mbtiles from MemoryCacheTileDataSource:

And here's an existing example of the usage of PersistentCacheTileDataSource:

        static PersistentCacheTileDataSource GetCacheDataSource(TileDataSource source, uint sizeInMB, string name)
        {
            string cacheFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + name;
            var cacheDataSource = new PersistentCacheTileDataSource(source, cacheFile);
            uint MEGABYTE = 1048576;
            cacheDataSource.Capacity = sizeInMB * MEGABYTE;
            return cacheDataSource;
        }  

rfidt...@gmail.com

unread,
Feb 28, 2017, 1:03:55 PM2/28/17
to Nutiteq-dev, rfidt...@gmail.com
Thank you very much,
I'll try this early and tell you what happen.

Before all I have a question about this :

if ("pbf".equals(format) || "ntvt".equals(format)) {
UnsignedCharVector styleBytes = AssetUtils.loadBytes("nutibright-v2a.zip");
MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);
VectorTileDecoder vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);
baseLayer = new VectorTileLayer(tileDataSource, vectorTileDecoder);
} else {
baseLayer = new RasterTileLayer(tileDataSource);
}

My MBTile file is not a "ntvt" file so I use a RasterTileLayer instead of VectorTileLayer.

Using Memory manager, from sample, means using VectorTileLayer on my MBTile file.
I will make you a feedback.
Thank you

rfidt...@gmail.com

unread,
Mar 1, 2017, 5:58:30 AM3/1/17
to Nutiteq-dev, rfidt...@gmail.com
Hi,
I am back on this topic.
I used memories manager (Persistent or Memory).
The result does not correspond to my expectations. Unfortunately this did not change the loading time.
1. I use more than one file on my application. I switched on them in my map interface with a button. Using memory cache means to delete/create db file each time.
2. Also, what I do not understand (for the same code) in the old SDK, I did not use cache and loading was done quickly (much fatser than now). I do not know what to do (go back and lose the benefits of the new SDK?).
I can't make a movie for you to show how long it is. :(

aa...@cartodb.com

unread,
Mar 1, 2017, 8:38:57 AM3/1/17
to Nutiteq-dev, rfidt...@gmail.com

Sorry it took so much time to deal with your issue, but I've somewhat pieced it together now.

.mbtiles bundles don't really need to be cached, as they are already present on your device, so just do it without Memory or Persitent. And I tried it with both SDK's (3.3 and 4.0), but could not find a performance difference. Raster tile rendering is simply enough and works the same way.

What I did find, however, was that the .mbiles file itself has some weird nuances: it's not indexed (which worsens performance on either SDK version). My associate is dealing with that problem at the moment.

Possibly because of those issues, I even ran into some other problems and the apps started crashing on me when it was time to render:

[libc] Fatal signal 6 (SIGABRT) at 0x00004d97 (code=-6), thread 19942 (m.carto.testapp)


Best wishes
Aare
CARTO Mobile

aa...@cartodb.com

unread,
Mar 2, 2017, 5:13:53 AM3/2/17
to Nutiteq-dev, rfidt...@gmail.com

It would be too much of a hassle to correct the files. 

What you could additionally do to improve performance is to limit max zoom: zooming out causes more tiles to be generated, tiles that you do not need.

rfidt...@gmail.com

unread,
Mar 17, 2017, 12:23:07 PM3/17/17
to Nutiteq-dev, rfidt...@gmail.com
By following your advice, I tested several MBTiles files but the result is not conclusive.
Could you please (if you have any) send me test files (MBTile files) you use ?

aa...@cartodb.com

unread,
Mar 21, 2017, 9:05:37 AM3/21/17
to Nutiteq-dev, rfidt...@gmail.com

Hey again,

Sorry for the late reply.

You can find some .mbtiles files in our sample projects
I cannot reproduce your performance issue. Would it be possible for you to share your code?
Reply all
Reply to author
Forward
0 new messages