xaml performance tools app model.net native 1 2 3 4 5

37
Building apps on the Universal Windows Platform

Upload: stella-flowers

Post on 22-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Building apps on the Universal Windows Platform

Page 2: XAML Performance Tools App Model.Net Native 1 2 3 4 5

XAML

Performance

Tools

App Model

.Net Native

1

2

3

4

5

Page 3: XAML Performance Tools App Model.Net Native 1 2 3 4 5

XAML

Page 4: XAML Performance Tools App Model.Net Native 1 2 3 4 5

<XAML />

Windows 10 XAML ‘free’

Common scenarios are handled by the platform“automagicaly”

Window gets resized, Pivot headers moveMouse and Keyboard capable automatically

Page 5: XAML Performance Tools App Model.Net Native 1 2 3 4 5

<XAML />

Windows 10 XAML ‘free’

Common scenarios are handled by the platform“automagicaly”

Responsive layout with new ControlsRelative panel, Adaptive triggers,

<VisualStateGroup x:Name="WindowSizeStates"><VisualState x:Name="WideState">

<VisualState.StateTriggers><AdaptiveTrigger MinWindowWidth="720" />

</VisualState.StateTriggers><VisualState.Setters>

<Setter Target="MySplitView.IsPaneOpen" Value="True" />

<Setter Target="MySplitView.DisplayMode" Value="Inline" />

</VisualState.Setters></VisualState>

</VisualStateGroup>

<VisualState x:Name="Pressed"><Storyboard>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"Storyboard.TargetProperty="Background"><DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource

SystemControlBackgroundBaseMediumLowBrush}" /></ObjectAnimationUsingKeyFrames><ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"

Storyboard.TargetProperty="BorderBrush"><DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource

SystemControlHighlightTransparentBrush}" /></ObjectAnimationUsingKeyFrames><ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"

Storyboard.TargetProperty="Foreground"><DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource

SystemControlHighlightBaseHighBrush}" /></ObjectAnimationUsingKeyFrames>

</Storyboard></VisualState>

Page 6: XAML Performance Tools App Model.Net Native 1 2 3 4 5

<VisualStateGroup x:Name="InputTypeStates"><VisualState>

<VisualState.StateTriggers><triggers:InputTypeTrigger TargetElement="{x:Bind ActivityList}"

PointerType="Touch" /><triggers:InputTypeTrigger TargetElement="{x:Bind ActivityList}"

PointerType="Pen" /></VisualState.StateTriggers><VisualState.Setters>

<Setter Target="GoToTopButton.Visibility" Value="Visible" /></VisualState.Setters>

</VisualState></VisualStateGroup>

<XAML />

Windows 10 XAML ‘free’

Common scenarios are handled by the platform“automagicaly”

Flexibility and power through extensibilityExtensible Triggers

Page 7: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Extensible Triggers Demo

Page 8: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Windows Insiders FTW!

http://github.com/dotMorten/WindowsStateTriggersMorten NielsenWindows Developer MVP (@dotMorten)

Page 9: XAML Performance Tools App Model.Net Native 1 2 3 4 5

<XAML />

Windows 10 XAML ‘free’

Common scenarios are handled by the platform“automagicaly”

Highly-tailored

Custom View and Controls by scenario, Xaml Views

Page 10: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Other UI GoodiesChange Notification on Dependency properties target.RegisterPropertyChangedCallback(ContentControl.ContentProperty, ContentChanged);

PerspectiveTransform3D (Effects: 3D Rotations, Parallax)

Custom chrome, branding, sizing CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

Drag and Drop <Grid AllowDrop="True" DragOver="Do_DragOver" Drop="Do_Drop" …>

<Grid> <Grid.Transform3D> <!– Parent Camera --> <PerspectiveTransform3D/> </Grid.Transform3D> ...</Grid>

Page 11: XAML Performance Tools App Model.Net Native 1 2 3 4 5

XAML Performancein Windows 10

Page 12: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Validating XAML in Windows 10

