Slow startup of xamarin app

后端 未结 4 1705
一整个雨季
一整个雨季 2021-02-09 06:02

We are developing a cross platform app on a PCL, but for the time being we are only using android devices for testing.
Our concern is that its taking about 6 to 8 seconds (d

4条回答
  •  旧时难觅i
    2021-02-09 06:25

    I'll put together all the solutions we found for this, so its all in one place.

    One of the answers linked this post, which was very useful.

    Besides that we also did the following things:

    • Check "optimize code" box on Properties in all projects. Not sure if that improves startup time specifically but it seems to help on the general performance a bit.
    • Add AOT and LLVM. We found a way to do this even though the option isn't available on our IDE. This increases the build time by a lot so if you want to do it I'd recommend doing it only for release builds.
    • Enable Xamarin Fast Renders. This is an experimental thing so you should read some documentation about it, but its done by adding this line global::Xamarin.Forms.Forms.SetFlags("FastRenderers_Experimental"); on MainActivity.OnCreate() method, before global::Xamarin.Forms.Forms.Init(this, bundle);
    • Update our Xamarin.Forms Nuget Version. This needs to be the same version on all projects of your solution, we had some issues with tap gestures which where also improved by this.
    • Link SDK Assemblies. On Properties > Android Options under Linking you can set to link "SDK Assemblies Only". You can also set to all assemblies, but this is not recommended if you are using custom assemblies.
    • Pre-Load screens. This improved by a lot the performance on the app itself what we did is load on each screen, on background, the views and view-models that where needed next, so when pushing them onto the navigation stack they were already loaded. This reduced by a lot the time on transition between pages.

提交回复
热议问题