This project has moved. For the latest updates, please go here.

Very weird performance issue depending on swiping gesture type

Oct 5, 2014 at 8:53 PM
Edited Oct 7, 2014 at 8:50 PM

First of all, I'd like to thank you for your work on this MapControl. It's GREAT. Much much MUCH better than the Microsoft's MapControl - it's unbeliveable how they decided to release such a poor control, when we have this alternative of yours.

The map itself works very well, it's API is also definitely more powerful. But I have a very serious problem relted to the performance. I intent to use this control to display pushpins - quite many of them. I'd like them to be more than 500, but map starts to fail on performance even with 20 elements. But that's not a case here.

What is a problem, is the fact that if I add these pushpins to the map, like that:
    <map:Map x:Name="Map"
             Center="{Binding Location}"

      <map:MapItemsControl ItemContainerStyle="{StaticResource PushpinItemStyle}"
                           ItemsSource="{Binding Pushpins}" />
where PushpinItemStyle defines simple Template:
    <Style x:Key="PushpinItemStyle"
      <Setter Property="local:BindingHelper.LocationPath" Value="Location" />
      <Setter Property="Template">
          <ControlTemplate TargetType="map:MapItem">
              <Image Source= {Binding ImageSource} />
navigating through the map is very hard! It's really slow, but it depends on thew navigation type:
  1. If I barely touch the screen and swipe a little (let the map 'stop itself'), it moves quite well - I mean, it's not as good as if there would not be any elements, but it's fine.
  2. If I touch the the screen, move finger from one point A to point B without taking a finger off the screen, the map just freezes for a moment, and then shows the final repositioned result. There's no moving of the map, no animation, just user gesture, freeze moment, and the final effect. It's really annoying, can't use the map.
Do you know what might cause such a problem? I'm almost more than sure that it's not the performance issue after all, becuase if I navigate via option 1., it all works ok. It's something with the gesture handling, but I have no idea where to start investigating this problem. Could you guide me a little bit? Or maybe I'm adding custom images (pushpins) to the map in a wrong way? Thanks in advance for any reply! And once more, thanks for this control : )
Oct 6, 2014 at 9:28 PM
This is a Windows 8.1 Store App? And how large are your images? Let me see if I can reproduce this behavior.
Oct 6, 2014 at 11:56 PM
It's Universal App (I'm making an application for Windows Phone 8.1 - it's Windows Runtime). Images are relatively small - simple .png 32x32 image.

I'm almost sure that it's performance problem per se - if I, let's call it, swipe the map from, it's performance is quite allright - so it must be related to the way that second gesture gets handled.

If you want I can prepare for you a simple project to help you reproduce the problem - just say a word : ) Thanks for replying Clemens! This MapControl is so much better than Microsoft's.
Oct 7, 2014 at 5:14 PM
Edited Oct 7, 2014 at 5:24 PM
Tried to reproduce that behaviour, but without success. I've created a view model like this
    public class ViewModel
        public ObservableCollection<Pushpin> Pushpins { get; set; }

    public class Pushpin
        public Location Location { get; set; }
        public ImageSource ImageSource { get; set; }
then put 100 different small images (BitmapImage with DecodePixelHeight set to 32) in the ImageSource property of 100 Pushpins and set their Location property to some random values. I also use exactly your ItemContainerStyle.

The map control can be manipulated smoothly by either swiping or flicking (i.e. with leaving finger down or lifting it up).

I'm running that on a Core i7, 3200x1800 pixels laptop with 64-bit Windows 8.1
Oct 7, 2014 at 8:49 PM
That is basicaly the same thing I've in my project. The point is, on my emulator it also works great, it's absolutely smooth. Problem arises when I deploy an app on the device - then the performance drops big time. I'm using Lumia 520 and Lumia 630 for testing purposes

I realise that they're high end phones, but, unfortunately, the majority of the users will more likely have slower than faster phones ; )

As I've stated before, my guess it's not a problem of low RAM or processor consumption, because if I'm swiping, the MapControl handles it pretty smooth. It has to be something really tiny and silly.
Oct 7, 2014 at 9:33 PM
I'll try this on my Lumia 630, tomorrow...
Oct 7, 2014 at 10:09 PM
That would be great, thank you very much for your contribution!
Oct 8, 2014 at 9:01 PM
Edited Oct 8, 2014 at 11:02 PM
Ok, I've now tried this on my Lumia 630, and although it works quite well with only 20 items, performance gets pretty poor with e.g. 40 items.

To be honest, I've got no idea why the performance is so much different when these two gestures are performed. Both simply generate ManipulationDelta events, which result in repeated invocations of the OnManipulationDelta method in Map.WinRT.cs. The only differerence is that the one ManipulationDelta events are generated by touch input, whereas the others are generated by manipulation inertia, but the code executed in the map control is identical. Perhaps the call frequency is different, i.e. higher in the first case.

I'll keep investigating this issue.
Nov 13, 2014 at 12:44 AM
Hello Clemens,

Were you been able to find anything that could help address this issue? Unfortunately, I wasn't able to fix the problem. I was playing around with ManipulationDelta event, lower the amount of calls to the delegated method handler, but with no success. If you want, I can explain a little more with code snippets what I've tried, but I don't think it could bring something new to the table. I would really appreciate your help on that, I ran out of ideas : (
Nov 13, 2014 at 8:41 PM
After taking another look I realized that the performance bottleneck seems to be that MapPanel updates the ViewportPosition attached property on each element that has a Location set. I still don't understand why this has a bad effect only when a touch is active, since in either case it's just a ManipulationDelta event that is handled. However I guess I could perhaps eliminate the ViewportPosition property anyway, so please be patient until the next release, which is soon to come.
Nov 13, 2014 at 10:44 PM
Oh, I see.. didn't come up with that :( I know I am quite demanding, but I'm running out of time in which I have to decide what type of map control shall I use. I'm not trying to rush you, or anything like that, but could you please tell me - more or less - when do you plan to release next version? It's matter of days, weeks or months? Thanks Clemens in advance, once again! ; )
Nov 14, 2014 at 6:44 AM
I'm going to release the next version in a couple of days, not sure when exactly. Meanwhile you could do a quick test to see if your performance problem is gone by commenting out the following line in MapPanel.cs:
private static void SetViewportPosition(UIElement element, MapBase parentMap, Location location)
    // element.SetValue(ViewportPositionProperty, viewportPosition);