Ways To Boost Xamarin.forms Apps Startup Time
The Xamarin SDKs for iOS and Android give great performance support in which to build Xamarin.Forms cross-platform applications. As you operate to tune the speed and responsiveness of Xamarin.Forms application, the identical rules that improve the experience of your apps created with the Xamarin SDKs for iOS and Android, will also enhance those operating cross-platform with Xamarin.Forms—and that experience starts at startup.
- Load Local Content First
We usually require to load new data as soon as our application has begun, but this will only reduce the first screen from rising and populating. Use state from an early run or have content set to operate that is for the initial execution.
If your application is offline ready and we suggest it is, then you're all set to populate the data for your first screen instantly. Azure Mobile Apps and Realm with Azure are excellent options.
You need to go to the web for your first run content, implement some UI informing the user whatever you're making by using a loading indicator. It is also an excellent chance to replace the empty part of your screen with helpful placeholder content to reinforce why this screen exists, what the user can assume from the app, or only some fun! Whatever your choice here, don't leave a screen empty.
- Optimize Your Assets
Video and Images are massive and can slow the initial rendering of a screen. Reduce reliance on huge assets and optimize any media you use for the essential dimensions. Don't depend on the OS to resize the screen for you.
For Android target screens, assets are placed in folders designing their density.
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
When you insert a big image in the ldpi folder and apply that asset on a screen of xxhdpi, Android will size it up. It is late and will bloat your runtime memory requirement, rarely even to the point of crashing your application.
To maintain that many densities and that many assets, it's advantageous to use an application such as Zeplin or Sketch to create various sizes from an individual design origin.
Xamarin.Android 7.0 freshly attached a test option to pre-crunch PNG files called AndroidExplicitCrunch. It moreover decreases the size of your assets (and application), increases build time and assures they are optimized for runtime.
- Lazy Load Anything You Don't Need Immediately
The App.xaml Resources is a suitable spot to put fonts, styles, and other resources that you'll use throughout your application, but it's also all loaded at startup. If you're trying to erase every additional millisecond from your startup time, eliminate anything here that you don't need and lazy load it by page or in another method.
4.Enable XAML Compilation
XAML is a successful and expressively robust way to represent your user interface. If you opt to remain in C# and create your UI there, it's generally compiled onward with the remainder of your code, providing you compile-time checking and quick. When you want that same benefit while using XAML, you enable XAML Compilation (XAMLC). It will compile your XAML within Intermediate Language (IL) and join it to your compiled assembly, finishing in more accelerated startup and runtime execution.
At the application level, you may submit your XAMLC options, and it will affect your complete app.
- Reduce Number of Assemblies
Ease comes at a price, as general. It may be a minimal cost, but you want to neglect no jewel unturned when attuning for execution. While NuGet packages are fantastic for leveraging different libraries, the truth is that the more extra (and higher) assemblies, your mobile application depends on slows down the performance as calls pass beyond borders. Xamarin.Forms.
Count the pros/cons of each dependence and, when possible, carry that code into your primary application. Your mileage may vary, so give it a look. It is an often-overlooked execution consideration that may reward bonuses for you.
Add comment