BT

Performance Tips For Metro Style XAML Apps

by Roopesh Shenoy on May 30, 2012 |

Microsoft has published a paper named “Performance Tips For Metro Style XAML Apps”. This includes several suggestions for remaining responsive, ensuring fluid animations, improving startup time, consuming lesser resources and more. We present a summary here.

UI related -

Animations -

  • Let Animations be independent (of the UI thread) wherever possible
  • Minimize overdraw – for e.g. by collapsing completely obscured elements, using composite elements instead of layering objects
  • Use ‘CacheMode’ for caching a canvas if the elements don’t change/animate
  • Avoid Animating Web View

Startup times -

  • Improve perception by using Splash Screens, Loading pages, background loading of data
  • Minimize XAML to be parsed at startup
  • Optimize Element Count
  • If it does not make much difference, combine assemblies – loading one large assembly typically takes lesser time than loading two small ones

App Process Lifetime -

  • Suspend before termination – an app has upto 5 seconds to save it’s data on suspending before it is terminated.
  • Serialize and de-serialize only data that has changed
  • Free as much memory as possible on suspension and release handles to files and devices. However also design to resume quickly
  • Reuse brushes between pages by creating them as ResourceDictionary elements – this can improve caching

Displaying Data -

  • Use UI virtualization i.e. create only those objects that are near to the view port, and Data virtualization i.e. read large data sets in small increments as and when needed
  • Use Item template selectors

Media -

  • Use full screen playback when possible
  • Don’t overlay embedded video
  • Delay setting the source of the MediaElement
  • Match Video/Image resolution with device resolution if possible
  • For Windows 8, Microsoft recommends H.264 video as the primary video format and AAC and MP3 as the preferred audio formats. Use WAV when including short audio effects (such as in games)

The paper by Microsoft contains detailed explanation with code samples. There is a separate article on DirectX and XAML interop which is not covered in this paper. 

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT