forcedotcom / SalesforceMobileSDK-CordovaPlugin

Cordova plugin for the Salesforce Mobile SDK
Other
47 stars 114 forks source link

Multiple Android App instances after login using SDK OAuth #440

Closed vsvikram closed 4 years ago

vsvikram commented 5 years ago

Andoid Version: 7.0 Salesforce SDK Cordova Plugin Version: 6.2 Cordova Version: 8.0.0

Issue: When I build the hybrid android app and launched the app in android device, the salesforce login screen appeared. After putting in login credentials, when I clicked on "Allow" for connected app scope permissions, the app closed (seemed like it crashed). But when I tried to see it on the screen (which shows the running apps on the android device), I could see two instances of the app. Clicking on one instance opened the app which was already logged in and the second instance launched the Salesforce login screen again.

Further observations:

Please find attached screenshot of the device menu. screenshot_2019-02-11-16-53-33-223_com android systemui

bhariharan commented 5 years ago

@vsvikram How did you generate the app? What's the stack trace displayed in logcat for the crash? We fixed this issue a few releases ago. If you generate a new app from forcehybrid using the latest version (7.0.0), you shouldn't see this issue. Could you try that?

vsvikram commented 5 years ago

@bhariharan I've used forcehybrid for generating the Android platform and removed and reinstalled the mobile SDK plugin after installing all other plugins in the project.

When I closed both the instances of the app and reopened the app, it was working as expected in a single instance but as soon as I logged out and salesforce login screen appeared, I could see two instances of the app again. Below are the logs from the logcat window when I clicked log out and during loading of salesforce login screen:

2019-02-13 11:31:34.989 16437-16437/com.abbott.edge D/SystemWebChromeClient: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js: Line 37 : TIMING com.salesforce.sfaccountmanager:getCurrentUser: 60.123046875ms
2019-02-13 11:31:34.989 16437-16437/com.abbott.edge I/chromium: [INFO:CONSOLE(37)] "TIMING com.salesforce.sfaccountmanager:getCurrentUser: 60.123046875ms", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js (37)
2019-02-13 11:31:35.066 16437-16619/com.abbott.edge I/ForcePlugin: SFAccountManagerPlugin.execute, action: logout, jsVersion: 6.2.0
2019-02-13 11:31:35.067 16437-16619/com.abbott.edge I/SFAccountManagerPlugin: logout called
2019-02-13 11:31:35.261 16437-16437/com.abbott.edge D/CordovaActivity: Paused the activity.
2019-02-13 11:31:35.428 16437-16619/com.abbott.edge W/PluginManager: THREAD WARNING: exec() call to com.salesforce.sfaccountmanager.logout blocked the main thread for 363ms. Plugin should use CordovaInterface.getThreadPool().
2019-02-13 11:31:35.459 16437-16437/com.abbott.edge D/SystemWebChromeClient: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js: Line 37 : TIMING com.salesforce.sfaccountmanager:logout: 390.141845703125ms
2019-02-13 11:31:35.459 16437-16437/com.abbott.edge I/chromium: [INFO:CONSOLE(37)] "TIMING com.salesforce.sfaccountmanager:logout: 390.141845703125ms", source: file:///android_asset/www/plugins/com.salesforce/www/com.salesforce.util.exec.js (37)
2019-02-13 11:31:35.580 16437-16437/com.abbott.edge I/Timeline: Timeline: Activity_launch_request time:74604014 intent:Intent { flg=0x10000000 pkg=com.abbott.edge cmp=com.abbott.edge/com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity }
2019-02-13 11:31:35.738 16437-16437/com.abbott.edge I/CordovaLog: Changing log level to DEBUG(3)
2019-02-13 11:31:35.738 16437-16437/com.abbott.edge I/CordovaActivity: Apache Cordova native platform version 7.0.0 is starting
2019-02-13 11:31:35.739 16437-16437/com.abbott.edge D/CordovaActivity: CordovaActivity.onCreate()
2019-02-13 11:31:35.770 16437-16437/com.abbott.edge D/EgretLoader: EgretLoader(Context context)
2019-02-13 11:31:35.771 16437-16437/com.abbott.edge D/EgretLoader: The context is not activity
2019-02-13 11:31:35.788 16437-16437/com.abbott.edge D/SystemWebViewEngine: CordovaWebView is running on device made by: Xiaomi
2019-02-13 11:31:35.805 16437-16437/com.abbott.edge D/PluginManager: init()
2019-02-13 11:31:35.827 16437-16437/com.abbott.edge D/SalesforceHybridSDKManager: Setting up global store using config found in www/globalstore.json
2019-02-13 11:31:35.828 16437-16437/com.abbott.edge D/ResourceReaderHelper: Asset not found: www/globalstore.json
2019-02-13 11:31:35.829 16437-16437/com.abbott.edge D/StoreConfig: No store config available
2019-02-13 11:31:35.829 16437-16437/com.abbott.edge D/SalesforceHybridSDKManager: Setting up global syncs using config found in www/globalsyncs.json
2019-02-13 11:31:35.831 16437-16437/com.abbott.edge D/ResourceReaderHelper: Asset not found: www/globalsyncs.json
2019-02-13 11:31:35.832 16437-16437/com.abbott.edge D/SyncsConfig: No syncs config available
2019-02-13 11:31:35.838 16437-16437/com.abbott.edge D/CordovaActivity: Started the activity.
2019-02-13 11:31:35.844 16437-16437/com.abbott.edge D/CordovaActivity: Resumed the activity.
2019-02-13 11:31:35.849 16437-16437/com.abbott.edge I/ClientManager: No user account found
    com.salesforce.androidsdk.rest.ClientManager$AccountInfoNotFoundException: No user account found
        at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:155)
        at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:139)
        at com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity.onResume(SalesforceDroidGapActivity.java:146)
        at com.salesforce.androidsdk.ui.SalesforceActivityDelegate.onResume(SalesforceActivityDelegate.java:103)
        at com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity.onResume(SalesforceDroidGapActivity.java:136)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
        at android.app.Activity.performResume(Activity.java:6958)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3493)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3556)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2814)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:165)
        at android.app.ActivityThread.main(ActivityThread.java:6375)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
