ActivityWatch / ActivityWatch/aw-android

Export button in bucket view silently fails: WebView fetches the export but never saves the file

Aberta
#228 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Kotlin
Estrelas
265
Forks
57
Merge médio
2d 21h
PRs com merge (30d)
19

Descrição

# Export button in bucket view silently fails: WebView fetches the export but never saves the file

## Summary

Tapping **Export** on a bucket in the Android app does nothing (appears to hang / time out). No file is ever produced, no error is shown, and the app does not crash.

Log capture shows the embedded `aw-server-rust` **successfully generates the export in ~39 ms**, but the response is then dropped by the app's WebView so no Android download or Storage-Access-Framework machinery is ever invoked, nothing is written to storage. This looks like the in-app WebView has no `DownloadListener` wired up to handle the web UI's download.

This reproduces on a **fresh install**
## Environment

| | |
|---|---|
| Device | Samsung Galaxy A52s 5G (SM-A528B) |
| Android | 14 (API 34), One UI 6.1 |
| Build | UP1A.231005.007.A528BXXSBGYI3 |
| Security patch | 2025-09-01 |
| ActivityWatch app | **0.12.1b5** (versionCode 33), minSdk 24, targetSdk 34 |
| System WebView | Google Chrome/Android System WebView **150.0.7871.181** |

## Steps to reproduce

1. Open the app, go to a bucket in the buckets view (e.g. `aw-watcher-android-test`).
2. Tap **Export** for that individual bucket.
3. Observe: nothing happens — no file, no picker, no error, no toast.

## Expected behavior

The bucket export JSON is saved to the device (e.g. via a Storage Access Framework "Save to…" picker or the Downloads folder), matching how the desktop web UI download behaves.

## Actual behavior

The web UI issues the export request, the local server answers it successfully, and then the file is silently discarded. From the user's perspective it hangs / times out.

## Evidence (logcat)

The app renders the bundled web UI inside an Android WebView (a Chromium sandboxed process is spawned for it):

```
ActivityManager: Start proc 3758:com.google.android.webview:sandboxed_process0:...:0
for {net.activitywatch.android/org.chromium.content.app.SandboxedProcessService0:0}
```

At the moment Export is tapped, the embedded server handles the request successfully in ~39 ms, then the client (WebView) immediately closes the connection:

```
I aw-server-rust: rocket::server: GET /api/0/buckets/aw-watcher-android-test/export:
I aw-server-rust: rocket::server: Matched: (bucket_export) GET /api/0/buckets//export
I aw-server-rust: rocket::server: Outcome: Success (19:08:28.527 -> 19:08:28.566, ~39 ms)
W aw-server-rust: rocket::server: Remote left: channel closed.
```

Across the entire attempt, **none** of Android's file-saving mechanisms fire (grep over the full capture, 0 hits each):

```
DownloadManager: 0 DownloadListener: 0 ACTION_CREATE_DOCUMENT: 0
documentsui: 0 openOutputStream: 0
```

There is also **no** `FATAL`/`AndroidRuntime` crash, **no** ANR, and **no** `OutOfMemory` in the log. The response is produced and then goes nowhere.

## Likely root cause

The Export action in the bundled `aw-webui` performs a browser-style download (a `blob:` / `` save that works in a normal browser). Android's `WebView` does not handle such downloads unless the host app registers a `WebView.setDownloadListener(...)` (and, for `blob:` URLs, bridges them to a native save). Without that, the fetched bytes are dropped.

## Workaround

Managed to pull the data directly from the phone's local server over ADB, bypassing the WebView:

```bash
# On the phone: enable Wireless debugging (Developer options)
adb pair <6-digit-code>
adb connect
adb forward tcp:5666 tcp:5600
# Per-bucket (reliable):
curl http://localhost:5666/api/0/buckets//export -o .json
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.