Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes on launch on Android 13 #110

Open
nathanmp opened this issue Jan 5, 2024 · 7 comments
Open

App crashes on launch on Android 13 #110

nathanmp opened this issue Jan 5, 2024 · 7 comments

Comments

@nathanmp
Copy link

nathanmp commented Jan 5, 2024

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:

  • The Play Store release (0.12.1b5) vs. the most recent Github release.
  • Granting unrestricted battery before the first launch vs. not doing so.
  • Granting permissions to track tabs vs. not doing so (only for the Play Store release - seems like the Github release can't use accessibility on my version of Android.)

Hardware info if relevant:

  • Moto G Stylus 5G (2023), running Android 13, kernel 5.10.136, Verizon.
    At least for the Play Store release, the same issue is not happening on my old phone (Moto One 5G UW Ace, Android 12, kernel 4.19.157), nor does it happen on my tablet (Samsung Galaxy A7 Lite, Android 13, kernel 4.19.191). IIRC, the issue did happen when my old phone was using Verizon.
    If you want me to get more info, let me know! Thanks!

gif-20240105-142342

@nathanmp
Copy link
Author

nathanmp commented Jan 15, 2024

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.

@Terrance
Copy link

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.

@derkrasseleo
Copy link

Possibly related issue: ActivityWatch/activitywatch#1003

@nathanmp
Copy link
Author

nathanmp commented Jul 30, 2024

I thought I posted an update here a while ago but I guess I didn't press Send. Anyway, the workaround stopped working for me shortly after I posted it. I tried to debug it and I got the same results as in the issue @derkrasseleo posted.

I also tried to figure out where the problem is in the APK, and I'm almost certain it's in the Rust kernel. I tried disassembling that to see what method causes the crash, and if I remember correctly there were actually multiple methods. I'm pretty sure I saved my results somewhere, but I'm not at my work PC now. I'll check it and update once I'm home.

EDIT: Alas I did not save my work, but I'll try to figure out my results again.

@florianklumb
Copy link

I had the same issue as you @nathanmp but today randomly tried switching off "Pause app activity if unused" and suddenly Activity Watch runs as expected. I'm on a Google Pixel 7a with Android 14.

@derkrasseleo
Copy link

derkrasseleo commented Sep 1, 2024

I had the same issue as you @nathanmp but today randomly tried switching off "Pause app activity if unused" and suddenly Activity Watch runs as expected. I'm on a Google Pixel 7a with Android 14.

Can't confirm that fixes it for me on Pixel 4a with Graphene OS (Android 13)

Edit: I cleared storage and force restarted the app, not it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@florianklumb @Terrance @nathanmp @derkrasseleo and others