Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

19
Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012 Brad Sullivan [email protected]

description

 

Transcript of Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Page 1: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012Brad [email protected]

Page 2: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Agenda

• Mixed-language debugging• Contract debugging• Debugging background tasks• Debugging installed applications without a Visual

Studio project• JavaScript Memory Analyzer• Using First Chance Exceptions in C++

Page 3: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

MICROSOFT CONFIDENTIAL – INTERNAL ONLY

Native/Managed Debugging for Store Apps• Remote Debugging Support• Native Visualization• Reliable Stepping

• Shipped in Update 1

Page 4: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

I have options for “Native Only” and “Script Only” debugging.

What if I want to do both?

Page 5: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Debugging Native and JavaScript• No Mixed Mode Debugging Support• Use Multiple Instances Instead

Launch the app under the script debugger Attach with the native debugger from a second instance of VS

• Visual Studio naturally gives focus to the correct instance• Cannot Debug JavaScript when stopped in the native

debugger

Page 6: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Contract Debugging

• Windows 8 contracts provide a new entry point for applications

• It’s not the same code as just launching under the debugger

• Simply attaching is not quick enough as you may have missed the code that you wanted to debug

Page 7: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Contract Debugging

• Configure the app to debug without launch in the project properties

• F5 the app• Invoke your application manually through the contract

Page 8: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Background Tasks

• Your app can register to run background tasks when certain events happen

• Some background tasks are straight forward to test and debug because you can trigger them manually

• Others can be a much bigger pain Like a maintenance trigger that fires after 8 hours

Page 9: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Background Tasks

• Trigger background tasks from the Debug Location Toolbar• Can trigger tasks on apps that are not running

Set them to debug without launching first

• Can trigger tasks that do not require a payload

Page 10: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

No Projects

• There are several reasons why you may not have a VS project, but still want to debug

Permissions Convenience Normally build/deploy outside of VS

• Attach to process is a pain for WWAs Especially if you need to debug startup code!

Page 11: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

No Projects

• Use the “Debug Installed App Package Feature”• Works both local and remote• Can automatically stop at the first line of JavaScript Code

Page 12: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

JavaScript Memory Profiler

• Identify unintentionally retained memoryand inefficient use of memory

• Snapshot-based tool• Shows JavaScript and DOM elements

Size Counts Reference graph

Page 13: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Memory terminology

Size: How large the object is in memoryRetained Size: The amount of memory that the object is preventing the garbage collector from reclaiming

Includes the size of the object Includes the size of all referenced objects (and any objects they reference) that the

current object is the only parent of in the memory graph

Page 14: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Size and retained size

Size Retained Size

Object A

Object B

Object C

Object D

500 KB 500 KB

100 KB 600 KB

Object A (100 KB)

Object B (500 KB)

Object C (50 KB)

Object D (100 KB)

50 KB

100 KB

50 KB

100 KB

Object A (100 KB)

Object B (500 KB)

600 KB

Page 15: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

First Chance Exceptions

• Tough to find your real error in XAML apps• Turning on first chance exceptions can create a lot of noise

that can slow you down• Async patterns can make this worse

Page 16: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

First Chance Exceptions

• Stop on Originate Error Exceptions for C++• Use the memory window on the third parameter to decode

the secret message

Page 17: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Related Sessions

Beat the Clock: Background Tasking in Windows 8Speaker: Jeff Prosise7 March 9:00

Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012Speaker: Brad Sullivan7 March 10:45

Page 18: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

More Info About Diagnostics

ALM Team Blog: http://blogs.msdn.com/b/visualstudioalm/

Page 19: Diagnostic Tips and Tricks for Windows Store Applications using Visual Studio 2012

Request Features

Uservoice site: http://visualstudio.uservoice.com/