Last Friday (20th January, 2017) I did a tech talk at Singapore Mobile .Net Developers meetup, under the topic “The three Awesome tools by Xamarin – Workbooks/Inspector/Profiler”!
So this blog post is a recap of the stuff I talked about! 😉
First of all here are the slides.
Here we go, the recap…
The three awesome tools by Xamarin
Last few months Xamarin has been busy releasing a lot of new updates and tools for us Developers, specially since the acquisition by Microsoft, they have been exponentially improving their platform and eco-system. 😀
So today I thought of picking up three awesome tool that has been released by Xamarin last few months, which are going to be extremely useful for Xamarin Mobile Development.
So to start off with…
Why do we need Xamarin Workbooks you asked? 😮
Now Imagine you’re someone who’s trying to learn Xamarin Mobile development or may be even C# dot net development? 😀
Could be someone trying to teach someone Xamarin or dot net or may be you’re trying to demo some awesome piece of code you implemented at a presentation, along with some documentation? 😉
Or simply you’re just trying out an experimenting some piece of code before you do some actual implementation in your actual project code?
Now in all of these stations, you have to open up your IDE, open up the documentations or presentations may be and most annoyingly you have to continuously switch in between them at all times. Not to mention having to recompile and run your code at the same time you switch back and forth. 😮
Oh well what a hassle is that?
To get rid of all that hassle, we have Xamarin Workbooks now! 😉
A perfect blend of documentation and code and immediate live preview results.
Xamarin Workbooks, is a prefect solution for experimenting with Xamarin and dot net code implementations and even as a learning tool for exploring code snippets and various kinds of implementations in Xamarin and dot net.
Perfect for creating teaching guides with a sweet side by side integration of code and documentation. Whenever you create or open up a Workbook, it creates a Sandbox environment for you to do your stuff, so you could accomplish your documentation aspect and coding aspect in one single place. 😉
So workbooks packs a bunch of awesome features, such as full fledged code editor with Roslyn IntelliSense, which has similar syntax coloring just like in Visual Studio. It has in-line compiler diagnostics support as well.
Attached with a rich text editor for you to add side by side code and documentation on the go. You could also easily search and add nuget packages as you go, just like you would do in Visual Studio, and instantly preview the results in console, or any mobile emulators as you have chosen.
You can easily save an share your workbooks with anyone and they could open it up and try out as they wish.
So Xamarin Workbooks supports dot net console/WPF implementations, Xamarin Android/iOS mobile development and even Xamarin Mac development scenarios. How cool is that eh! 😉
Why do we need Xamarin Profiler you asked? 😮
Now as mobile developers we need to make sure we are giving a smooth intuitive user experience for our beloved users. So in order to do that, we need to make sure our app is fully optimized for the memory usage, process usage and various resource usage without causing any excessive lags or crashes.
And even some times during the development we come across these mysterious crashes without even hitting any debug points where we need more than just the debug logs to figure out what’s causing those mysterious crashes. 😮
Another aspect is that as mobile developers we need to always focus on the over flow of the resource usage in our application at run time so that we could do the necessary improvements in our code to reduce any excessive resource usage.
Something very important to keep in mind is that when we are dealing with Xamarin Mobile Development, we have to deal with both the Xamarin dot net environment and the Native environment at run time. In that case the available native profilers we have for android and ios can not help to analyze our xamarin dot net environment. So we need something better than just native profilers for our Xamarin Mobile applications.
As a solution for all those scenarios, we have Xamarin Profiler now! 😉
Xamarin Profiler is a tool that seamlessly integrated with your Xamarin Application, collects and displays information to analyze your application at run time.
This can easily be used for finding memory leaks, resolving performance issues, monitoring resource usage at the run time, and more over to polish up your mobile app before delivering to your users.
Fun fact, is that this tool is actually based on the Mono log profiler which is a command line profiler that they previously used to analyze Mono run time applications. So what they have done is, they’ve added a bunch of improvements to it and added this intuitive UI on top of it deliver this analytical information for us developers! 😀
So there are three key features or as they call them “instruments” that’s packed along with Xamarin Profiler. 😀
Allocations instrument is used for analyzing the memory usage of your application at any given point of time at the run time.
Time Profiler instrument is used for tracking app performance, whereas it allows you to see which function took the longest to finish its execution.
Then we have the Cycles instrument, which provides you details with memory cycles occurred at the run time. May be I should explain it a bit further…
Memory Cycles: When you’re dealing with Xamarin Mobile applications, we have this environment of managed dot net environment and the un-managed native environment, sometimes due to our bad code a bunch of objects in the memory creates references to them selves in a circular manner, which could happen inside the dot net environment or most of the time in between the dot net and the un-managed environment. So in situations like that, the Garbage collector finds it hard to break through those circular references and release those objects, which results in those objects presisting in memory and the memory usage is only going to get increased. 🙂
So thanks to Xamarin Inspector we could easily identify those memory cycles and do the necessary changes in our code to eliminate them 😉
It also packs up these additional features allowing us to further drill down into details to analyze our application run time.
Why do we need Xamarin Profiler you asked? 😮
As Mobile Developers we need to make sure we deliver a beautiful pixel perfect design for our end users, and specially according to my UX lead he’s going to haunt me in my nightmares if I don’t deliver a pixel perfect UI implementation. 😀
So we always have to do the tiny changes in padding or the height or the width or may be a tiny hex value in the color and so on, whereas every time we do a change we need to recompile the project and run.
And then even if you get the app to run, you still have to go navigate to the page that you just made the changes to, which takes a lot of time.
Now I’m aware of the existence of Xamarin Forms Previewer, but if you had already tried it out, we are well aware there’s a whole bunch of bugs and issues with it when it comes to complex UI designs, which has a whole bunch of custom renderers.
So for a solution to all the above scenarios, Xamarin has given us this awesome tool, Xamarin Inspector! 😀
An awesome tool that allows you to debug and analyze or modify your application UI at run time without having to recompile your code. 😉
Something really cool about this tool is that it gives this awesome exploded 3D layers view of your application UI. Which makes it very easy to analyze the rendered layers and get rid of any extra layers to improve performance.
Xamarin Inspector has two main features, first is the REPL access. REPL stands for Read, Evaluate, Print and Loop, which allows you to inject code to your application in real time.
Then the Visual Inspector allows you to interact with your UI hierarchy in real time in an intuitive 3D view.
So that you could make necessary changes to your UI in real time and see it instantly rendered on your emulator. 😉
Something very important to keep in mind is that, with the latest update for this tool, they are providing you direct Xamarin Forms support, so no longer you have to deal with the native-rendered properties, you could easily make changes to your Xamarin Forms properties on the fly.
Yep that’s it fellas! now get out there and build something awesome with Xamarin! 😀
-Udara Alwis, out! 😛