Skip to main content

Observing network traffic for Bing Maps control in WP7

Using the Bing Maps control in a WP7 app can incur a rather large memory cost when compared to the rest of an app. Typically I see an initial cost of approximately 8 Mb to show a full screen map when the zoom level is set to 16. This is not a concern, and in my opinion this shouldn't be either. Whats interesting to see is whats happen under the covers from a network perspective and to see if I can see any correlation. None of the following has any scientific basis, more a set of observations.

This is very simple to do, all we need to do is configure the WIFI on the device and then reconfigure Fiddler for remote connections. You can find all the detailed required in this great post by Eric Law.

For the observations I used a modified version of the app from the 'How many pins...' post I did a couple of weeks ago. It only shows the map control it does not display any pins.

When the app is initially installed and run for the first time I'm observing the following network traffic in Fiddler:



You can see there are approximately 35 requests for tiles when the app initially starts, as expected the low resolution tiles are requested first followed by higher resolution. Interestingly the largest tile in png format is only 25 Kb in size.Even if we multiplied 35 by 25 we don't get anywhere near the 8 Mb figure. Infact it only totals about 875 Kb. What we have to remember is, PNG is a bitmapped image format employing a lossless compression format.

Lets see the cost of loading one of these single tiles into an Image control, shown below is the tile and the a test app which loads the tile into the Image control when button the is clicked. I've also stuck on a couple of memory counters.



You can see from loading the image explicitly there is a memory cost associated approximately 600 Kb for this tile. If this was multipled by 25 we'd get a total memory cost of 15 Mb. This is a theoretical total figure but even if it was approaching half this size for the tiles downloaded in the Fiddler screenshot you can see the Bing Maps control is already managing the memory allocated internal already without even approaching the 90 Mb limit.

The next observation was around restarting the application. I observed the tiles were being cached for the app. Whether these are cached by the control for all apps or on a per app basis is unclear. Each response for a tile has HTTP caching directives and these state the tile can be cached for a year - 365 days. The screenshot show 2 restarts of the application, once immediately after closing the app and the second after rebooting the device.


The final observation is the most obvious as I scroll & zoom in and out of the map, I see alot of requests for tiles as expected, the interesting part is it appears the control makes maximum of 5 simultaneous requests for tiles. This was pretty hard to capture but the following screenshot shows 3 outstsanding requests:








Comments

Popular posts from this blog

Implementing a busy indicator using a visual overlay in MVVM

This is a technique we use at work to lock the UI whilst some long running process is happening - preventing the user clicking on stuff whilst it's retrieving or rendering data. Now we could have done this by launching a child dialog window but that feels rather out of date and clumsy, we wanted a more modern pattern similar to the way <div> overlays are done on the web. Imagine we have the following simple WPF app and when 'Click' is pressed a busy waiting overlay is shown for the duration entered into the text box. What I'm interested in here is not the actual UI element of the busy indicator but how I go about getting this to show & hide from when using MVVM. The actual UI elements are the standard Busy Indicator coming from the WPF Toolkit : The XAML behind this window is very simple, the important part is the ViewHost. As you can see the ViewHost uses a ContentPresenter element which is bound to the view model, IMainViewModel, it contains 3 child v

Showing a message box from a ViewModel in MVVM

I was doing a code review with a client last week for a WPF app using MVVM and they asked ' How can I show a message from the ViewModel? '. What follows is how I would (and have) solved the problem in the past. When I hear the words ' show a message... ' I instantly think you mean show a transient modal message box that requires the user input before continuing ' with something else ' - once the user has interacted with the message box it will disappear. The following solution only applies to this scenario. The first solution is the easiest but is very wrong from a separation perspective. It violates the ideas behind the Model-View-Controller pattern because it places View concerns inside the ViewModel - the ViewModel now knows about the type of the View and specifically it knows how to show a message box window: The second approach addresses this concern by introducing the idea of messaging\events between the ViewModel and the View. In the example below

Custom AuthorizationHandler for SignalR Hubs

How to implement IAuthorizationRequirement for SignalR in Asp.Net Core v5.0 Been battling this for a couple of days, and eventually ended up raising an issue on Asp.Net Core gitHub  to find the answer. Wanting to do some custom authorization on a SignalR Hub when the client makes a connection (Hub is created) and when an endpoint (Hub method) is called:  I was assuming I could use the same Policy for both class & method attributes, but it ain't so - not because you can't, because you need the signatures to be different. Method implementation has a resource type of HubInnovationContext: I assumed class implementation would have a resource type of HubConnectionContext - client connects etc... This isn't the case, it's infact of type DefaultHttpContext . For me I don't even need that, it can be removed completely  from the inheritence signature and override implementation. Only other thing to note, and this could be a biggy, is the ordering of the statements in th