apache / apache/cordova-android
Cannot resume the app after hiding with lounchMode "singleInstance" or "single Top"
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 16h 18m
- Merged PRs (30d)
- 11
Description
# Bug Report
## Problem
Hallo guys!
I found some problem.. maybe anyone can help.
with android “singleInstance” or “singleTop” after onPause my app was killed from system tasks. and then if I switched to the app again cordova do app restart…. How I can fix this?
tested on:
- `Huawei P20 Pro` - `onRESUME` event `not` fired
- `Nexus 5X` - `onRESUME` event `always` fired
### What is expected to happen?
back to the app and not restart the app after opening
### What does actually happen?
```
2021-01-18 14:54:51.184 22311-22311/com.example.myapp D/CordovaActivity: Paused the activity.
2021-01-18 14:54:51.195 22311-22311/com.example.myapp I/chromium: [INFO:CONSOLE(4)] "FIRE -> onDevicePause -> device paused", source: file:///android_asset/www/js/app.min.js (4)
2021-01-18 14:54:51.418 22311-22348/com.example.myapp D/ZrHung.AppEyeUiProbe: not watching, wait.
2021-01-18 14:54:51.648 22311-22349/com.example.myapp W/libEGL: EGLNativeWindowType 0x7524822950 disconnect failed
2021-01-18 14:54:51.657 22311-22349/com.example.myapp W/libEGL: EGLNativeWindowType 0x7524822d10 disconnect failed
2021-01-18 14:54:52.130 22311-22311/com.example.myapp D/CordovaActivity: Stopped the activity.
2021-01-18 14:54:52.159 22311-22311/com.example.myapp D/CordovaActivity: CordovaActivity.onDestroy()
2021-01-18 14:54:52.160 22311-22311/com.example.myapp D/CordovaWebViewImpl: >>> loadUrl(about:blank)
2021-01-18 14:54:52.170 22311-22311/com.example.myapp W/cr_AwContents: WebView.destroy() called while WebView is still attached to window.
2021-01-18 14:54:52.179 22311-22311/com.example.myapp D/ActivityThread: Remove activity client record, r= ActivityRecord{de81ed2 token=android.os.BinderProxy@88805e7 {com.example.myapp/com.example.myapp.MainActivity}} token= android.os.BinderProxy@88805e7
2021-01-18 14:54:52.188 22311-22311/com.example.myapp W/cr_AwContents: Application attempted to call on a destroyed WebView
java.lang.Throwable
at org.chromium.android_webview.AwContents.p(chromium-TrichromeWebViewGoogle.aab-stable-428014133:2)
at vM.loadingStateChanged(chromium-TrichromeWebViewGoogle.aab-stable-428014133:2)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:363)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
```
## Information
```
$ cordova -v
10.0.0
```
```
$ cordova platform ls
Installed platforms:
android 9.0.0
ios 6.1.1
```
```
$ cordova plugin ls
com.lampa.startapp 6.1.6 "startApp"
cordova-clipboard 1.3.0 "Clipboard"
cordova-plugin-android-fingerprint-auth 1.5.0 "FingerprintAuth"
cordova-plugin-android-permissions 1.1.2 "Permissions"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-apprate 1.7.1 "AppRate"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-camera 5.0.1 "Camera"
cordova-plugin-ckopenimage 1.2.0 "cordova-plugin-ckopenimage"
cordova-plugin-customurlscheme 5.0.2 "Custom URL scheme"
cordova-plugin-deeplinks 1.1.1 "Cordova Deeplinks Plugin"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-document-viewer 1.0.0 "SitewaertsDocumentViewer"
cordova-plugin-file-opener2 3.0.5 "File Opener2"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-ignore-lint-translation 0.0.1 "cordova-plugin-ignore-lint-translation"
cordova-plugin-inappbrowser 4.1.0 "InAppBrowser"
cordova-plugin-ios-keychain 3.0.1 "KeyChain Plugin for Cordova iOS"
cordova-plugin-nativestorage 2.3.2 "NativeStorage"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-safariviewcontroller 1.6.0 "SafariViewController"
cordova-plugin-splashscreen 6.0.0 "Splashscreen"
cordova-plugin-touch-id 3.3.1 "Touch ID"
cordova-plugin-whitelist 1.3.4 "Whitelist"
```
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start by reproducing the reported behavior with Android launchMode values singleInstance and singleTop, using the CordovaActivity lifecycle log and the onPause/onResume events as entry points. Compare the Huawei P20 Pro and Nexus 5X results, then determine what behavior should be preserved when the activity is reopened. Done means the app resumes without restarting and the expected resume event behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100