SlideShare a Scribd company logo
Compiled Xaml in Xamarin.Forms
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Hi, I’m Matt
➔Making stuff with Xamarin since ‘13
➔The mobile guy at
➔I build MFractor to make your job easier :)
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Overview
➔Session Overview
◆ Xamarin.Forms Architecture
◆ Xaml overview
◆ What is Compiled Xaml?
◆ Using Compiled Xaml.
◆ Benchmarking a Xamarin.Forms App
◆ Benchmarking Analysis
◆ Summary
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Xamarin.Forms Architecture
➔Cross platform mobile solution
➔Typically MVVM Design
◆ Model -> Data entities
◆ View -> Visual code (Xaml)
◆ ViewModel -> Application state
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
What is Xaml?
➔A view markup language
◆ Fancy xml
◆ “eXtensible Application Markup Language”
◆ Developed by Microsoft as an hierarchical object creation language
◆ Defines visual content of page or view.
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Credit: James Montemagno
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Xaml Flavours
➔Non-compiled (Inflated):
◆ Embedded into assembly
● Bloat assembly size.
◆ Inflated at runtime
● Within “InitializeComponent”
● “LoadFromXaml”
➔Compiled:
◆ Xaml is converted into IL
● Much faster view creation.
◆ *.xaml removed from final assembly
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
➔App Wide:
Using Compiled Xaml
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
➔Skipping views:
Using Compiled Xaml
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
➔XamlC build task runs over assembly
◆ “Reweaving”
➔Inspects for XamlCompilation attributes
◆ Assembly wide
◆ View level
◆ Skip
➔Parses *xaml
➔InitiliseComponent replaced with IL code
➔Optimise new IL code
Using Compiled Xaml
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Using Compiled Xaml
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
➔Pros
◆ Significantly faster view creation
◆ Some runtime errors are now compile time errors
➔Cons
◆ Increased build times
◆ Some issues with resource dictionary.
● Undocumented(?) restrictions that corrupt the generated IL
● Resolve by replacing with x:Static expressions
◆ Binding errors are still runtime
Pros - Cons
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Performance Analysis
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Methodology
➔Tested “Xaml Samples” app
◆ https://github.com/matthewrdev/xamarin-samples/tree/master/compiled-xaml-benchmarking
➔Profile the startup time of a view
◆ Wrap InitialiseComponent in a profiler
◆ Log with non-blocking logger
◆ Record time in milliseconds for 3 screens
◆ Open each screen 3 times
◆ Using 4 different devices
● iOS Simulator
● iPhone SE
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Inflated Xaml Results
Home Page Grid Page Keypad Page
IOS Simulator 126ms 6.33ms 8ms
iPhone SE 103ms 48.66ms 79.33ms
Lenovo 1030.33ms 87.33ms 145.66ms
Genymotion 170ms 9.33ms 10.33ms
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Compiled Xaml Results
Home Page Grid Page Keypad Page
IOS Simulator 21ms 3.00ms 2.33ms
iPhone SE 26.33ms 11.66ms 14.66ms
Lenovo 185.33ms 11.33ms 51.66ms
Genymotion 38ms 1.34ms 6.67ms
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
➔Startup page is always most expensive
➔More x:Static == less startup time
➔Less dynamic bindings = less startup time
➔Resource Dictionaries can cause runtime errors.
Observations
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Results Summary
➔Compiled Xaml is 20% as expensive as inflated xaml.
➔Build time increase for compiled xaml
● 15s for 40 xaml project
➔Android AOT Compilation provides further improvements:
◆ 2% at huge build time cost.
◆ +100s for moderate sized app
➔Subsequent view creations come at reduced cost
◆ Compiled -> 10% of initial time
◆ Inflated -> 50% of initial time
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Resources
➔Xaml Samples Source Code
➔Performance Benchmarking Data
➔Xaml Basics
➔Xamarin Forms Source Code
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Questions?
@matthewrdev | matthew.ch.robbins@gmail.com | mfractor.com
Future Talks?
What do you want next?
● Revised Android Network Security talk?
● Dissection of a Xamarin.Android apk?
● Building a Xamarin Studio addin?
● FFImageLoading in Xamarin.Forms?

