3,5 seconds startup for Android?

AliRFarahnakAliRFarahnak DKMember ✭✭

Loading dll files at startup is taking 3.5 seconds in our app.
Does anyone know how can we reduce this time?

Answers

  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited July 2015

    That's actually quite fast compared to mine ;)

    1. Look at what items are being constructed/run before you set your MainPage
      • defer your dependency registration where possible
      • delay any additional methods wherever possible.
      • Run the above methods in an async/await Task (if possible) after things are loaded.
    2. Switch to "Release" and see if it speeds up.
    3. I think the Linker setting can affect startup, but I'm not sure.
  • glucoseglucose CNMember

    Add a Splash Screen.

  • AliRFarahnakAliRFarahnak DKMember ✭✭

    @ChaseFlorell I did all that :( my users are complaining i have 5k daily users

    @glucose I already have that. But how should that help on the startup?

  • BrianMBrianM USMember ✭✭

    My Xamarin Forms Android app takes about 1 second to load. Can you post what is in your MainActivity:OnCreate method?

  • ChaseFlorellChaseFlorell CAInsider, University mod

    That sounds a little unrealistic imo. Most of the apps that I have on my device today take that long to start.

    Of your 5k users, are they all complaining, or is it just one or two?

  • AliRFarahnakAliRFarahnak DKMember ✭✭
    edited July 2015

    @BrianM hmm, is that when the process is in the Background? Sure I attached my MainActivity. I cant see how i can do my startup time better, even a HelloForms app startup too slow on a Sony Experia I use as an test phone.

    Im thinking about going back to my old eclipse project and drop Xamarin.Forms completely because of the slow startup :(

    @ChaseFlorell Well 1 unique user complains daily. I have 2-300 new installs everyday and almost the same amount uninstalls hmm!

    You guys could try out my app, feedback would be preciated. I cant see what im doing wrong else than the startup time.

    Google Play: https://play.google.com/store/apps/details?id=com.islam.halalcheck

    Thanks!

    [Activity(Label = "HalalCheck", Icon = "@drawable/icon", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

    public class MainActivity : XFormsApplicationDroid
    {

        /// <summary>
        /// Called when [create].
        /// </summary>
        /// <param name="bundle">The bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
    

    if DEBUG

            Insights.Initialize("-", this);
    

    else

            Insights.Initialize("-", this);
    

    endif

           /* _measureActivity = Insights.TrackTime("TimeStartup");
            _measureActivity.Start();*/
    
    
            if (!Resolver.IsSet)
            {
                this.SetIoc();
            }
            else
            {
                var app = Resolver.Resolve<IXFormsApp>() as IXFormsApp<XFormsApplicationDroid>;
                app.AppContext = this;
            }
            Forms.Init(this, bundle);
    
            App.Init();
            AppBrain.Init(this);
    
            AndroidPlaystoreAudit.Instance.UsesUntilPrompt = 2;
            AndroidPlaystoreAudit.Instance.TimeUntilPrompt = new TimeSpan(0, 0, 5);
            AndroidPlaystoreAudit.Instance.Run(this);
    
            LoadApplication(new App());
    
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.ContentDescription = e.View.StyleId;
                }
            };
    
    
        }
        protected override void OnResume()
        {
            base.OnResume();
            //_measureActivity.Stop();
            /*#if DEBUG
            SplashActivity.watch.Stop();
            System.Diagnostics.Debug.WriteLine("LoadApplication " + SplashActivity.watch.ElapsedMilliseconds);
            #endif*/
        }
    
    
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();
    
            var app = new XFormsAppDroid();
    
            app.Init(this);
    
            var documents = app.AppDataDirectory;
            var pathToDatabase = Path.Combine(documents, "halalcheck.db");
    
    
            resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice)
                // .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                // .Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>()))
                //  .Register<IJsonSerializer, Serialization.JsonNET.JsonSerializer>()
            .Register<IJsonSerializer, JsonSerializer>()
                //  .Register<IEmailService, EmailService>()
                //   .Register<IMediaPicker, MediaPicker>()
                //    .Register<ITextToSpeechService, TextToSpeechService>()
                //  .Register<IDependencyContainer>(resolverContainer)
            .Register<IXFormsApp>(app)
            .Register<INetwork, Network>()
    
          //  .Register<ISecureStorage>(t => new KeyVaultStorage(t.Resolve<IDevice>().Id.ToCharArray()))
            .Register<ISimpleCache>(
                t => new SQLiteSimpleCache(new SQLitePlatformAndroid(),
                    new SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));
    
            Resolver.SetResolver(resolverContainer.GetResolver());
        }
    
        public override void OnBackPressed()
        {
    
            if (((NavigationPage)App.Root.Detail).CurrentPage.GetType() == (typeof(HalalListPage)))
            {
                base.OnBackPressed();
                AppBrain.Ads.ShowInterstitial(this);
            }
            else if (((NavigationPage)App.Root.Detail).CurrentPage.GetType() == (typeof(HalalItemPage)) ||
                ((NavigationPage)App.Root.Detail).CurrentPage.GetType() == (typeof(AllahNamePage)))
            {
                base.OnBackPressed();
            }
            else
            {
                App.Root._menu.MenuListView.SelectedItem = App.Root._menu.MenuListView.ItemsSource.Cast<MenuItemHalalCheck>().First();
            }
        }
    
    }> 
    
  • AliRFarahnakAliRFarahnak DKMember ✭✭

    Hmm

Sign In or Register to comment.