EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
567 stars 630 forks source link

exec() call to GooglePlus.trySilentLogin blocked the main thread for 2001ms. Plugin should use CordovaInterface.getThreadPool(). #371

Open gustavo-iniguez-goya opened 7 years ago

gustavo-iniguez-goya commented 7 years ago

Hi,

Whenever I use trySilentLogin(), the call freezes the UI for up to ~1500-3000ms. Device: Nexus 4 LG SO: Android 7.x

04-10 12:15:43.774 24113 24235 W PluginManager: THREAD WARNING: exec() call to GooglePlus.trySilentLogin blocked the main thread for 2001ms. Plugin should use CordovaInterface.getThreadPool().

After change this in https://github.com/EddyVerbruggen/cordova-plugin-googleplus/blob/master/src/android/GooglePlus.java#L181:

if (apiConnect.isSuccess()) {
    handleSignInResult(Auth.GoogleSignInApi.silentSignIn(this.mGoogleApiClient).await());
}

by:

cordova.getThreadPool().execute(new Runnable() {
    public void run() {
        try{
            if (apiConnect.isSuccess()) {
                handleSignInResult(Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient).await());
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
});

the same message apperars, but the blocking time decreases to ~30-100ms: 04-10 12:15:43.774 24113 24235 W PluginManager: THREAD WARNING: exec() call to GooglePlus.trySilentLogin blocked the main thread for 86ms. Plugin should use CordovaInterface.getThreadPool().

Is it worth to change it? May it cause any problem? I've been using this change for a week, and seems to work well.

aokj4ck commented 6 years ago

Duplicate of https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/239