Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bug: Android app is restarting every time we access a plugin (share/camera/ library etc) #4130

Closed
joaolnpr opened this issue Jan 29, 2021 · 14 comments

Comments

@joaolnpr
Copy link

joaolnpr commented Jan 29, 2021

Bug Report

Capacitor Version

  Capacitor Doctor

Latest Dependencies:

  @capacitor/cli: 2.4.6
  @capacitor/core: 2.4.6
  @capacitor/android: 2.4.6
  @capacitor/electron: 2.4.6
  @capacitor/ios: 2.4.6

Installed Dependencies:

  @capacitor/cli 2.4.6
  @capacitor/core 2.4.0
  @capacitor/android 2.4.5
  @capacitor/ios 2.4.5
  @capacitor/electron not installed

[success] Android looking great! 👌
[error] Xcode is not installed

Platform(s)

Android

Current Behavior

Every time we access to a capacitor plugin the app restarts, Share, Camera or Library, all of them facing same issue.

Expected Behavior

The app should not restart once we access a plugin

Code Reproduction

Video: After we share, the app is restarting:

WhatsApp.Video.2021-01-29.at.14.14.59.mp4

Other Technical Details

npm --version output: 6.13.4

node --version output: v12.14.0

pod --version output (iOS issues only):

Additional Context

LOG Cat from Android Studio:

