How can I stop Chrome background updates killing my app?

4.2k views Asked by At

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?

1

There are 1 answers

0
ppm On

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.