Slow Startup

BuildCalcBuildCalc USMember ✭✭✭
edited February 2013 in Xamarin.Android

I have just completed a port for a Java Android app to Mono for Android. While the Mono for Android is app equivalent in responsiveness, it is noticeably slower to load from a cold start. I have an application subclass that does some checks and loads some globally accessible data, and then I have an activity subclass that displays this data. I checked the time of these operations for both systems on the same device (time started in the 'onCreate' method of the application subclass, and stopped in the 'onWindowFocusChanged' method of the activity), and the Mono for Android app actually measured faster, but it is clearly slower to display the data.

Is there an explanation for this?
Is there some intrinsic overhead to the startup time for a Mono for Android app?
Has anyone else had similar results?

Posts

  • fastforwardfastforward MYMember

    Looks like Mono for Android had a slower startup as compared with Eclipse though the development time could be faster. I guessed it has something to do with the configuration. But I still believe that this could be fixed soon.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    There is some mandatory startup overhead, by nature of our architecture.

    Loading the .apk into memory (via mmap(2)), initializing the JIT, JITing code... All of these contribute to startup overhead. We may be able to reduce some of these further, but it won't be possible to entirely eliminate all overhead.

    If your app startup is taking too long, you can use a splash screen, but the last time I measured the overhead was only ~1.2s on a Nexus One (nearly three year old hardware)...

  • jeff.albanojeff.albano USMember ✭✭
    edited August 2014

    Hi Jonathan,

    Would it be possible for you guys to maybe have an initial activity indicator or an image indicating the loading to omit the white page thing before the application start up? A lot of users were complaining about it, and we cannot do anything.

    If there will be a way for you guys to do it, it is much appreciated and will make the application have responsive start up look, until initializing is done.

    Thanks so much.

  • davidbordoleydavidbordoley USMember

    See: http://developer.xamarin.com/guides/android/user_interface/creating_a_splash_screen/

    There are some subtleties to getting it to work right (tm), but that is the general approach to follow.

  • jeff.albanojeff.albano USMember ✭✭

    Hi Jonathan,

    Just came back to this issue as we decided to just leave it for the mean time.
    Thanks! Working well now with a beautiful splash screen.

  • ChintanNaikChintanNaik INMember

    Hi Jonathan,

    I found another reason of slowness. Would like your input in case if I am missing anything. Below is the case.

    I am building APK using Xamarin 5.3 (build 439) on Mac. On my Samsung Galaxy Android 4.1.2 (CPU architecture: ARM Cortex - A9) device start up time is,

    Average about 4.5 seconds when APK is build with ABI options armeabi and armeabi-v7a,
    Average about 4.5 seconds when APK is build with ABI option armeabi,
    Average about 3.5 seconds when APK is build with ABI option armeabi-v7a.

    So it looks that it uses armeabi ABI even if APK build with both (armeabi and armeabi-v7a) and device supports armeabi-v7a. Please correct if my understanding is wrong.

    Do you think if I am missing anything? OR it could be a problem with the APK build by Xamarin? OR something wrong with Android?

    In this article - http://developer.xamarin.com/guides/android/advanced_topics/MultiCore_devices_XamarinAndroid/ , Xamarin says - "Note: Xamarin.Android will ensure that .so are added to the APK in the correct order. This bug should not be an issue for users of Xamarin.Android.". This could be similar to that?

    Thanks,
    Chintan.

  • ChintanNaikChintanNaik INMember

    Jonathan,

    Please ignore my above post. There was an error while measuring timings. App startup time is almost same in any of two cases - (i) APK build with ABI options armeabi and armeabi-v7a (ii) APK build with just armeabi-v7a.

    Thanks,
    Chintan.

  • denominator01denominator01 USMember ✭✭

    Are there any updates on performance improvements on startup time for Xamarin apps?

  • Is it possible to create splash screen for API level10?

  • BrianTackerBrianTacker USMember

    Im noticing this as well, I implemented a splash screen but the delay seems the be happening before the app is "Launched". So if I force close the app, click on the icon, it takes 1-2 seconds for the splash screen to even display. If anyone has a way to display a splash screen right away I would appreciate it.

  • cwphillicwphilli USMember ✭✭✭

    @BrianTacker said:
    Im noticing this as well, I implemented a splash screen but the delay seems the be happening before the app is "Launched". So if I force close the app, click on the icon, it takes 1-2 seconds for the splash screen to even display. If anyone has a way to display a splash screen right away I would appreciate it.

    My splash screen is displaying immediately.
    Would you mind sharing your code, or starting your own thread and tagging me?

  • BrianTackerBrianTacker USMember

    @cwphilli said:
    My splash screen is displaying immediately.
    Would you mind sharing your code, or starting your own thread and tagging me?

    Ok so after some digging I found out the issue was because I had no "base" theme for the custom splash theme and no background image set. So basically it was just applying a transparent theme before the OnCreate was being called and drawing the splash layout. Once I changed that Im getting the splash instantly.
    Now Im having a new issue where I need to display an ImageView inside the splash, but thats a new issue all together :-/

  • cwphillicwphilli USMember ✭✭✭

    Why do you need to display an ImageView inside the splash?
    I set the theme of the SplashActivity, then in my styles.xml simple set the windowBackground to my image from a resource.

  • BrianTackerBrianTacker USMember

    @cwphilli said:
    Why do you need to display an ImageView inside the splash?
    I set the theme of the SplashActivity, then in my styles.xml simple set the windowBackground to my image from a resource.

    Since there are so many different aspect ratios out there, I have a single PNG that can scale regardless of the screen width or height. I tried the method you mentioned at first but my logo looks distorted or stretched on certain ratios.

  • Amit02Amit02 INMember ✭✭

    @cwphilli i am still getting this issues while launching my app. it is taking 1-2s time to launch.

Sign In or Register to comment.