Mapbox Brutile Async Layer slowdowns and panning artifacts

Topics: WinForms Controls
May 14, 2016 at 12:08 PM
Edited May 14, 2016 at 4:39 PM
Hello Felix

I noticed some strange or wrong behaviour with the mapbox control using a brutile async layer. This is the main code, very simple:
        Dim tileSource1 = BruTile.Predefined.KnownTileSources.Create(BruTile.Predefined.KnownTileSource.BingHybrid)
        Dim Newlay As New SharpMap.Layers.TileAsyncLayer(tileSource1, "Bing Hybrid")
        MapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan
If you turn on MapBox1.ShowProgressBar, tiles seems to be drawn like in groups. Rendering seems to stops some time, and suddenly ten or more tiles are drawn at once, making the mapbox like laggy.
On the other side, with ShowProgressBar turned off, you can notice how tiles are drawn 1 by 1, very fast, with no lag for the user.

This behaviour it's noticeable also when you set SetToolsNoneWhileRedrawing to true, but less pronounced. Sometimes seems to work ok, sometimes mapbox seems laggy and drawing tiles "by groups".

With pan as the mapbox active tool and using a brutile async layer, if you click and move mouse to pan while tiles are still being downloading (and painted) to complete the map background (base map), map seems to move from the actual panning positiong to previous map center point each time a tile is painted.
I think this behaviour could be related to mapbox trying to paint tiles received after click to pan event. You can notice how a few tiles are drawn after click to pan, and then tile draw stops.
This is the result of panning a map while it's still downloading/drawing tiles, notice the missplaced tiles. Map redraws ok after stopping pan action.

Kind regards.
May 17, 2016 at 1:47 PM
Is this a new issue or has that been that way for quite some time.
Or do you use a precompiled binary (SharpMap 1.1) or did you compile SharpMap yourself?
Nov 29, 2016 at 10:56 PM
Edited Nov 29, 2016 at 11:05 PM
Hi Felix

Got this GIS project on stand-by for a few months... now I'm back with it.

About artifacts or strange behaviour when panning, I can reproduce this bug in the winform samples. Choose 2nd option (Async Tile Layers), maximize the window in order to force more tiles to be load each time you pan the map, and start panning repeatedly while are still some tiles to be downloaded/drawn.
You will notice that the map seems to pan ok, but suddenly it makes a kind of rollback movement. I think is related to when a tile "arrives" while you are still panning, maybe it could be solved if you stop drawing tiles if panning is active, but inquiring sharpmap code for that exceeds my programming skills.

I tried with Debug-Any CPU and Release-Any CPU compiling options, got the same result. I'm using VS 2015 express.

Kind Regards.

P.D. This behaviour occurs also using .shp files with AsyncLayerProxyLayer
Dec 1, 2016 at 8:08 AM
I can confirm this behavior now. It seems to be barely noticable with high speed internet connection.
Here is the issue:
Dec 2, 2016 at 4:00 PM
Please notice that while you are panning the map, if a tile arrives, mapbox seems to "come back" to draw the tile, moving the current map center position back and forward.
I think this behaviour occurs also when connecting to a slow WMS server, not only with slow internet connection. You can check the Spanish land registry WMS server if you want to be annoyed by slow loading:

To deal with this kind of problems currently I set the OnlyRedrawWhenComplete property to true in TileAsyncLayer; no inmediate tile drawing but no panning problems.