XAML performance fundamentals

  • View
    59

  • Download
    0

Embed Size (px)

DESCRIPTION

XAML performance fundamentals. Kiran Kumar PRINCIPAL DEVELOPMENT LEAD 3-157. Agenda. Performance ideology XAML architecture overview XAML performance guidance Tools and demos. Performance ideology. Fast: Snappy user interactions – app launch, navigating pages, changing orientation - PowerPoint PPT Presentation

Text of XAML performance fundamentals

XAML performance fundamentals

Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/20131XAML performance fundamentalsKiran KumarPRINCIPAL DEVELOPMENT LEAD3-1576/27/2013Windows Azure2 2011 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.Performance ideologyXAML architecture overviewXAML performance guidanceTools and demos

AgendaPerformance ideologyFast: Snappy user interactions app launch, navigating pages, changing orientation

Fluid: Smooth user interactions panning a page, animations, eliminating glitches

Efficient: System citizenship battery life, memory and disk footprint, pay for play

Responsive

Performance ideologyKnow your runtimeDirect3D, Direct2D, DirectComposition, DWrite etc Fastest way to get pixels on the screenCoding to metalNo support for accessibility, IME, input handling etcXAML/HTMLPowerful features but comes with cost.Know your budgetPanning has a smaller budget than Startup.Perceived experience mattersUsing patterns (like MVVM)Patterns can make developers more productivePatterns guide you Patterns typically dont make the App users life betterPatterns could create layers that can slow down the app

Build for performance

XAML architecture overviewComplete native implementation built on top of DirectXXAML ArchitectureWindows 8 subsystemWindows Store app (C++, C#, or Visual Basic)AppTheming & PVLDirect3DDirectWriteDirect2DMediaInputXAML platformXAML graphics engineXAML ABI supportWindows Runtime / C++XAML core and framework (parser, controls, property engine, styles, animation, etc.)XAML architectureXAML architecture / threadsUI thread

ParsingLayoutApplyTemplateApp CodeData bindingInput processingSubmitting frames

Render threadRunning animationSubmitting frames

Worker threadsImage decodingText renderingMedia playback

XAML architecture / framesUI thread frames do heavy liftingRun layout on dirty elementsParse XAML for any objects being createdRender visible objects into DirectComposition Run user codeRender thread frames run at 60 FPSUpdate animation valuesUpdate DirectComposition Visuals

XAML operations are broken into frames

Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/20139XAML performance: startupWhat happens during startupUI thread

ParsingLayoutApplyTemplateData bindingInput processingApp codeDrawing instructions to DirectComposition

Render thread

Set up animation loops if anyUpdate DirectComposition Transforms

Desktop Window Manager (DWM)

Frame compositionPresenting to screen

Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/201311StartupToo many XAML files referencedTrim down your element countUse UI virtualization to create only visible itemsDelay-load UICollapsed Custom Controls V/s User ControlsMake smart web requestsUnnecessary resources loaded (for example DLLs)Avoid sync file IO requests

Causes for slow startup

Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/201312Demo: StartupXAML performance: panning and animationDependent animations UI thread creates the animation tree Each frame of animation is generated on the UI thread and sent individually to the Desktop Window Manager (DWM)

Independent animationsUI thread creates the animation treeRender thread takes over and runs the animation and sends the updates to Desktop Window Manager (DWM)

How XAML handles animationsAnimationBuild 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/201315AnimationGPU overdraw can impact frame ratesOverdraw can impact GPUARM devices have a lower fill-rate

Dependent animations are badThings that require UI thread updatesCompositionTarget.Rendering and Timeline.EnableDependentAnimationReacting to pointer events and moving the visuals

Independent animations are goodAnimations that dont target layout propertiesCan run independent of UI thread

Make animations smooth Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/201316Animation: Diagnosis DebugSettings.EnableFrameRateCounter

DebugSettings.EnableRedrawRegions

DebugSettings.IsOverdrawHeatMapEnabled

Build 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.6/27/201317PanningUI threadRealizes the virtualized contentRecycles containers were possibleUpdates Data on the New contentCalls input handlersWhat happens during panningRender threadUsing Direct Manipulation and Direct Composition independently moves the visualsBuild 2012 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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 Corp