Page 13: XAML Performance Tools App Model.Net Native 1 2 3 4 5

TOUR

Universal Windows app Performance

Notable performance gains when moving to UWP

Hello World (M)

Dialer (M) Calc (PC)0

100

200

300

400

500

600

700

345

609663

277

510 511

8.1 10

Tim

e in

ms

Hello World (M)

Dialer (M) Calc (PC)0

2

4

6

8

10

12

14

16

18

20

7.5

12.6

18.4

4.2

7

12.5

8.1 10

Dynam

ic

in

MB

StartupMemory

CPU - 15% to 30% Working Set - 25% to 45%

Page 14: XAML Performance Tools App Model.Net Native 1 2 3 4 5

TOUR

Notable New Performance FeaturesCompiled Bindings AKA {x:Bind}

Resolved at compile time and produce compiler errors.

<ListView> <ListView.ItemTemplate> <DataTemplate x:DataType="local:FreeBookCategory"> <StackPanel> <SymbolIcon Symbol="{x:Bind Symbol}"/> <TextBlock Text="{x:Bind Name}"/> <Button Click="{x:Bind Click}"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate></ListView>

Page 15: XAML Performance Tools App Model.Net Native 1 2 3 4 5

TOUR

Notable New Performance FeaturesProgressive Rendering AKA {x:Phase}

Set render priority for elements

<DataTemplate x:DataType="model:FileItem">

<Grid Width="200" Height="80">

<TextBlock Text="{x:Bind DisplayName}" />

<TextBlock Text="{x:Bind prettyDate}"

x:Phase="1"/>

</Grid>

</DataTemplate>

Page 16: XAML Performance Tools App Model.Net Native 1 2 3 4 5

TOUR

Notable New Performance FeaturesDeferred Loading AKA {x:Defer}

XAML construct to “delay instantiation” of this part of the tree

<StackPanel x:Name="AdditionalProductPage"

Visibility="Collapsed" …

x:DeferLoadStrategy="Lazy">

</StackPanel>

var deferredPanel =

FindName("AdditionalProductPage");

Page 17: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Profile your applicationProfile your application First step – see if there’s a problem within your code

Use Visual Studio 2015 to analyze and fix Timeline tool – where is my problem Profiler to spot slow code Memory usage Visual Diagnostics

Page 18: XAML Performance Tools App Model.Net Native 1 2 3 4 5

XAML Improvements in Visual Studio

Page 19: XAML Performance Tools App Model.Net Native 1 2 3 4 5

<Visual Studio/>

New XAML language service

Built on top of RoslynCompletely decoupled from the designerAdvanced code + XAML refactoring

Design Modes

Design surface for every device family

Visual Tree Inspector

Inspect and modify your XAML while it is running

Profiling tools

CPU, Memory, Timeline, Network and moreSupport for WPF and Universal Windows apps

Page 20: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Blend for Visual StudioBlend is a tool for creating great user experiences, with deep focus on best-in-class UI design capabilities.

Visual Studio is a tool for creating great apps, with focus on best-in-class code editing and debugging capabilities.

Blend is rebuilt from the ground up using VS technologies

Page 21: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Windows Device Family Extension SDKsUse device family specific APIs by adding references to Windows Device Family Extension SDKs

Page 22: XAML Performance Tools App Model.Net Native 1 2 3 4 5

var api = "Windows.Devices.Gpio.GpioController";if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(api)){

var gpio = GpioController.GetDefault();var pin = gpio.OpenPin(LED_PIN);pin.SetDriveMode(GpioPinDriveMode.Output);pin.Write(GpioPinValue.High);

}

Page 23: XAML Performance Tools App Model.Net Native 1 2 3 4 5

App Model

Page 24: XAML Performance Tools App Model.Net Native 1 2 3 4 5

The Windows App ModelDefines the app lifecycle

Unified across all Windows devices Works on IOTMobilePCXboxHololens

Cradle to Grave Install Runtime environment Resource Management Update Data Model Uninstall

