Repository navigation
fix(android): log Rust panics to logcat via android_log - #654
Merged
ErikBjare merged 1 commit intoAug 25, 2026
Merged
Conversation
The default panic hook writes to stderr, which Android discards, so a panic in libaw_sync.so surfaces only as SIGABRT with no message (ActivityWatch/aw-android#220). Install a panic hook in aw-sync (JNI_OnLoad plus each JNI entry) that writes the panic payload, location, and backtrace through __android_log_write, and initialize android_logger so existing log macros also reach logcat. Also call log_panics::init() from aw-server's Android initialize() so panics in libaw_server.so are diagnosable the same way.
Greptile SummaryThis PR makes Android-native Rust panics visible in logcat without changing panic termination behavior.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified. The logging setup is target-scoped and idempotent, JNI calls retain a fallback initialization path, and the dependency update does not introduce a newly resolved vulnerable package. Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Android app
participant VM as JVM loader
participant Sync as libaw_sync.so
participant Server as libaw_server.so
participant Logcat
App->>VM: Load aw_sync
VM->>Sync: JNI_OnLoad
Sync->>Sync: Initialize android_logger and panic hook
App->>Server: initialize()
Server->>Server: Initialize logger and log_panics
App->>Sync: Invoke sync JNI operation
Sync->>Sync: Ensure logging initialized once
alt Rust panic
Sync->>Logcat: Payload, location, and backtrace
end
Reviews (1): Last reviewed commit: "fix(android): log Rust panics to logcat ..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #654 +/- ##
==========================================
+ Coverage 70.81% 77.11% +6.29%
==========================================
Files 51 65 +14
Lines 2916 5370 +2454
==========================================
+ Hits 2065 4141 +2076
- Misses 851 1229 +378 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First follow-up from ActivityWatch/aw-android#220.
Rust's default panic hook writes to stderr, which Android discards, so a panic in
libaw_sync.socurrently surfaces only asSIGABRTwith no message in logcat.This installs:
android_loggerplus a panic hook that writes the payload, location, and backtrace via__android_log_write(tagaw-sync), installed fromJNI_OnLoadand each JNI entrylog_panics::init()during Androidinitialize()so panics inlibaw_server.soare diagnosable the same way (tagaw-server-rust)This does not fix the abort itself; it makes the panic diagnosable.
Verified:
cargo test -p aw-sync(5/5) and./compile-android.sh arm64(JNI_OnLoadexported fromlibaw_sync.so).