Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
757 views
in Technique[技术] by (71.8m points)

performance - Why does my App start incredibly slow (10s+) at first run, showing only white screen on android 5.0?

I have a freshly created app (built in android studio 2.0), having a few activities.

When I test it on my Android 4.3 (note 2) device it starts nicely and fast after a clean install, in turn the same app on my samsung galaxy S4 with android 5.0, hangs for about 10-15 seconds while showing a white screen only.

To be sure I have unplugged it from android studio and commented out almost every method that was in my MainActivity, but it makes no difference, I get the same 10 seconds startup after install or after clearing the app's cache.

I am really concerned about this issue, this could really hurt my app's user experience.

What could be wrong?

Logcat:

05-10 02:07:14.266 26036-26631/com.cerculdivelor I/GMPM: App measurement is starting up
05-10 02:07:14.747 26036-26036/com.cerculdivelor W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:14.907 26036-26036/com.cerculdivelor I/LOGTAG: Table has been created!
05-10 02:07:14.967 26036-26650/com.cerculdivelor D/OpenGLRenderer: Render dirty regions requested: true
05-10 02:07:15.007 26036-26649/com.cerculdivelor I/Timeline: Timeline: Activity_launch_request id:com.cerculdivelor time:111211793
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isShipBuild true
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Thread-62285-755755249: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.137 26036-26645/com.cerculdivelor I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
                                                               OpenGL ES Shader Compiler Version: E031.25.03.06
                                                               Build Date: 01/24/15 Sat
                                                               Local Branch: AF11_RB1_AU15
                                                               Remote Branch: 
                                                               Local Patches: 
                                                               Reconstruct Branch: 
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/OpenGLRenderer: Initialized EGL, version 1.4
05-10 02:07:15.197 26036-26650/com.cerculdivelor D/OpenGLRenderer: Enabling debug mode 0
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.988 26036-26051/com.cerculdivelor I/art: Background sticky concurrent mark sweep GC freed 40699(4MB) AllocSpace objects, 12(383KB) LOS objects, 0% free, 49MB/49MB, paused 1.007ms total 161.285ms
05-10 02:07:16.168 26036-26043/com.cerculdivelor W/art: Suspending all threads took: 5.249ms
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:16.238 26036-26036/com.cerculdivelor I/Choreographer: Skipped 44 frames!  The application may be doing too much work on its main thread.
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111214133
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2d342603 time:111214133
05-10 02:07:17.369 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{10b472f8 token=android.os.BinderProxy@2d342603 {com.cerculdivelor/com.cerculdivelor.MainActivity}} show : false
05-10 02:07:30.622 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111227400
05-10 02:08:36.286 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{1e1f9137 token=android.os.BinderProxy@4e1915e {com.cerculdivelor/com.cerculdivelor.SplashActivity}} show : true

Main Activity:

public class MainActivity extends AppCompatActivity implements View.OnClickListener, HttpConActivity.downloadListener {

    private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
    private BroadcastReceiver mRegistrationBroadcastReceiver;
    private boolean isReceiverRegistered;
    CallbackManager callbackManager;
    private AccessTokenTracker accessTokenTracker;
    private List<ProductsGetterSetter> products;
    private SQLiteDataSource datasource;
    private TextView toolbarTitle;
    private String fbId;
    private String name;
    private TextView notifBubbleText;
    private TextView inboxBubbleText;
    private ArrayList<NotificationSetter> notifications;
    private SharedPreferences preferences;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
        setSupportActionBar(toolbar);

        /**** 
TextView title = (TextView) findViewById(R.id.toolbar_title);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Baron.otf");
        title.setTypeface(tf);

        TextView feedTv = (TextView) findViewById(R.id.feedTv);
        feedTv.setOnClickListener(this);
        TextView shopTv = (TextView) findViewById(R.id.shopTv);
        shopTv.setOnClickListener(this);
        TextView sellTv = (TextView) findViewById(R.id.sellTv);
        sellTv.setOnClickListener(this);
        TextView likesTv = (TextView) findViewById(R.id.likesTv);
        likesTv.setOnClickListener(this);
        TextView myShopTv = (TextView) findViewById(R.id.myShopTv);
        myShopTv.setOnClickListener(this);


        // Send crash report if exists
        if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
            Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
        }

        ****/

    }


    @Override
    protected void onResume() {
        super.onResume();

       /****
        datasource = new SQLiteDataSource(this);
        datasource.open();

        preferences = getSharedPreferences("user", MODE_PRIVATE);
        if (preferences.getString("fbId", "").equals("")) {
            promtForLogin();
        } else {
            initialiseApp();
        }

        this.invalidateOptionsMenu();
        ****/
    }

Gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.cerculdivelor"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.android.support:cardview-v7:23.0.+'
    compile 'com.android.support:recyclerview-v7:23.0.+'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile "com.google.android.gms:play-services-gcm:8.3.0"

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is because Instant Run takes awhile to load. The blank/white screen will go away in production builds.

I'm not sure why Instant Run takes so long to load. If you look in the app's internal cache directory you will see quite a few dex files. There was an article about how Instant Run works posted a couple days ago here: https://medium.com/google-developers/instant-run-how-does-it-work-294a1633367f#.ntl30mbe2

You can disable Instant Run or just be aware that your production builds will not have this blank white screen.

Similar question: Android Studio 2.0 - pause/white screen on App first run


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...