Page 25: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Running your codeExisting apps will run on the platforms they were built for

Windows Windows Mobile

Universal Windows Apps

Classic Windows Apps

X

Windows Phone 7,8,8.1 apps

X

Existing Windows Store Apps (WinRT)

X

Page 26: XAML Performance Tools App Model.Net Native 1 2 3 4 5

MultitaskingResource Management Scaling from low end phones to high end PCs

Extended Execution for foreground applications Ask for more time

The amount of time is based on what device you’re running on let me finish saving my file

Always keep my app running Tell the OS when you start that you intend to keep running Turn by turn navigation

Triggers

Page 27: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Unifying the navigation model

Evaluated Xbox, Windows, and Phone modelsBack will behave much like Back button in Phone today

Navigates back in the app, then back to previous app

Go back to where you came from

Page 28: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Building a Web of AppsAllow apps to integrate using the best of the web

URL based activation/communication

Foreground to Foreground Very similar to the web model Allows for custom scheme invocation skype:presidentobama New in 10 - the ability to return results, query for apps and enumerate apps

Foreground to Background Application services Enables you to “publish” a background task that can be called by other apps Social app integration with the People app is a key example of this

Page 29: XAML Performance Tools App Model.Net Native 1 2 3 4 5

App 2 App Demo

Page 30: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Content adapts with the tileThe new adaptive tile template works similarly to universal app patterns by allowing your content to adapt depending on the devices screen density. As you design your tiles it is important to keep in mind how you want your content to adapt to the tiles size on screens of different densities.

<tile>

<visual>

<binding template="TileMedium">

<group>

<subgroup>

<text hint-style="subtitle">John Doe</text>

<text hint-style="subtle">Photos from our trip</text>

<text hint-style="subtle">Thought you might like to see all of</text>

</subgroup>

</group>

<group>

<subgroup>

<text hint-style="subtitle">Jane Doe</text>

<text hint-style="subtle">Questions about your blog</text>

<text hint-style="subtle">Have you ever considered writing a</text>

</subgroup>

</group>

</binding>

</visual>

</tile>

Min. Med Size Max Med. Size

Show more content?

XML SAMPLE 1

Adaptive Tile Template

Page 31: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Adaptive and Interactive Toast Template (Windows App)The adaptive toast template is our most flexible toast we’ve ever had. This template allows you to put the content you want on the toast, how you want it, and have it work across all of Windows phone, tablet, and PC devices. It allows you to add interactivity to quickly reply to a message, accept an invite, like something on a social network, or snooze an alarm.

Legacy TemplatesIf there is a template that already meets your needs perfectly, feel free to use the legacy template catalog. There are 8 different templates available for use and previously Windows only template features, like inline images, are now fully working on Windows Phone.

Toast Templates

Desktop

Mobile

Page 32: XAML Performance Tools App Model.Net Native 1 2 3 4 5

.NET Native

Page 33: XAML Performance Tools App Model.Net Native 1 2 3 4 5

.NET Native

Native code compilation for managed languages

Provides converged developer experience for .NET across devices

Uses lean runtime and VC++ optimizer for fast code execution and reduced memory usage

Page 34: XAML Performance Tools App Model.Net Native 1 2 3 4 5

.NET Native

60%CPU savings from cold start

40%CPU savings from warm start

30%Smaller memory footprint

Page 35: XAML Performance Tools App Model.Net Native 1 2 3 4 5

Compile with .NET Native Demo

Page 36: XAML Performance Tools App Model.Net Native 1 2 3 4 5

SummaryWe are listening

XAML does the hard work for you and enables responsive design

Microsoft is using the same XAML controls and APIs as you

New Visual Studio features make it easy to create responsive and performant applications quickly

Unified app model across all Window 10 devices

Rich app to app communications

Native code compilation and performance for managed languages

Page 37: XAML Performance Tools App Model.Net Native 1 2 3 4 5

© 2015 Microsoft Corporation. All rights reserved.