More Related Content

PDF
Staying Dry in Rails using code generation
PPT
Wordcamp Birmingham 2009
PDF
Distributed caching for your next node.js project cf summit - 06-15-2017
PPT
Standards.Next: Canvas
PDF
HTML GL - 60 FPS and amazing effects by rendering HTML/CSS in WebGL, framewor...
PDF
Migrating your Web app to Virtual Reality
PDF
Introduction to Xamarin.Forms
PPTX
SydMobNet March 2016: Matthew Robbins - Android M Security Policies
Staying Dry in Rails using code generation
Wordcamp Birmingham 2009
Distributed caching for your next node.js project cf summit - 06-15-2017
Standards.Next: Canvas
HTML GL - 60 FPS and amazing effects by rendering HTML/CSS in WebGL, framewor...
Migrating your Web app to Virtual Reality
Introduction to Xamarin.Forms
SydMobNet March 2016: Matthew Robbins - Android M Security Policies

Similar to Compiled Xaml Performance in Xamarin.Forms (20)

PDF
Introduction to Xamarin
PPTX
extending-and-optimizing-xamarin-forms-apps
PPTX
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
PDF
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
PDF
Introduction to Building Wireframes - Part 2
PDF
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
PPTX
Accelerating Xamarin Development
PPTX
Lean Prototyping - A Practical Guide
PDF
Seaside - Why should you care? (OSDC.fr 2010)
PPTX
Dia 4.1 mvvm cross
PPTX
Streamlining .net core development using Docker
PDF
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
PDF
Xamarin vs. native script which one is the ideal cross-platform framework fo...
KEY
Intro To Django
PPTX
Xamarin 101
PPTX
Build 2017 - B8099 - What's new in Xamarin.Forms
PPTX
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
PDF
Webinar - Matteo Manchi: Dal web al nativo: Introduzione a React Native
PPTX
#SydMobNet Nov 2014: Evolve 2014 recap
PPTX
We love XAML - Blend for Windows och Phone development - TechDays Sweden 2014
Introduction to Xamarin
extending-and-optimizing-xamarin-forms-apps
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Introduction to Building Wireframes - Part 2
XAML Development with Xamarin - Jesse Liberty | FalafelCON 2014
Accelerating Xamarin Development
Lean Prototyping - A Practical Guide
Seaside - Why should you care? (OSDC.fr 2010)
Dia 4.1 mvvm cross
Streamlining .net core development using Docker
State of Union: Xamarin & Cross-Platform .NET in 2016 and Beyond
Xamarin vs. native script which one is the ideal cross-platform framework fo...
Intro To Django
Xamarin 101
Build 2017 - B8099 - What's new in Xamarin.Forms
C# everywhere - Building Cross-Platform Apps with Xamarin and MvvmCross
Webinar - Matteo Manchi: Dal web al nativo: Introduzione a React Native
#SydMobNet Nov 2014: Evolve 2014 recap
We love XAML - Blend for Windows och Phone development - TechDays Sweden 2014
Ad

Recently uploaded (20)

PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Cost to Outsource Software Development in 2025
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PPTX
Patient Appointment Booking in Odoo with online payment
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Digital Systems & Binary Numbers (comprehensive )
Design an Analysis of Algorithms I-SECS-1021-03
Oracle Fusion HCM Cloud Demo for Beginners
Why Generative AI is the Future of Content, Code & Creativity?
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Weekly report ppt - harsh dattuprasad patel.pptx
Download FL Studio Crack Latest version 2025 ?
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Cost to Outsource Software Development in 2025
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
CHAPTER 2 - PM Management and IT Context
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Reimagine Home Health with the Power of Agentic AI​
iTop VPN Crack Latest Version Full Key 2025
Salesforce Agentforce AI Implementation.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
17 Powerful Integrations Your Next-Gen MLM Software Needs
Patient Appointment Booking in Odoo with online payment
Ad

Compiled Xaml Performance in Xamarin.Forms