How can I stop Chrome background updates killing my app?
Asked Answered
M

1

15

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?

Messer answered 28/9, 2018 at 10:38 Comment(7)
This is definitely a thing; seap.samsung.com/forum-topic/…. I would appreciate any details on this.Actionable
So...sorry to the original poster but I was convinced that I had asked this question previously and so edited it with more information and offered a bounty. I maintained the original question and I believe that they have the same resolution.Actionable
You can force stop the application or root the android device.Cartomancy
I'm not sure you have understood the question @Amirhf. This is happening at runtime while my app is executing in the foreground. Chrome update just kills the app without warning.Actionable
In my case, I created a Sticky Foreground Service, and my app gets restarted even when Chrome updates my phone and crashes.Specular
@Actionable did you have opportunity to solve this issue?Legacy
@Specular I have also defined a foreground service and it is sticky, but after webview update, my app doesn't come to foreground. In any other case, I check if it is in background and bring it back to foreground successfully, any idea?Legacy
K
2

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.

Kaylyn answered 7/4, 2020 at 21:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.