Windows Phone: info about Windows Phone 8.1 and //build/ sessions
Mood: content
Posted on 2014-04-08 20:58:00
Tags: windowsphone wpdev
Words: 2065

For Windows Phone developers, Microsoft's //build/ conference was a very exciting place! Here's some information for you about developer-specific stuff (Cortana, etc. you can read about plenty of other places...which is not to say Cortana doesn't have some cool stuff for developers!)

The first link to read is What's next for Windows Phone 8 developers. All of the apps for Windows Phone 8 are written against the Silverlight API, and while this is still supported in Windows Phone 8.1, the new APIs that are common with existing Windows 8 apps are called a "Windows Phone Store" or "XAML". (neither one of which is terribly helpful...but I digress) If you want to keep your app as a Silverlight app, here are Supported features for Windows Phone Silverlight 8.1 apps. If you're looking to port your app to the new APIs, check out Migrating your Windows Phone 8 app to a Windows Runtime XAML app, and there's also a very helpful post about Windows Phone 8.1 for Developers–What Controls Are New.

Don't forget: if you want to get the Windows Phone 8.1 update early (and who doesn't?), check out the Windows Phone Preview for Developers - I believe the update will be ready in a week or so.

My notes for the //build/ sessions I went to are below. I'd particularly recommend the "Live Tiles Enhancements", "Nokia APIs", and "Animations in Phone XAML Apps" sessions. My fellow ambassador Lance McCarthy collated videos of all the Windows Phone-related //build/ sessions.


