Nachman Software Development Engineer in Test Microsoft Corporation httpwwwnachmorecom httpblogsmsdncomoren Faster than a speeding app Agenda Back to Basics Silverlight Threading on the Phone ID: 467980
Download Presentation The PPT/PDF document "Oren" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Oren
NachmanSoftware Development Engineer in TestMicrosoft Corporationhttp://www.nachmore.com || http://blogs.msdn.com/oren
Faster than a speeding app…Slide2
Agenda
Back to BasicsSilverlight Threading on the PhonePerformance debuggingReal-World app pain pointsListBoxMemoryNetworkingPopupTools Demo / InformationSummary / Q&ASlide3
Further Reading
WhitePaperhttp://bit.ly/aSJHS8 - dochttp://bit.ly/9A93TN - samplesShane’s Channel 9http://bit.ly/9h3V7u
PDC Talkhttp://bit.ly/cvVvY4Slide4
The Usual Reaction…Slide5
Back to
BasicsSlide6
Early prototype of “Hungry Castaway”By Roger Peters (SmartyPantsGaming.com)
demo Castaway
Threading, Redraw and
FillRate
ProblemsSlide7
Desktop Threading Model
UI Thread
User
Threads
new Thread()
ThreadPool.QueueUserWorkItem
(
BackgroundTask
)
Dispatcher.BeginInvoke
(Action)Slide8
Compositor Thread
Phone Threading Model
UI
Thread
User
Threads
new Thread()
ThreadPool.QueueUserWorkItem
(
BackgroundTask
)
Dispatcher.BeginInvoke
(Action)
Raster
Raster
Raster
Raster
UI Thread busy = PFC Delayed
No work
==
No TickSlide9
Thread Responsibilities
UI
Thread
Compositor Thread
More
Work?
Handoff Surface + Animation
Tree Invalidated?
LayoutSlide10
What gets kicked off the compositor thread
Anything that modifies the base texture of an objectOpacity MaskNon-Rectangular ClipsNon-StoryBoard animation (per-frame callbacks)CompositionTarget.RenderingSlide11
Early prototype of “Hungry Castaway”By Roger Peters (SmartyPantsGaming.com)
demo Castaway
The SolutionSlide12
Pain
PointsSlide13
ListBox
Toolkit – LongListSelector (silverlight.codeplex.com)LowProfileImageLoader (David Anson)Watch out for UI thread work during a ListBox action PrepareContainerForItemOverrideArchitecture tradeoffs:Virtualized vs Non-VirtualizedAccidental dropping of VirtualizationLoad everything and bind at the endSlow loadPopulate during loading (INotifyCollectionChanged)Possibly jerky while loadingSlide14
Panorama / Pivot
Panorama will load all pages – from the get goPivot will collapse pages that are not in or next to viewDelay load if loading is killing your UI threadBinding will bind across all pages!Update your View according to what is in the user’s view!Slide15Slide16
Copy & Paste
No developer APIAutomagically applies to all TextBox controlsAnd derivativesTextbox in Pivot or Panorama? Requires recompile + resubmitTextBox is heavier than TextBlockSlide17
Networking
Use HttpWebRequest on Background ThreadBackground -> Background ThreadPoolUI Thread -> UI ThreadLimit of 6 parallel requests (extras will queue)Serialization – JSON, XML, Binary?Network? Payload size will dominateIsolated Storage? Speed will dominateAdvanced: WiFi? Download larger chunks & in parallelSlide18
Popup
Minimal Hardware AccelerationPlan Ahead Instead!See blog for full screen popup workaroundSlide19
Summary
60fps is attainable!But don’t kill yourselves if you’re at 45No “blue pill”Use the debug flags! (Counters + RedrawRegions)Plan & test for perf from the startPlenty of resources – use them!Feel free to reach out for helpWinning Patterns!
45Slide20
Q&A
(if time)Slide21
Useful Links
SLM Perf Team Bloghttp://blogs.msdn.com/slmperf Performant Progress Bar (and other controls)http://silverlight.codeplex.com/David Anson’s LowProfileImageLoaderhttp://bit.ly/ajnDch Oren Nachmanhttp://www.nachmore.com or http://blogs.msdn.com/oren Slide22
Thank You!
Thank You for attending today’s Tech.Days Online Conference. Today’s Online Conference will be recorded. It will be made available on-demand very soon. Your Feedback Matters! Please complete the online evaluation form which will be emailed to you. Slide23
Click to edit Master title style
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries
. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT
MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
ONLINE CONFERENCE