windows phone 7 - real world performance challenges
Post on 20-Aug-2015
2.427 Views
Preview:
TRANSCRIPT
WP7 Performance Challenges
• My Experience
• Everyday performance challenges
• Visually rich app performance challenges
• Computing intense performance challenges
Cocktail Flow Challenges
• Serialization / Deserilaization
• Animations
• Downloading packages: networking
• Rich ListBoxes
• Emulator vs physical device
Visiblox Charts for WP7 Challenges
• Avoiding overloading of the UI thread
• Realtime drawing on the screen– How fast can you draw on the phone?
• Memory Leaks
• Data binding
• DPs
Networking & the UI
• WebClient: simple, easy
• … runs on the UI thread!• HttpWebRequest: complicated &performant
Serialization & Deserialization
• Binary Serialization• DataContractSerializer• Json.NET• sharpSerializer• Mike Talbot’s Silverlight Serializer• Sterling Isolated Storage DB• Ninja Database Pro
ListBox
• Cool in the beginning
• Rusty when you start adding stuff
• Awfully slow when you start tweaking visuals
• Pain to make it half as fast as on the iPhone
ListBox
• Slow with > 50-200 elements• Virtualized, but….• Several workarounds– Windows Phone Team: ListBox best practices– 3rd party Listbox (Telerik)– Implement paging
Emulator vs Physical Device
• Emulator usually 2-5x times faster• GPU intensive tasks: emulator can be slower
• Test (frequently) on the device
Frame Rate Counters
• FPS (render > 30, UI > 15)• Texture mem. usage• Fill Rate (<2.5)• Blog post explaining these
BitmapCache vs No Caching
• No caching GUP calculates every time• BitmapCache “screenshot” saved, no GPU
needed
Image Do’s and Don’t‘s
• Fast (with BitmapCache):– Transforms: Scale, Rotate, Translate– Opacitiy change– Clipping region change
• Slow– Changing image with / height– OpacityMask– Non-rectangular clipping areas
• Jpegs are (somewhat) faster than pngs
Avoid Overloading the UI Thread
• Use BackgroundWorker
• Throttle calls to UI while it’s busyvia the “render loop”:
– E.g a chart is redrawn whenever the Zoom changes– A chart redraw takes 100ms– The Zoom is changed at 0ms, 40ms, 80ms, 120ms– The chart will still be drawing at 40ms & 80ms!
Rendering Real-Time
• Lightweight vs heavyweight elements– Shapes vs Controls vs UserControls
• Drawing is more expensive than redrawing– Reuse existing elements
• WriteableBitmap & WriteableBitmapEx
• Working with large Paths: buggy, slow
Extreme Optimalizations
• Data Binding– Avoid when there are thousands of objects– Takes up memory & notifications may fire too
often• DPs– Only use if needed– Slow to read cache in CLR properties
Summary
• Networking & effect on UI thread
• Serialization & deserialization
• ListBox
• BitmapCaching
top related