CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
181 stars 65 forks source link

GeoJSONLayer not updated / drawn while HTTPTileDataSource requests are ongoing #492

Open dpattou opened 2 years ago

dpattou commented 2 years ago

Hello, I ran into what I think might be a SDK issue, although I'm not 100% sure. Please let me know if I'm just doing something incorrect / this is normal behavior :)

I'm using the mobile SDK 4.4.4, via the nativescript-carto plugin.

I'm displaying a track and some other elements on a GeoJSONLayer (styled using carto css), which sits on top of a RasterTileLayer loading tiles from map tiler via a HTTPTileDataSource. I'm also displaying the user location on a VectorLayer.

Everything seems to be working fine when the phone's network is good or completely turned off. However, if the network is really bad (or, to easily reproduce the issue, set to EDGE / Poor on the Android simulator), I'm running into an issue where the GeoJSONLayer stops updating while the HTTPTileDataSource is issuing requests to map tiler. Sometimes, it can take about a minute for a request to timeout or to complete, and during this whole minute, the GeoJSONLayer, and thus the track and other elements, are no longer drawn.

This happens on new / not yet downloaded tiles that the HTTPTileDataSource is trying to load, which is a big issue, but if moving the map around and playing with zoom a bit the whole track (or most of it) ends up disappearing from the screen...

When switching back (using the simulator) to a good network connection, new tiles are loaded and the GeoJSONLayer is re drawn normally.

All this time, the user marker displayed on the VectorLayer is correctly drawn and visible.

Below are a few logs which show the GeoJSONLayer updating and as soon as an call to map tiler is made by the HTTPTileDataSource, update logs (and actual updates ;) ) stop, and if looking at the log timestamps, we can clearly see that this can happen for more than a minute.

I may be be able to avoid this issue by drawing everything I'm drawing on the GeoJSONLayer on the VectorLayer instead but this would have some drawbacks so any help to resolve or work around this issue would be very much appreciated :)

Thank you !

Logs:

03-14 16:46:52.910  5517  5517 I carto-mobile-sdk: BaseMapView: Build: android-"|master|release/v4.4.4", time: Jan 11 2022 16:40:20, device type: sdk_gphone_x86, device OS: 11
03-14 16:46:53.162  5517  5647 D carto-mobile-sdk: ConfigChooser.chooseConfig: Model: sdk_gphone_x86, board: goldfish_x86, product: sdk_gphone_x86
03-14 16:46:53.169  5517  5647 D carto-mobile-sdk: ConfigChooser.chooseConfig: Selected display configuration: 0
03-14 16:46:53.190  5517  5647 I carto-mobile-sdk: BaseMapView::onSurfaceCreated()
03-14 16:46:53.202  5517  5647 I carto-mobile-sdk: BaseMapView::onSurfaceChanged(): width: 1080, height: 1370
03-14 16:46:53.273  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 0)
03-14 16:46:53.275  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 1)
03-14 16:46:53.288  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:46:53.289  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=2, y=0, zoom=2, frameNr=0, id=7]
03-14 16:46:53.304  5517  5649 D c
<img width="348" alt="Capture d’écran 2022-03-16 à 10 19 31" src="https://user-images.githubusercontent.com/6225820/158557585-3f72d29f-625a-4802-995e-8e7d7c51db82.png">
<img width="353" alt="Capture d’écran 2022-03-16 à 10 18 42" src="https://user-images.githubusercontent.com/6225820/158557591-406f2b3d-5280-46e6-9c42-636f2e53b621.png">
<img width="355" alt="Capture d’écran 2022-03-16 à 10 17 51" src="https://user-images.githubusercontent.com/6225820/158557596-98543c15-d275-4297-a270-21237e2c6202.png">
arto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 0)
03-14 16:46:53.304  5517  5647 D carto-mobile-sdk: TileRenderer: Initializing renderer
03-14 16:46:53.304  5517  5647 D carto-mobile-sdk: VTRenderer::create: Creating renderer
03-14 16:46:53.368  5517  5651 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/2/2/0.png?key=w2HhwN0xz73R1iQIQQDh
03-14 16:46:53.368  5517  5651 I carto-mobile-sdk: AndroidUtils::AttachCurrentThread: Attaching current thread to JNI
03-14 16:46:53.370  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=2, y=1, zoom=2, frameNr=0, id=11]
03-14 16:46:53.387  5517  5647 D carto-mobile-sdk: TileRenderer: Initializing renderer
03-14 16:46:53.388  5517  5647 D carto-mobile-sdk: VTRenderer::create: Creating renderer
03-14 16:46:53.446  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:46:53.494  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=4238, y=2985, zoom=13, frameNr=0, id=46826979]
03-14 16:46:53.507  5517  5517 W carto-mobile-sdk: Bitmap: Warning while loading PNG: iCCP: known incorrect sRGB profile
03-14 16:46:53.518  5517  5517 W carto-mobile-sdk: Bitmap: Warning while loading PNG: iCCP: known incorrect sRGB profile
03-14 16:46:53.570  5517  5652 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=4237, y=2985, zoom=13, frameNr=0, id=46826978]
03-14 16:46:53.672  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 0)
03-14 16:46:53.768  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=16952, y=11943, zoom=15, frameNr=0, id=749279117]
03-14 16:46:53.957  5517  5648 D carto-mobile-sdk: ConfigChooser.chooseConfig: Model: sdk_gphone_x86, board: goldfish_x86, product: sdk_gphone_x86
03-14 16:46:53.977  5517  5648 D carto-mobile-sdk: ConfigChooser.chooseConfig: Selected display configuration: 0
03-14 16:46:54.148  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 1)
03-14 16:46:54.188  5517  5648 I carto-mobile-sdk: BaseMapView::onSurfaceCreated()
03-14 16:46:54.214  5517  5648 I carto-mobile-sdk: BaseMapView::onSurfaceChanged(): width: 1080, height: 660
03-14 16:46:54.221  5517  5629 D carto-mobile-sdk: GLResourceManager::~GLResourceManager: Delete queue size: 7
03-14 16:46:54.225  5517  5637 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=4238, y=2985, zoom=13, frameNr=0, id=46826979]
03-14 16:46:54.240  5517  5635 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=4238, y=2985, zoom=13, frameNr=0, id=46826979]
03-14 16:46:54.240  5517  5648 D carto-mobile-sdk: TileRenderer: Initializing renderer
03-14 16:46:54.240  5517  5648 D carto-mobile-sdk: VTRenderer::create: Creating renderer
03-14 16:46:54.241  5517  5648 D carto-mobile-sdk: TileRenderer: Initializing renderer
03-14 16:46:54.241  5517  5648 D carto-mobile-sdk: VTRenderer::create: Creating renderer
03-14 16:46:54.246  5517  5637 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=4237, y=2985, zoom=13, frameNr=0, id=46826978]
03-14 16:46:54.655  5517  5652 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47772, zoom=17, frameNr=0, id=11988262455]
03-14 16:46:54.764  5517  5652 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67810, y=47772, zoom=17, frameNr=0, id=11988262455]
03-14 16:46:54.771  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67809, y=47772, zoom=17, frameNr=0, id=11988262454]
03-14 16:46:54.779  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67809, y=47772, zoom=17, frameNr=0, id=11988262454]
03-14 16:46:54.782  5517  5652 D carto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 2)
03-14 16:46:54.788  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95543, zoom=18, frameNr=0, id=47952652057]
03-14 16:46:54.801  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95543, zoom=18, frameNr=0, id=47952652056]
03-14 16:46:54.802  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95544, zoom=18, frameNr=0, id=47952914201]
03-14 16:46:54.806  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95544, zoom=18, frameNr=0, id=47952914200]
03-14 16:46:54.808  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95545, zoom=18, frameNr=0, id=47953176345]
03-14 16:46:54.818  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95545, zoom=18, frameNr=0, id=47953176344]
03-14 16:46:54.827  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135620, y=95543, zoom=18, frameNr=0, id=47952652057]
03-14 16:46:54.834  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135619, y=95543, zoom=18, frameNr=0, id=47952652056]
03-14 16:46:54.863  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135620, y=95544, zoom=18, frameNr=0, id=47952914201]
03-14 16:46:54.872  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135619, y=95544, zoom=18, frameNr=0, id=47952914200]
03-14 16:46:54.941  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135620, y=95545, zoom=18, frameNr=0, id=47953176345]
03-14 16:46:54.986  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135619, y=95545, zoom=18, frameNr=0, id=47953176344]
03-14 16:46:58.872  5517  5647 I carto-mobile-sdk: BaseMapView::onSurfaceChanged(): width: 1080, height: 1634
03-14 16:46:58.886  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95542, zoom=18, frameNr=0, id=47952389913]
03-14 16:46:58.908  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95542, zoom=18, frameNr=0, id=47952389912]
03-14 16:46:58.965  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:46:59.031  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47771, zoom=17, frameNr=0, id=11988131383]
03-14 16:46:59.050  5517  5664 D carto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 2)
03-14 16:46:59.066  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135620, y=95542, zoom=18, frameNr=0, id=47952389913]
03-14 16:46:59.107  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:46:59.169  5517  5665 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67810, y=47771, zoom=17, frameNr=0, id=11988131383]
03-14 16:46:59.188  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135619, y=95542, zoom=18, frameNr=0, id=47952389912]
03-14 16:46:59.213  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95543, zoom=18, frameNr=0, id=47952652058]
03-14 16:46:59.217  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95542, zoom=18, frameNr=0, id=47952389914]
03-14 16:46:59.223  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95544, zoom=18, frameNr=0, id=47952914202]
03-14 16:46:59.263  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135621, y=95544, zoom=18, frameNr=0, id=47952914202]
03-14 16:46:59.265  5517  5650 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135621, y=95543, zoom=18, frameNr=0, id=47952652058]
03-14 16:46:59.272  5517  5665 D carto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 2)
03-14 16:46:59.276  5517  5651 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135621, y=95542, zoom=18, frameNr=0, id=47952389914]
03-14 16:47:00.871  5517  5647 I carto-mobile-sdk: BaseMapView::onSurfaceChanged(): width: 1080, height: 1370
03-14 16:47:01.224  5517  5517 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:47:01.225  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47772, zoom=17, frameNr=0, id=11988262455]
03-14 16:47:01.257  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67809, y=47771, zoom=17, frameNr=0, id=11988131382]
03-14 16:47:01.258  5517  5651 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47771, zoom=17, frameNr=0, id=11988131383]
03-14 16:47:01.293  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95544, zoom=18, frameNr=0, id=47952914200]
03-14 16:47:01.300  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95542, zoom=18, frameNr=0, id=47952389913]
03-14 16:47:01.581  5517  5651 D carto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 1)
03-14 16:47:01.581  5517  5651 I carto-mobile-sdk: AndroidUtils::DetachCurrentThread: Detaching current thread from JNI
03-14 16:47:01.585  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95542, zoom=18, frameNr=0, id=47952389914]
03-14 16:47:01.597  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95543, zoom=18, frameNr=0, id=47952652057]
03-14 16:47:01.597  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95543, zoom=18, frameNr=0, id=47952652058]
03-14 16:47:01.608  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95542, zoom=18, frameNr=0, id=47952389912]
03-14 16:47:01.614  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95543, zoom=18, frameNr=0, id=47952652056]
03-14 16:47:01.617  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95544, zoom=18, frameNr=0, id=47952914201]
03-14 16:47:01.617  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95544, zoom=18, frameNr=0, id=47952914202]
03-14 16:47:03.499  5517  5517 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:47:03.510  5517  5650 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67809, y=47771, zoom=17, frameNr=0, id=11988131382]
03-14 16:47:03.577  5517  5650 D carto-mobile-sdk: CancelableThreadPool: Removing worker from the pool (size 0)
03-14 16:47:03.603  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47771, zoom=17, frameNr=0, id=11988131383]
03-14 16:47:03.608  5517  5671 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95542, zoom=18, frameNr=0, id=47952389913]
03-14 16:47:03.661  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95542, zoom=18, frameNr=0, id=47952389914]
03-14 16:47:03.661  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95543, zoom=18, frameNr=0, id=47952652057]
03-14 16:47:03.704  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95543, zoom=18, frameNr=0, id=47952652058]
03-14 16:47:03.730  5517  5671 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95542, zoom=18, frameNr=0, id=47952389912]
03-14 16:47:03.751  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95543, zoom=18, frameNr=0, id=47952652056]
03-14 16:47:03.981  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67810, y=47770, zoom=17, frameNr=0, id=11988000311]
03-14 16:47:03.984  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135619, y=95541, zoom=18, frameNr=0, id=47952127768]
03-14 16:47:03.985  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135621, y=95541, zoom=18, frameNr=0, id=47952127770]
03-14 16:47:03.986  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=135620, y=95541, zoom=18, frameNr=0, id=47952127769]
03-14 16:47:04.052  5517  5671 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67810, y=47770, zoom=17, frameNr=0, id=11988000311]
03-14 16:47:04.052  5517  5671 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/17/67810/47770.png?key=w2HhwN0xz73R1iQIQQDh
03-14 16:47:04.052  5517  5671 I carto-mobile-sdk: AndroidUtils::AttachCurrentThread: Attaching current thread to JNI
03-14 16:47:04.053  5517  5670 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135619, y=95541, zoom=18, frameNr=0, id=47952127768]
03-14 16:47:04.117  5517  5670 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=135621, y=95541, zoom=18, frameNr=0, id=47952127770]
03-14 16:47:04.117  5517  5670 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/18/135621/95541.png?key=w2HhwN0xz73R1iQIQQDh
03-14 16:47:04.118  5517  5670 I carto-mobile-sdk: AndroidUtils::AttachCurrentThread: Attaching current thread to JNI
03-14 16:47:14.399  5517  5643 D carto-mobile-sdk: CancelableThreadPool: Adding worker to the pool (size 2)
03-14 16:47:14.407  5517  5675 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67809, y=47770, zoom=17, frameNr=0, id=11988000310]
03-14 16:47:14.433  5517  5675 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67809, y=47770, zoom=17, frameNr=0, id=11988000310]
03-14 16:47:14.433  5517  5675 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/17/67809/47770.png?key=w2HhwN0xz73R1iQIQQDh
03-14 16:47:14.433  5517  5675 I carto-mobile-sdk: AndroidUtils::AttachCurrentThread: Attaching current thread to JNI
03-14 16:47:26.850  5517  5670 I carto-mobile-sdk: GeoJSONVectorTileDataSource::loadTile: Loading MapTile [x=67809, y=47769, zoom=17, frameNr=0, id=11987869238]
03-14 16:47:26.852  5517  5670 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67809, y=47769, zoom=17, frameNr=0, id=11987869238]
03-14 16:47:26.852  5517  5670 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/17/67809/47769.png?key=w2HhwN0xz73R1iQIQQDh
03-14 16:48:38.384  5517  5671 I carto-mobile-sdk: PersistentCacheTileDataSource::loadTile: Loading MapTile [x=67810, y=47767, zoom=17, frameNr=0, id=11987607095]
03-14 16:48:38.384  5517  5671 I carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading https://api.maptiler.com/maps/outdoor/17/67810/47767.png?key=w2HhwN0xz73R1iQIQQDh

