ActivityWatch / aw-android

ActivityWatch for Android, using aw-server-rust as backend.
Mozilla Public License 2.0
155 stars 26 forks source link

App crashes on launch on Android 13 #110

Open nathanmp opened 5 months ago

nathanmp commented 5 months ago

I'm able to install the app and grant permissions just fine. However, when I launch the app, the app closes just after starting. A dialog saying "ActivityWatch keeps stopping" appears, but that disappears faster than I can click on it. I managed to screen record a gif of it, see below.

I've tested using all 6 combinations of the below, and the same thing occurs:

Hardware info if relevant:

gif-20240105-142342

nathanmp commented 5 months ago

I looked at the logcat and got some potentially-useful info. The cause of the crash is "Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6435 (AsyncTask #1), pid 6327 (tywatch.android)". Here's the backtrace from the crash (with some fields removed for ease of reading).

#00  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168)1
#01  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#02  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#03  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#04  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#05  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#06  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#07  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#08  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#09  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk
#10  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/split_config.arm64_v8a.apk (Java_net_activitywatch_android_RustInterface_heartbeat+44)
#11  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/oat/arm64/base.odex (art_jni_trampoline+144)
#12  /apex/com.android.art/lib64/libart.so (nterp_helper+5648)
#13  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/oat/arm64/base.vdex (net.activitywatch.android.RustInterface.heartbeatHelper+48)
#14  /apex/com.android.art/lib64/libart.so (nterp_helper+5720)
#15  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/oat/arm64/base.vdex (net.activitywatch.android.watcher.UsageStatsWatcher$SendHeartbeatsTask.doInBackground+558)
#16  /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
#17  /data/app/~~VYaHQqGzFxwNupl6kA4Eng==/net.activitywatch.android-RAHubCU-xrTKceu-ho7LIQ==/oat/arm64/base.vdex (net.activitywatch.android.watcher.UsageStatsWatcher$SendHeartbeatsTask.doInBackground+4)
#18  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.AsyncTask$3.call+168)
#19  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.FutureTask.run+180)
#20  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (android.os.AsyncTask$SerialExecutor$1.run+72)
#21  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+796)
#22  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+64)
#23  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.lang.Thread.run+72)
#24  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
#25  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144)
#26  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600)
#27  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)1
#28  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)1

Also, there's a call to aw-server-rust when the app starts, and judging by logcat that call appears to succeed. Maybe that can help rule out a potential error? The server call:

01-14 18:41:15.559  aw-server-rust: rocket::server: GET / text/html
01-14 18:41:15.559  aw-server-rust: rocket::server: Matched: root_index GET
01-14 18:41:15.569  aw-server-rust: rocket::server: Outcome: Success
01-14 18:41:15.570  aw-server-rust: rocket::server: Response succeeded.

EDIT: I found a bizarre workaround: enable "Show background ANRs" in developer settings. ActivityWatch works perfectly fine if this is enabled, and there's no "app not responding" pop-up either. And it even has data from the time that I couldn't open AW's UI, so the recording functionality must've been working OK.

I have a guess for why the workaround works at least, even if I haven't been able to figure out the cause for the crash. From Android's ProcessErrorStateRecord.java, processes are silently killed if they're not "interesting for background traces" and the "Show Background ANRs" option is not set. An "interesting" process is one that's displaying an activity, is the System UI, or has an overlay.

One guess - could there be a non-UI process that gets launched but is then killed, which causes ActivityWatch to immediately close? That would explain why "Show Background ANRs" works - it'd stop the process from getting silently killed. The crash happens in AsyncTask (presumably a non-UI process). That doesn't explain why there's no ANR popup for the background task. I can try taking another look in the logcat to see if I can figure that out. Anyway, maybe this can help narrow down the problem. And at least there's a workaround for now.

Hris2023 commented 5 months ago

I have the same issue, but unfortunately your workaround isnt working for me. Im on latest GrapheneOS, Android 14, Pixel 7 Pro.

Terrance commented 1 month ago

I've also just started encountering this, after finding no data has been recorded for the last week or so, and toggling the Usage access permission in an attempt to get it going again.

Here's a log of the startup leading to the crash: 📎 20_05-23-32-16_835.log

Enabling Show background ANRs also doesn't help for me.