8

My legacy holo app used to start up very fast.

Recently, I spend 1 year part-time, to port the holo app, to material designed app. Here's some significant changes which I had done.

  1. From API 21 to API 23
  2. From ActionBarSherlock to AppCompat Toolbar support library
  3. From support library v4:22.1.1 to v4:23.2.1
  4. Final compiled APK size changed from 4~5 MB to 5~6 MB.

One of the problem I'm facing right now is slow startup speed of my material designed app. It is significant slower (more than 2 seconds) than my holo designed app.

Fast start up speed for holo app

https://youtu.be/NguClpd6rG0

Slow start up speed for material designed app

https://youtu.be/TdnlZey0ABM

Note, before launching the app, I had ensure I kill the process (By going Settings -> App -> Force Stop) upfront.

As you can see from the video, once I tap on the icon, the ActionBar for the holo app is immediately shown. Where as, for material designed app, you need to wait around 2 to 3 seconds, only the Toolbar will become visible.

At first, I want to use TraceView to debug and root cause of the slowness. However, I realize TraceView can only be used on the app which is already started.

I had confirmed I don't perform any time consuming task in my Application, Activity and Fragment. Since both of my holo app & material designed app share the same logic code, I can't figure out the reason why my material designed app is slower.

Have anyone of you face the same problem? I was wondering, is there any good way for me to track down the root cause?

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
  • 2
    Are you using Android Studio 2.0, and Instant Run? Also just clarifying - is the final compiled version a 'release version' with all logging etc removed, or is it a debug version? The reason I ask, if it is still a debug version and you're using the 'Instant Run' option in the latest stable release of Android Studio this causes a lag/white screen on first load. If indeed the case, disable Instant Run, build the project and try running again. As I say this may not be the case as I'm working on a couple assumptions. – Mark Apr 21 '16 at 10:41
  • 1
    I was going to say same as @MarkKeen , slow startup might seem as an issue if using studio 2.0, but release build should fix these – Nilabja Apr 21 '16 at 10:44
  • 1
    "However, I realize TraceView can only be used on the app which is already started" -- use the `startMethodTracing()` and `stopMethodTracing()` methods on `Debug`. Start the method tracing sometime early (e.g., `onCreate()` of a custom `Application`). – CommonsWare Apr 21 '16 at 11:10
  • The `ActionBar` is part of the theme, and will always show up immediately, even before the `Activity` has reached `onCreate`. As the `Toolbar` is inflated as part of the activity layout, it won't be visible until this stage is reached. The initialisation time between `Application.onCreate` and `Activity.onCreate` is the time you're not seeing any bar, which is to be expected. The true measure would be the time from icon press -> activity layout inflated. – Kane O'Riley Apr 21 '16 at 11:30
  • Thanks @MarkKeen . You are right. If I rebuild the app in release mode, and sign it with key, the 3 seconds white screen will disappear. – Cheok Yan Cheng Apr 21 '16 at 14:36
  • @CheokYanCheng I asked a similar question recently and credit goes to somebody else .. http://stackoverflow.com/a/36593849/4252352 maybe worth an upvote to them, as it solved your issue ... I did add some insights why in the question update, although only theory, rather than evidence to back it up.. Anyway, glad the issue is resolved! – Mark Apr 21 '16 at 21:47

2 Answers2

1

This is false negative! As commented by @MarkKeen and @Nilabja, this is probably caused by new Android Studio 2.0. (In previous version of Android Studio, I didn't encounter this problem)

I'm using Android Studio 2.0.

Although I launch the app by tapping on icon, the app is uploaded via green play button in Android Studio. If I rebuild the APK in release mode, with signed key, and 3 seconds white screen doesn't appear. It has on-par speed with previous holo app.

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
-2

I guess by same reason why red car is faster than green one:) I am sure that the reason is not in design but in other parts of the app and dependencies.

SILINIK
  • 988
  • 7
  • 16