Invalid Pointer exceptions when using Win2D

Chances are if you are using Win2D in a complex app, you may have seen it crash sometimes with an unhandled exception with HResult 0x80004003 and a not very descriptive message containing only the phrase Invalid pointer.

If this is the case, take a second look at all your CanvasCreateResourcesEventArgs.TrackAsyncAction calls – because, while you may think this is a threading problem, the cause is far easier to solve: you are accessing a null object/property instead. Somehow Win2D is throwing an Exception with that error message instead of a NullReferenceException.

Why is my adaptive tile not updating on some devices?

Recently I have worked in an UWP app that uses the new adaptive tiles to display both images and text without having to go through the old method of rendering a tile image with a XamlRenderingBackgroundTask. Everything worked flawlessly on my test devices, even on Release mode with .NET Native compilation enabled; however, when published through the Store, some users started complaining that the tile content didn’t update at all. The most strange thing was that the background task that took care of updating the live tile wasn’t failing at all – it wasn’t reporting any errors/exceptions and the tile badge count was updating without issues.

I started investigating a bit and there was something in common with these users – all of them were using either a Lumia 950 or a Lumia 950 XL. And after a bit of investigation, I found the cause: I was using scaled assets for the graphics shown on the Live Tile, but only including the scale-100 images – turns out the runtime wasn’t defaulting to this size in all cases, and the tile was failing to entirely update (it didn’t even show the text without images).

So, lesson learned: don’t use scaled asset in your adaptive tile, or if you have to, be sure to include ALL the supported sizes.