2019-02-13 11:31:35.850 16437-16437/com.abbott.edge W/BootConfig: unauthenticatedStartPage set for local app, but it will never be used.
2019-02-13 11:31:35.852 16437-16437/com.abbott.edge I/SfDroidGapActivity: onResumeNotLoggedIn - should authenticate/online - authenticating
2019-02-13 11:31:35.853 16437-16437/com.abbott.edge I/SfDroidGapActivity: authenticate called
2019-02-13 11:31:35.855 16437-16437/com.abbott.edge I/ClientManager: No account of type com.abbott.edge.login found
2019-02-13 11:31:35.910 16437-16437/com.abbott.edge W/ContentCatcher: Failed to notify a WebView
2019-02-13 11:31:35.915 16437-16451/com.abbott.edge I/Timeline: Timeline: Activity_launch_request time:74604349 intent:Intent { flg=0x20000000 pkg=com.abbott.edge cmp=com.abbott.edge/com.salesforce.androidsdk.ui.LoginActivity (has extras) }
2019-02-13 11:31:36.007 16437-16437/com.abbott.edge D/CordovaActivity: Paused the activity.
2019-02-13 11:31:36.092 16437-16437/com.abbott.edge V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fd7b889
2019-02-13 11:31:36.092 16437-16437/com.abbott.edge V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@c09808e
2019-02-13 11:31:36.122 16437-16437/com.abbott.edge D/EgretLoader: EgretLoader(Context context)
2019-02-13 11:31:36.123 16437-16437/com.abbott.edge D/EgretLoader: The context is not activity
2019-02-13 11:31:36.137 16437-16437/com.abbott.edge D/LoginActivity: User agent login flow being triggered
2019-02-13 11:31:36.171 16437-16437/com.abbott.edge W/ContentCatcher: Failed to notify a WebView
2019-02-13 11:31:36.697 16437-16437/com.abbott.edge D/CordovaActivity: Stopped the activity.
2019-02-13 11:31:36.706 16437-16437/com.abbott.edge D/CordovaActivity: Stopped the activity.
2019-02-13 11:31:36.709 16437-16437/com.abbott.edge D/CordovaActivity: CordovaActivity.onDestroy()
2019-02-13 11:31:36.711 16437-16437/com.abbott.edge D/CordovaWebViewImpl: >>> loadUrl(about:blank)
2019-02-13 11:31:36.713 16437-16437/com.abbott.edge W/cr_AwContents: WebView.destroy() called while WebView is still attached to window.
2019-02-13 11:31:36.719 16437-16437/com.abbott.edge W/ContentCatcher: Failed to notify a WebView
2019-02-13 11:31:36.728 16437-16437/com.abbott.edge W/cr_AwContents: Application attempted to call on a destroyed WebView
    java.lang.Throwable
        at org.chromium.android_webview.AwContents.f(SourceFile:320)
        at org.chromium.android_webview.AwContents.a(SourceFile:294)
        at org.chromium.android_webview.AwContents.q(SourceFile:596)
        at azJ.loadingStateChanged(SourceFile:157)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:329)
        at android.os.Looper.loop(Looper.java:142)
        at android.app.ActivityThread.main(ActivityThread.java:6375)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
2019-02-13 11:32:07.131 16437-17329/com.abbott.edge W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
2019-02-13 11:32:07.134 16437-17329/com.abbott.edge W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
2019-02-13 11:33:08.289 16437-17329/com.abbott.edge W/IInputConnectionWrapper: finishComposingText on inactive InputConnection

Meanwhile, I'll try and update the SDK to 7.0.0 and see if the issue persists.

ramanRajSaxena07 commented 5 years ago

Facing the same issue!! even after generating a new app from forcehybrid using the latest version (7.0.0).

Cordova version - 8.1.2 Android Studio - 3.3.1 Android version - 8.1.0 API 27

Not getting this issue when running app on emulator(API 28).

vsvikram commented 5 years ago

@bhariharan, can you please confirm if this is an issue with the SDK?

ramanRajSaxena07 commented 5 years ago

@bhariharan, Any update on this?

bhariharan commented 5 years ago

Do you have multiple apps generated from the SDK installed on your emulator? Could you verify that generating a new app using forcedroid@7.1.1 and running it on an emulator with no other SDK apps installed does not produce this behavior?

I'm unable to reproduce this issue. This would occur only if the package name and/or the account_type value in XML are the same for both apps, and LoginActivity is attempting to launch the other process.

ramanRajSaxena07 commented 5 years ago

The app is a hybrid app and it is built using forcehybrid@7.0.0 not by forcedroid.

Also, There is only one SDK app in the emulator.

bhariharan commented 5 years ago

Yes, I meant forcehybrid. Could you verify that generating a new app using forcedroid@7.1.1 and running it on an emulator with no other SDK apps installed does not produce this behavior?