Archived APK with AOT slower than Release build

Wojciech_KulikWojciech_Kulik ✭✭USMember ✭✭
edited November 2018 in Xamarin.Android

Hi,

I'm trying to release mobile application in Xamarin.Forms on Android. However, Android startup time is insane and unacceptable (about 10 seconds on some devices).

I've spent several hours browsing internet to find some optimizations. Therefore I've got installed latest version of Visual Studio for Mac, NDK and Mono. I also optimized assets and turned on XAML compilation. Plus I removed almost all initialization from MainActivity and MainApplication OnCreate event (also from my main view).

After all it turned out, that the only thing that cause any improvement is turning on AOT. Therefore I tested it with the following options:

<AotAssemblies>True</AotAssemblies>
<AndroidAotMode>Normal</AndroidAotMode>
<EnableLLVM>true</EnableLLVM>

Startup time dropped to about 4.5s, which is better. I thought that I will publish this update. But somehow it turned out that after "Archive for publishing" this APK is even slower than without AOT. Now even scrolling in the application works terribly slow.

Any ideas how to fix the problem? I don't know why release uploaded from Visual Studio is so dramatically different than the one generated for publishing (even using the same scheme - Release).

Full Release configuration:
https://pastebin.com/X1mKQsfJ

Best regards,
Wojciech

Posts

  • Wojciech_KulikWojciech_Kulik ✭✭ USMember ✭✭

    After further investigation, it turned out that the problem was with too big image. Strange thing that the image wasn't moving while scrolling, but even though it was causing laggy scrolling.

  • batmacibatmaci ✭✭✭✭✭ DEMember ✭✭✭✭✭

    you arent using any linker in your release? your apk size should be really big and some settings i wonder why you use
    why do you have DebugSymbols and pdbonly? this should increase your apk size even more. what are Optimize=true and AndroidManagedSymbols=true for?
    It is also suggested to add this line if you are using AOT with LLVM
    <AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>

        <DebugSymbols>true</DebugSymbols>
            <DebugType>pdbonly</DebugType>
            <Optimize>true</Optimize>  
            <AndroidManagedSymbols>true</AndroidManagedSymbols>
    
Sign In or Register to comment.