Big news was Windows Phone 8.1 (Action Center for notifications, Cortana, universal apps which shows further unification between Windows 8 and Windows Phone APIs)
Windows free on all <9" devices - seems to change MS's business model, at least on phones
Open-sourced "Roslyn" C# compiler! Not ready for production code yet, but available on github
.NET Foundation ( http://www.dotnetfoundation.org/ ) - has open source .NET stuff, including MEF
new JIT compiler RyuJIT - http://aka.ms/RyuJITinfo (good for startup time and general performance), now has SIMD support
.NET Native ( http://aka.ms/dotnetnative ) - compiles C# all the way to native code (uses C++ optimizer). Still can use all CLR features (garbage collection, etc.) Only for Windows Store apps now. (compiles in the cloud?)

Microsoft logo is colors of Office Red, Xbox Green, Windows Blue, Bing Orange!

Wed Day 1 Keynote

New WP 8.1 (Action Center, Cortana)
Universal apps through "shared" project (not PCL, so you can #if, etc.)
Improved mouse/keyboard support in Win81
- Start menu coming back later this year! But with tiles and stuff
Someday can target XBox with Windows APIs
Nokia phones (630/635 and 930) with SensorCore
Windows free on all <9" devices!
Kinect v2 for Windows
preview of Office Metro for Windows


Wed 4/2 4PM 2-582 Tips and Tricks in Visual Studio 2013 Cathy Sullivan
http://channel9.msdn.com/Events/Build/2014/2-582
http://aka.ms/VSTipsandTricks
http://msdn.microsoft.com/en-us/library/vstudio/dn320181%28v=vs.120%29.aspx
settings sync (to MS account)
search in Tools->Options, Soln Explorer, Error List
Ctrl + double-click window to redock
Ctrl+F4 to close a document
in quick search bar can use filters like @mru (most recently used documents) and @opt (options)
Scrollbar preview thingy - can see changes you've made!
Ctrl+, = Navigate to
Alt+F12 = Code Peek (opens up a temporary window with the definition of what your cursor is on)
- Esc closes
Code Lens - inline view of recent changes, references, etc. (hold Alt to trigger?)
- http://msdn.microsoft.com/en-us/library/dn269218.aspx
Productivity Power Tools - http://visualstudiogallery.msdn.microsoft.com/3a96a4dc-ba9c-4589-92c5-640e07332afd
- can show which files have errors in Solution Explorer
- Bing code search (searches MSDN, Stack Overflow, etc.)

Thu Day 2 Keynote
Lots of Azure - 57% of Fortune 500 use it
Manage Azure machines from inside Visual Studio
Browser Link - live edit page in browser, reflects back to Visual Studio!
Azure Mobile Services stuff
.NET Native - can compile .NET assemblies to real native code!
Roslyn .NET compilers - refactoring preview, now open source! (http://roslyn.codeplex.com), modified lexer to use french quotes for string constants very quickly. Works on Xamarin too
".NET Foundation" - www.dotnetfoundation.org for .NET open source stuff

Thu 1PM 2-588 .NET in a world of devices and services
Best end-to-end dev experience
BYO platform, framework, tools
6M professional .NET developers, 1.8B machines have .NET installed
new JIT compiler RyuJIT - http://aka.ms/RyuJITinfo (good for startup time and general performance), now has SIMD support
Roslyn - add language stuff, good for VS extensibility, diagnostics for style guidelines (i.e. if statements w/o braces), easy to see preview and fix it.
http://referencesource.microsoft.com - source for .NET stuff
.NET Foundation ( http://www.dotnetfoundation.org/ ) - has open source .NET stuff, including MEF
.NET Native ( http://aka.ms/dotnetnative ) - compiles C# all the way to native code (uses C++ optimizer). Only for Windows Store apps now. (compiles in the cloud?)
Efforts have been towards: Native, Open, Cross-Platform

Thu 2:30PM 2-523 Live Tiles Enhancements
Tiles are good unobtrusive notifications
http://bit.ly/TileTemplateCatalog
same templates on Win8 and WP now, although WP might not show every field (no Square310x310 for WP)
Windows Notifications Service - now used on WP as well for client and server. SSL for free.
Types of tile update schedules: Local, Scheduled, Periodic (like on Windows - every 30 mins polls a URL for tile XML data), Push (can do a Raw one which will cause your app to run in the background)
Can do test push notifications through emulator
App.OnNewTilePinned event (to set up polling)
WP Tile notification queue - can cycle through 5 notifications which can have different templates, also support for expiring notifications
Same XML for Win/WP - can use Versions & Fallbacks to support Win8 (instead of 8.1).
Advice: put WP templates first
Session 2-521 - Notifications Deep Dive
Draw tiles - WritableBitmap old, XamlRenderingBackgroundTask is new. Recommend doing in C++ to avoid hitting memory cap.
"Debug Location" toolbar in VS can let you fire Lifecycle Events
App Tile Updater sample
Session 2-517 - what's new
Tips for tile scaling (see presentation)
Live tiles for websites using meta tags
@MattHidinger

Thu 4PM 3-545 Quality and Performance for XAML apps
Reduced memory usage for XAML in WP8.1
TestListViewer class can extend from ListViewer and log when items get prepared/released (PrepareContainerForItemOverride()) to ensure virtualization is working corectly.
Putting ListViewer in a StackPanel can defeat virtualization! (because StackPanel gives infinite space)
- using a Grid instead will fix
Performance Monitor in VS to log CPU, memory usage, etc.
- can take "snapshots" to see objects in memory, do a diff, see why things in memory
double.Parse can break in german ("34.56" -> 3456) - code analysis rule will catch (pass in InvariantCulture)
Multilingual Editor for localization - can auto translate strings via Bing!
Pseudo-localization - puts in crazy characters, can find non-localized strings
Test on screen sizes, no network, themes, optional HW (no front-facing camera)
Automated tests (unit, UI)
- for UI test do New Project->Coded UI Test Project, can navigate, assert that images exist, etc.

Thu 5:30PM 2-549 Nokia APIs
Imaging, Context, Location Music
Imaging SDK v1.2 - easy GIF creation, local image blend, Image Aligner
ChromaKey - pick color to make transparent, combine images (green screen)
blend filter
http://developer.nokia.com/resources/library/Lumia
Can select areas that are background vs. foreground
SensorCore - sense if walking, running, driving, or idle
SC requires HW (only on 630/5, 930 for now...may come to others later??)
Can go back 10 days to get data
Step Counter, Activity Monitor, Place Monitor, Route Tracker

Fri 9AM 4-587 Native code performance on modern CPUs
Cool new instruction in AVX2 - Fused multiply accumulate (FMA)
AVX instructions=some floating point 256-bit SIMD instructions
AVX2 instructions=more 256-bit SIMD instructions
compiling w/ AVX2 instructions available in VS 2013 Update 2
Profile always - can use VS Performance Analyzer, Intel VTune Amplifier, AMD CodeXL
Case study: on Haswell FP multiply=5 cycles, FP add=3 cycles, Fused multiply accumulate(FMA) does both in 5 cycles
For A*B+C, FMA is faster, as expected
For A*B+C*D:
non-FMA code looks like
mul A,B->A
mul C,D->C
add A,C->A
but two multiplies can run in parallel (since multiple ALUs) and the whole thing takes 5+3=8 cycles
FMA code looks like
mul A,B->A
fma A,C,D->A
and takes 5+5=10 cycles!
For things like dot product, FMA is way faster. Haswell has 2 FMA units
cycle timings are different on AMD chips! performance is hard
--
Sidenote: "xmm" registers are 128-bit, "ymm" registers are 256-bit
SSE2 and AVX allow 128-bit autovectorization
AVX2 allows 256-bit autovectorization
You might think 256-bit instructions would make your code 2x faster than using 128-bit instructions, but that ignores memory latency. Optimizing your code by using vector instructions moves your code from CPU-bound to memory-bound. You can see this in Intel's VTune.
Case study: Eigen3 benchmark with AVX2 was 60% than with SSE2! AVX was also slower, and this only showed up on Haswell, not Sandy Bridge.
key difference was turning two 128-bit vector copies into a 256-bit vector copy
Intel VTune showed "Loads blocked by Store Forwarding" was high
Store buffers are a small table of address and data that has been stored to them (42 of them on Haswell) - lets you avoid hitting the real cache if you later to a load on an address in a store buffer.
But loads that overlap multiple store buffers don't get optimized and have to go to cache
An earlier 128-bit store was causing that to be in a store buffer, and then the 256-bit copy couldn't read from it so it had to go to cache!
(this perf bug is in VS 2013 Update 2, fix coming)
512-bit vector instructions are coming

Fri 10:30AM 2-529 Sensor Platform Enhancements in Windows Phone
accelerometer, compass, gyrometer, inclinometer, light sensor, orientation, simple orientation
Can respond to light sensor to add contrast in especially dim/bright settings
Outdoors=5K-50K lux
Indoors Bright=500-1K lux
Indoors Dim=10-100 lux
Dark Room=0-10
If you do respond to these, do gradual changes and use hysteresis to avoid weird toggling effects
Orientation sensor - if it's facedown, maybe ignore gestures?
Lock screen apps can now access sensors. Background apps can also access sensors by registering for a DeviceUseTrigger, although a limited number of apps can do this at once. Also needs special declaration in Appxmanifest.
Can control sensors in WP/Win emulator
remember that background task runs in a separate process
For orientation, display=how pictures on screen are shown, device=physical positioning
Be careful about power usage: can adjust reporting interval in background tasks, make sure you dispose unneeded sensor refs!
if the foreground app crashes your background task can linger
For magnetometer can get whether it's high or low accuracy (based on HW quality, etc.)
Snapdragon sensor core has a low-power core to get sensor data
In WP 8.1 sensor drivers are in user-mode, not kernel-mode

Fri 2PM 3-554 Animations in Phone XAML Apps
Timing is crucial - don't make animations too slow
Can be annoying - careful about repeating them!
Animations are great as subtle feedback (like tilt effect when tapping an item)
*ThemeTransition and *ThemeAnimation are the classes involved
some transitions/animations are on WP only, some are on Win and WP but look different, some are on both and look the same
transitions are when page is entered/exited or when items are moved in a ListBox, etc. and are triggered automatically. Animations are on particular elements, and are triggered manually.
animations extend from Timeline class
transitions are specified in XAML with something like <uielement.Transitions><TransitionCollection><ReorderThemeTransition/></TransitionCollection></uielement.Transitions>
animations are put in a Storyboard
PageNavigationThemeTransition's - when navigating from page A -> page B, uses transitions in page B (when going forward or back)
attached property DefaultNavigationTransitionInfo
other transitions: Common (the default one), Slide, Continuum
Even with Common, can get a staggering effect in a ListView - in the transition set IsStaggeringEnabled="True", in the control set attached property IsStaggerElement="True"
Slide - quick animation for leaf node pages (like facebook comments page)
Continuum - text of selected element flies out/in. Good for master->details page (like tapping on an email in email app)
Specify elements with ContinuumNavigationThemeTransition.IsEntranceElement on page B, CNTT.IsExitElement on page A. (for performance, also need CNTT.ExitElementContainer on the container in page A)
New parameter to Navigate() method - can override animation by passing NavigationTransitionInfo.
PopUpThemeTransition - built into Flyouts, Jump lists
PointerUpDownThemeTransition (i.e. "tilt effect") - built into button, ListViewItem, etc.
Uses VisualStates and VisualStateManager like on Win. Can go to a particular state (i.e. "Pressed" or "None") in code with VisualStateManager.GoToState()
SlideInThemeTransition for Pivot swiping. Can set attached property Pivot.SlideInAnimationGroup on contents (up to 3 levels of staggering)
A few builtin animations - "Accordion" (compression) for scrollable elements when reach the top/bottom, page rotation animation with crossfade, menu flyout show and hide
--

See all my Windows Phone development posts.

I'm planning on writing more posts about Windows Phone development - what would you like to hear about? Reply here, on twitter at @gregstoll, or by email at ext-greg.stoll@nokia.com.

--

Interested in developing for Windows Phone? I'm the Nokia Developer Ambassador for Austin - drop me a line at ext-greg.stoll@nokia.com!


This backup was done by LJBackup.