Note: The HTTPTileDataSource is wrapped in a PersistentCacheDataSource, but using the HTTPTileDataSource directly doesn't solve the issue.

2nd note: I'm also running into the issue in another 'mode' where I'm using an OrderedTileDataSource, with an offline (cache only) and online data source with different zoom levels. While the requests from the online data source are ongoing, 'gray' tiles are shown and no data from either the offline data source or GeoJSONLayer is drawn.

dpattou commented 2 years ago

Screenshots:

Capture d’écran 2022-03-16 à 10 19 31 Capture d’écran 2022-03-16 à 10 18 42 Capture d’écran 2022-03-16 à 10 17 51
mtehver commented 2 years ago

@dpattou Sorry for the late reply. SDK uses a shared pool of background processes to handle requests to tile data sources. My guess is that due to slow network connection, these processes get stuck and new requests are queued. You can give some layers a higher priority though (like your GeoJSONVectorTileLayer), by using layer.setUpdatePriority(N) where N should be > 0.

Regarding the 2nd issue, I am not sure this issue can be really solved as once the online data source gets stuck, new requests will not be handled until the data source manages to handle the request or receives a timeout.

farfromrefug commented 2 years ago

@mtehver but then why would it prevent the local vector data source from drawing? I understand that the background pool might be stuck but it should prevent a local data source from drawing. There is no "request" on the local vector data source