`2021-01-29 14:17:12.294 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: ViewPostIme pointer 0
2021-01-29 14:17:12.308 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: ViewPostIme pointer 1
2021-01-29 14:17:12.338 2503-2569/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/assets/fonts/Barlow-SemiBold.ttf
2021-01-29 14:17:12.346 2503-2503/com.flowrobe.app D/InputMethodManager: HSIFW - flag : 0 Pid : 2503
2021-01-29 14:17:13.767 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: ViewPostIme pointer 0
2021-01-29 14:17:13.810 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: ViewPostIme pointer 1
2021-01-29 14:17:13.830 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 36488273, pluginId: Share, methodName: share
2021-01-29 14:17:13.831 2503-2715/com.flowrobe.app V/Capacitor: callback: 36488273, pluginId: Share, methodName: share, methodData: {"title":"Share your FlowRobe love 🔥❤","text":"Check out FlowRobe where you can swipe nice clothes, upload easier than ever, and give preloved new lives! 🙈👟♻ \n 👉🏽 ","url":"http://flowrobe.com/app","dialogTitle":"Share your FlowRobe love 🔥❤"}
2021-01-29 14:17:13.846 2503-2503/com.flowrobe.app D/InputMethodManager: HSIFW - flag : 0 Pid : 2503
2021-01-29 14:17:13.865 2503-2503/com.flowrobe.app D/Capacitor: App paused
2021-01-29 14:17:13.880 2503-2503/com.flowrobe.app I/Capacitor/Console: File: http://localhost/main-es2015.js - Line 855 - Msg: Successful share [object Object]
2021-01-29 14:17:13.982 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
2021-01-29 14:17:13.982 2503-2503/com.flowrobe.app D/InputMethodManager: prepareNavigationBarInfo() DecorView@30c61b[MainActivity]
2021-01-29 14:17:13.983 2503-2503/com.flowrobe.app D/InputMethodManager: getNavigationBarColor() -855310
2021-01-29 14:17:14.149 2503-2503/com.flowrobe.app D/InputMethodManager: HSIFW - flag : 0 Pid : 2503
2021-01-29 14:17:14.881 2503-2503/com.flowrobe.app D/InputTransport: Input channel destroyed: 'ClientS', fd=173
2021-01-29 14:17:16.336 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: stopped(false) old=false
2021-01-29 14:17:16.337 2503-2503/com.flowrobe.app D/Capacitor/App: Firing change: true
2021-01-29 14:17:16.338 2503-2503/com.flowrobe.app V/Capacitor/App: Notifying listeners for event appStateChange
2021-01-29 14:17:16.338 2503-2503/com.flowrobe.app D/Capacitor/App: No listeners found for event appStateChange
2021-01-29 14:17:16.367 2503-2503/com.flowrobe.app D/Capacitor: App resumed
2021-01-29 14:17:16.370 2503-2503/com.flowrobe.app D/ViewRootImpl@4d8758f[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
2021-01-29 14:17:16.370 2503-2503/com.flowrobe.app D/InputMethodManager: prepareNavigationBarInfo() DecorView@30c61b[MainActivity]
2021-01-29 14:17:16.370 2503-2503/com.flowrobe.app D/InputMethodManager: getNavigationBarColor() -855310
2021-01-29 14:17:16.379 2503-2503/com.flowrobe.app D/InputMethodManager: prepareNavigationBarInfo() DecorView@30c61b[MainActivity]
2021-01-29 14:17:16.380 2503-2503/com.flowrobe.app D/InputMethodManager: getNavigationBarColor() -855310
2021-01-29 14:17:16.380 2503-2503/com.flowrobe.app V/InputMethodManager: Starting input: tba=com.flowrobe.app ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
2021-01-29 14:17:16.380 2503-2503/com.flowrobe.app D/InputMethodManager: startInputInner - Id : 0
2021-01-29 14:17:16.381 2503-2503/com.flowrobe.app I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2021-01-29 14:17:16.387 2503-2503/com.flowrobe.app V/Capacitor/Network: Notifying listeners for event networkStatusChange
2021-01-29 14:17:16.405 2503-2569/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/home
2021-01-29 14:17:16.519 2503-2569/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/polyfills-es2015.js
2021-01-29 14:17:16.521 2503-2576/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/styles-es2015.js
2021-01-29 14:17:16.521 2503-2569/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/vendor-es2015.js
2021-01-29 14:17:16.521 2503-2578/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/runtime-es2015.js
2021-01-29 14:17:16.524 2503-2570/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/main-es2015.js
2021-01-29 14:17:16.552 2503-2503/com.flowrobe.app I/Capacitor/Console: File: capacitor-runtime.js - Line 2398 - Msg: onscript loading complete
2021-01-29 14:17:17.205 2503-2503/com.flowrobe.app W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 168790 - Msg:
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.

For the module builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):

CommonJS Modules:
const firebase = require('firebase/app');
require('firebase/<PACKAGE>');

ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

Typescript:
import * as firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

2021-01-29 14:17:17.325 2503-2503/com.flowrobe.app W/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 39262 - Msg: DEPRECATED: DI is instantiating a token "CustomHammerConfig" that inherits its @Injectable decorator but does not provide one itself.
This will become an error in v10. Please add @Injectable() to the "CustomHammerConfig" class.
2021-01-29 14:17:17.377 2503-2576/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/firebase-auth-es2015.js
2021-01-29 14:17:17.379 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 119405112, pluginId: Storage, methodName: get
2021-01-29 14:17:17.379 2503-2715/com.flowrobe.app V/Capacitor: callback: 119405112, pluginId: Storage, methodName: get, methodData: {"key":"user"}
2021-01-29 14:17:17.466 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 119405113, pluginId: Network, methodName: getStatus
2021-01-29 14:17:17.466 2503-2715/com.flowrobe.app V/Capacitor: callback: 119405113, pluginId: Network, methodName: getStatus, methodData: {}
2021-01-29 14:17:17.488 2503-2503/com.flowrobe.app I/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 75107 - Msg: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
2021-01-29 14:17:17.504 2503-2570/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/common-es2015.js
2021-01-29 14:17:17.518 2503-2575/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/2-es2015.js
2021-01-29 14:17:17.522 2503-2849/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/6-es2015.js
2021-01-29 14:17:17.534 2503-2575/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/17-es2015.js
2021-01-29 14:17:17.548 2503-2576/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/default~pages-home-home-module~product-product-module~trades-trades-module~wardrobe-wardrobe-module~~fddc403d-es2015.js
2021-01-29 14:17:17.548 2503-2578/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/19-es2015.js
2021-01-29 14:17:17.552 2503-2849/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/pages-home-home-module-es2015.js
2021-01-29 14:17:17.558 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 119405114, pluginId: Network, methodName: addListener
2021-01-29 14:17:17.559 2503-2715/com.flowrobe.app V/Capacitor: callback: 119405114, pluginId: Network, methodName: addListener, methodData: {"eventName":"networkStatusChange"}
2021-01-29 14:17:17.573 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Cordova plugin): callbackId: AppRate577142635, service: AppRate, action: getAppTitle, actionArgs: []
2021-01-29 14:17:17.592 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Cordova plugin): callbackId: AppRate577142636, service: AppRate, action: isNativePromptAvailable, actionArgs: []
2021-01-29 14:17:17.595 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Cordova plugin): callbackId: NativeStorage577142637, service: NativeStorage, action: getItem, actionArgs: ["counter"]
2021-01-29 14:17:17.598 2503-2503/com.flowrobe.app I/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 156716 - Msg: Ionic Native: deviceready event fired after 431 ms
2021-01-29 14:17:17.601 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 119405115, pluginId: App, methodName: addListener
2021-01-29 14:17:17.601 2503-2715/com.flowrobe.app V/Capacitor: callback: 119405115, pluginId: App, methodName: addListener, methodData: {"eventName":"appUrlOpen"}
2021-01-29 14:17:17.609 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 119405116, pluginId: SplashScreen, methodName: hide
2021-01-29 14:17:17.610 2503-2715/com.flowrobe.app V/Capacitor: callback: 119405116, pluginId: SplashScreen, methodName: hide, methodData: {}
2021-01-29 14:17:17.622 2503-2715/com.flowrobe.app V/Capacitor/Plugin: To native (Cordova plugin): callbackId: AppRate577142638, service: AppRate, action: getAppVersion, actionArgs: []
2021-01-29 14:17:17.678 2503-2849/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/svg/close-sharp.svg
2021-01-29 14:17:17.686 2503-2575/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/swipe-back-2154c9a7-js-es2015.js
2021-01-29 14:17:17.713 2503-2575/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/5-es2015.js
2021-01-29 14:17:17.718 2503-2578/com.flowrobe.app D/Capacitor: Handling local request: http://localhost/28-es2015.js`

