Tuesday, April 26, 2011

Minify the size of your XAP file with some help from Telerik

As every good Windows Phone 7 developer knows. It's generally a very good idea to make the size of your XAP file as small as possible. Among other things this can help towards faster app loading times.

For an app I've been working on recently (more off than on) I wanted to get the start up time as short as possible. One of the ways I've been doing this has been to remove unnecessary external libraries and to optimise my use of the ones that I do need.
Now, while I'm a big fan of NuGet sometimes I don't want everything in a library. In this instance I created a version of the library I was using specifically restricted to the functionality that the app needs. I did this by getting the source of the library I was using (well actually libraries as there were 2), added the source project to my solution, excluded everything I didn't need from the project and then linked my app to that project rather than the downloaded copy of the compiled library.

Before I started this process my app was 599Kb. After the above process I got it down to 298Kb but there were still a couple of large assemblies in my XAP file that were bugging me.
These were both from Telerik (part of their WP7 control suite) but as I was just using a small part of the functionality available in those libraries this bugged me. As source wasn't available, I couldn't use the above technique. So I tweeted about it.

A few hours later I had a very interesting response.

It turns out Telerik already have a solution to this problem. It's called the Telerik Minifier and it provides 2 option:
1. You tell it which objects you specifically want and it gives you a set of libraries which contain just those. or
2. You point it at your XAP file and it removes everything it can to make it smaller. (I'm guessing it does the process in option 1 but just manages the updating of the XAP file for you.)

I opted for option 2 and then a minute or so later my XAP file was down to 209Kb in size.

And yes, my app now opens super fast. So fast in fact that I'm not including a Splash Screen!

After some questions about what's actually happening, have a look at the image below.

On the left is the contents of the XAP before minification. On the right is the contents of the XAP after minification. The Telerik controls have been replaced with new versions which only contain the necessary code for running the app.

Monday, April 25, 2011

#WP7Dev app feedback #7

This is part of my series of app reviews.

After a long break I finally got round to providing some more reviews. In the hope that these points (from multiple reviews) will help you think about your apps, here are some of the (anonymized) feedback points:

  • There’s no way (currently) to get back to the settings after first launch. (As you’ve requested location permission this should be a cause to fail marketplace submission)
  • On the first panorama item, I would expect to be able to tap the map image to be able to do something.
  • It might be good to have a quick way to [do something] in either direction. Without having to create 2 [items].
  • The panorama background image doesn't appear to relate to the functionality and content of the app.
  • There doesn’t appear to be a way to un-favourite a[n item].
  • Rather than “Tap to add X” you could just use “add X” as the tapping is implied. Similar also in other places.
  • On the X screen:
    • It strikes me that the available space could be used much better used.
    • Do you need the title? I don’t think so.
    • The transition between “X” and “Y” isn’t obvious. I wondered for a bit what these terms meant. Could you make this clearer for the user? On the first few uses of the app at least?
    • Showing the time that the last location information was received might be a useful addition.
    • When status is “Z” it would be good to also indicate that the app will try and get a location again soon. I did wonder when I first saw this.
  • The help screen seems completely superfluous and this information could be added elsewhere.
  • It would be good if the "contact support" option indicated it was going to try and send an email.
  • I'm not sure that putting the views in a pivot is the best option. I keep accidentally navigating between pivot items when trying to [manipulate the content on screen].
  • The speed of rotation of the 3D model can be quite fast which can make it hard to get the exact position desired. I noticed this when trying to get back to the original view.
  • Could you add a double tap option which would automatically revert the image to the default view?
  • Add support for tombstoning
    • remember the selected pivot item
    • if the [content has been manipulated] then remember this also
  • While it's not possible to use the checkboxes to select more than 6 objects, if you have 6 selected and then add another this is automatically selected and you end up with 7 selected and it doesn't complain.
  • Why can't I edit an item? - even if only the ones I create.
  • your terminology alternates between "item" and "object" within the app.

Here's what one of the creators of the apps thought of my feedback:
"thanks a lot, this is extremely helpful! Running the app I agree with every single point you make (and can't understand how I did not notice these issues before...)"