Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop Chrome background updates killing my app?

Updated Post

The Problem

We have various logs indicating that a background update to Chrome is killing our app, which uses webviews. The logs all follow a similar pattern;

3034  3049 I ActivityManager: Force stopping com.android.chrome appid=10115 user=-1: installPackageLI
3034  3049 I ActivityManager: Killing 963:com.google.android.googlequicksearchbox:search/u0a80 (adj 500): stop com.android.chrome,installPackageLI
3034  3049 W ActivityManager: Scheduling restart of crashed service com.google.android.googlequicksearchbox/com.google.android.apps.gsa.shared.util.keepalive.StandaloneKeepAlive$KeepAliveService in 1000ms
3034  3049 W ActivityManager: Scheduling restart of crashed service com.google.android.googlequicksearchbox/com.google.android.apps.gsa.nowoverlayservice.DrawerOverlayService in 10999ms
3034  3049 I ActivityManager: Killing 1709:com.my.app/u0a292 (adj 0): stop com.android.chrome,installPackageLI

I found a similar issue from another developer here; https://seap.samsung.com/forum-topic/activitymanager-kills-our-pro-kiosk-mode-app-chrome-update. It talks about an API provided in Knox but I have been unable to find out if there is anymore information. Ideally I would like a native solution, or perhaps some sort of AndroidManifest entry to mitagate this.

I understand that when one app has a dependency on another, then it might need to close and restart in order to maintain parity. However our app is a full screen active app and just gets booted in this situation, it seems strange there isn't a way to get around this.

Questions

How can I wait for our app to finish (or lose focus) before the update can go through? Is there something i'm missing from my apps settings that would avoid issues such as this? Perhaps it's the usage of the webview that is the problem?

App Info

Our dependency on the webview this is likely that of a 3rd part ad provider. The app is made in Unity. I can change the AndroidManifest itself or update our native versions of the Player and main Activity. I can also write native code if needs be. I suspect this would be a problem for native apps too.


Original Post - Title: Identify dependency on Chrome (App killed on Chrome update.

I noticed that each time the Chrome app gets an update, my application is killed.

Force stopping com.android.chrome appid=10145 user=-1: installPackageLI
Killing 14427:my.application.com/u0a263 (adj 200): stop com.android.chrome,installPackageLI

A side note: Chrome web view (or web view in general) is not used at all in my application.

Is there a chance that some of the dependencies in my app use web view and that is why my application is being killed? If yes, how to detect which one? If not, is there anything to prevent this behavior?

like image 608
Daniel Kareski Avatar asked Sep 28 '18 10:09

Daniel Kareski


People also ask

How do you stop apps from being killed in the background?

First, swipe down once from the top of the screen and tap the gear icon. Scroll down and find “Apps.” Next, tap the three-dot menu icon and select “Special Access.” If you don't see it, there will be a section on that screen titled “Special App Access.” Now select “Optimize Battery Usage.”

How do I stop Chrome from running in the background on my phone?

Stop Chrome Running from Background in Mobile Devices On Android – go to “Settings > Apps” section and tap on “Force Stop” to close the app. You have to do this each time when you want to stop the app. On iPhone – go to “Settings > General” section and tap on “Background App Refresh”.


1 Answers

How can I wait for our app to finish (or lose focus) before the update can go through?

Drumroll... You can't. This is a long-standing problem for any app that uses WebView (or uses some framework or library that uses WebView). See this bug. There's no way for your app to prevent Chrome/WebView updates; that would be a security problem. Updates are scheduled by the Play Store, which has no understanding of which apps depend on WebView.

Is there a chance that some of the dependencies in my app use web view and that is why my application is being killed? If yes, how to detect which one?

Try adb logcat | grep WebViewFactory; that string will be logged whenever an app starts using WebView.

You could also follow these instructions to inspect WebView with Chrome's dev tools. (You can skip setWebContentsDebuggingEnabled(true) if you have a userdebug build of Android.) This will show you all the WebViews in your app, and the contents of each one.

And, if you go to the trouble building userdebug Android, you could just add a stack trace in the WebView constructor.

it seems strange there isn't a way to get around this.

It's not a great option, but you could try adding another process to your app, and only using WebView from that process, and handling crashes without killing your main process.

like image 137
ppm Avatar answered Oct 14 '22 06:10

ppm