mtehver commented 2 years ago

@farfromrefug All data source requests are submitted to pools. There are 2 pools: one for tile data sources and one for non-tile data sources. Thus GeoJSONVectorTileDataSource instances share the same pool with HTTPTileDataSource instances.

An important technical detail: if pools are busy (all available threads are already executing a task) but a new task comes in with a higher priority, pools will dynamically grow and the task will be executed without delay. This was implemented pre 4.4.0, I believe.

farfromrefug commented 2 years ago

@mtehver thanks for explaining ! this clarifies it a lot

dpattou commented 2 years ago

Thanks for the answer @mtehver. Sorry for the delay, I was away for quite a while.

Using layer.setUpdatePriority(N) seems to indeed solve the 1st issue and the GeoJSONLayer is correctly drawn while tiles are loading. Great, thanks !

Regarding the 2nd issue, is there a way to set a lower timeout duration ? This would improve the user experience a lot if it could be set to 10-20seconds. Currently, it can sometime hang for more than a minute, and iOS frequently logs the following message:

Background Task 10 (“<private>“), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

jarmani commented 2 years ago

Hi @mtehver,

Any ideas about the timeout duration ?

In poor mobile network condition it really makes the whole map unusable.

mtehver commented 2 years ago

@jarmani By default we do not change platform-specific timeouts of network connections. In case of Android, SDK uses HttpURLConnection which may not have a finite timeout at all. So indeed, in case of bad network conditions, map may become 'stuck'.

I will add setTimeout methods to CartoOnlineTileDataSource, HTTPTileDataSource and MapTilerOnlineDataTileDataSource in SDK 4.4.6.

mtehver commented 2 years ago

@jarmani @dpattou setTimeout for online tile data sources is now available in 4.4.6-rc.1.

jarmani commented 2 years ago

Amazing, thanks !