status-im / status-mobile

a free (libre) open source, mobile OS for Ethereum
https://status.app
Mozilla Public License 2.0
3.91k stars 984 forks source link

App is killed/crashed while in the background with enabled push notifications #20697

Open qoqobolo opened 4 months ago

qoqobolo commented 4 months ago

Bug Report

Problem

I tried to reproduce the issue with the proposed preconditions: mobile network, low battery, Android device, enabled push notifications, and restored Status user with the Status community.

I was able to reproduce the case when the app was killed/crashed while in the background although push notifications were enabled. The steps I tried were:

  1. Have the device on mobile network
  2. Recover the Status user
  3. Enable push notifications
  4. Add User2 to contacts
  5. Kill the app
  6. Lock the device screnn
  7. Start sending messages from Device1 to Status User
  8. Wait for 3-10 mins
  9. Unlock the device with Status User
  10. Open the app

Expected behavior: the app is opened without password/biometrics

Actual behavior: you need to enter the password/use biometrics which means that the app was killed. The notification background service is stopped until login.

However, the app also behaved the same way a couple of times without receiving messages - I just left it in the background for a while and locked the screen, but when I opened it I was asked for a password to log into the app.

Also, the issue did not always reproduce - in about half of the attempts.

Logs

bckgrncrash12.log

Additional Information

cammellos commented 4 months ago

07-09 16:13:52.365 2540 5134 W AwareLog: KillShrinker: AbnormProcInfo kill pid=26187 07-09 16:13:52.365 1031 1047 I AwareLog: IAWARE_PROC_KILL 07-09 16:13:52.365 1031 1047 I AwareLog: Sending signal. PID: 26187 SIG: 9 07-09 16:13:52.369 2540 5134 W AwareLog: KillShrinker: AbnormProcInfo kill pid=26218

The app is getting killed, Sig 9

Horupa-Olena commented 3 months ago

@cammellos @churik Hi! I tried to reproduce this bug but without success. I tested it on Android 13 with medium battery charge, during the transition to low battery, and with low battery charge.

seanstrom commented 1 month ago

I've also tried to reproduce this issue and was unable to get the same error. I tested on a Pixel 7a running Android 14, and I even enabled battery saver mode with the "extreme battery saver" settings that will pause apps, and I was still able to receive notifications.

seanstrom commented 1 month ago

Perhaps there are some other ways that will cause Android to stop the background task for notifications? I'm not sure how that's possible, but I can try looking into other ways for that to happen if the current reproduction steps don't cause this glitch atm.

Parveshdhull commented 3 weeks ago

might be related to https://github.com/status-im/status-mobile/issues/20985 https://github.com/status-im/status-mobile/issues/20930#issuecomment-2440078108

07-09 16:13:52.664  1624  2727 W ActivityManager: Scheduling restart of crashed service im.status.ethereum/.pushnotifications.ForegroundService in 1000ms
...
07-09 16:13:53.702  1624  1959 I ActivityManager: Start proc 28347:im.status.ethereum/u0a1253 for service {im.status.ethereum/im.status.ethereum.pushnotifications.ForegroundService}
07-09 16:13:53.710 28347 28347 E libc    : Access denied finding property "persist.device_config.runtime_native.use_app_image_startup_cache"
07-09 16:13:53.711 28347 28347 E status.ethereu: LoadAppImageStartupCache enabled : 1
07-09 16:13:53.704 28347 28347 W status.ethereu: type=1400 audit(0.0:72405): avc: denied { read } for pid=28347 name="u:object_r:device_config_runtime_native_prop:s0" dev="tmpfs" ino=1
07-09 16:13:53.712 28347 28347 I status.ethereu: Reinit property: dalvik.vm.checkjni= false
07-09 16:13:53.712 28347 28347 I status.ethereu: ReInitProperties: persist.vm.debug.dumpapi= false
07-09 16:13:53.715 28347 28347 E status.ethereu: Not starting debugger since process cannot load the jdwp agent.
Parveshdhull commented 2 weeks ago

To ensure the app doesn’t get killed while in the background, we need to disable battery optimization for the app. I'm not sure, but we will likely also need to show a popup explaining why we need this permission and might also have to justify it when publishing the app.

Interestingly, we can manually simulate the doze standby mode for testing this bug, as detailed here: Testing Doze.

Parveshdhull commented 2 weeks ago

I'm not sure, but we will likely also need to show a popup explaining why we need this permission and might also have to justify it when publishing the app.

(https://stackoverflow.com/a/33114136) Image

Parveshdhull commented 2 weeks ago

https://commonsware.com/blog/2015/11/11/google-anti-trust-issues.html https://stackoverflow.com/a/50840603