@joaolnpr
Copy link
Author

Related #2584 ?

@joaolnpr
Copy link
Author

Related #2931 ?

@jcesarmobile
Copy link
Member

Do you have Don't keep activities setting on in the Android developer options?
That will cause the behavior described here.
If it's not enabled, there is nothing we can really do, the OS is killing your app when it launches an Intent to another app (such as Camera plugin does), probably because of low memory.

@jcesarmobile jcesarmobile added needs reply needs reply from the user and removed platform: ios labels Jan 29, 2021
@joaolnpr
Copy link
Author

Hey @jcesarmobile , thanks for the reply.

I dont have that option enabled, I also disabled developer tools and tried again with the same issue.
The phone I am using is Samsung A10 with Android 10, never had problems with mobile apps as off with this app, and we are talking about a 20 mega app. And the feature share shouldn't consume that much memory right?

From what you are saying I can try in other Android phones and everything should be working fine?

@Ionitron Ionitron removed the needs reply needs reply from the user label Jan 30, 2021
@joaolnpr
Copy link
Author

The phone I am using and having this issue is Samsung A10 - with 2G Memory and 32G storage, I dont think so this would be memory issues.

@jcesarmobile I am having some cordova plugins, could this impact on this?

@joaolnpr
Copy link
Author

joaolnpr commented Feb 1, 2021

Hey @jcesarmobile does the launchMode=singleTask on AndroidManifest.xml would impact on this? Shoul dbe multiTask?

image

@joaolnpr
Copy link
Author

joaolnpr commented Feb 4, 2021

I found out the issue, on Network state change which is triggered on android app when calling capacitor plugin on resuming the app we had a reload of location....
Thanks for the help

@joaolnpr joaolnpr closed this as completed Feb 4, 2021
@Aarbel
Copy link

Aarbel commented Jul 28, 2021

cf #2712

@Aarbel
Copy link

Aarbel commented Jul 28, 2021

@Aarbel
Copy link

Aarbel commented Jul 28, 2021

@joaolnpr how did you fixed it in details ? Looks like it's a comon crash with android apps since one year

@smunoz-temperies
Copy link

smunoz-temperies commented Aug 31, 2021

I found out the issue, on Network state change which is triggered on android app when calling capacitor plugin on resuming the app we had a reload of location....
Thanks for the help

hi @joaolnpr how did you fix that ?
did you do some configuration changes in AndroidManifest.xml?

thanks in advance!

@shipra5676
Copy link

I am also facing crashing issue on taking picture, I am using realme device , android version -12. I tried capacitor 3.5.1 and 4 as well but same issue. please resolve it.

@Aarbel
Copy link

Aarbel commented Sep 5, 2022

A workaround for better camera stability on android is to use an html "capture" <input> and compress the image in the front-end: we did this https://gist.github.com/Aarbel/c657991441dce71ef6a33dc3e781d117.
Otherwise it often crashes on some devices on which the camera is too big for the CPU / RAM of the device

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

6 participants