Data-integrity review: browser visit lost on watcher destroy, export overwrite without truncate, notify drops startOfDay minutes (+2)

Aperta
#409 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
android, kotlin
Ambito
mobile, mobile-dev

Direzione di ricerca

Start with watcher/WebWatcher.kt around onDestroy (410-417): flush the open session via sessionTracker.handleUrl(null, null) before writer.shutdown(), using a Robolectric ServiceController and recording writer to prove it. Then inspect fragments/WebUIFragment.kt writeExport (1070) for the "wt" truncation fix and sendText (167-168) for surrogate-safe chunking. workers/NotifyWorker.kt parseStartOfDayHour (134) needs a LocalTime; the extractor findings at WebWatcher.kt 98/136/140 need a device repro and a privacy decision before changing recording behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Remaining findings from a data-integrity review of aw-android master (aa9cea0). I checked each one against the code. They are not fixed in #407 (DST day window) or #408 (sub-second browser durations), and none of them duplicates an open issue or PR.

1. The browser visit in progress is lost when the accessibility service is destroyed. Two reviewers found this independently. A visit is written only when the URL, browser or window changes. WebWatcher.onDestroy (watcher/WebWatcher.kt:410-417) shuts down writer without first calling sessionTracker.handleUrl(null, null). If the user turns the service off, or the system unbinds it while a page is open, that whole visit is dropped. There is no upper bound on how much is lost: reading one page for 40 minutes loses 40 minutes. Fix: in onDestroy, flush the open session before writer.shutdown(). A test needs a Robolectric ServiceController with a recording writer, because the defect is a missing call that a pure tracker test can't see. A process kill (battery optimisation, app update) loses the visit too. Fixing that would need periodic chunked writes, as MediaPlaybackSegments already does.

2. Saving an export over an existing file can leave the old file's tail behind. WebUIFragment.writeExport (fragments/WebUIFragment.kt:1070) opens the URI with openOutputStream(uri), which means mode "w". Some providers (MediaProvider/FUSE-backed Downloads) don't truncate on "w", so a shorter re-export to the same file ends up with stale bytes after the closing ]. The SAF mirror already uses "wt" for this reason (SyncInterface.kt:605). Fix: openOutputStream(uri, "wt").

3. NotifyWorker drops the minutes of startOfDay. parseStartOfDayHour (workers/NotifyWorker.kt:134) keeps only the hour, so "04:30" becomes 4, while the widget and webui use 04:30. Between 04:00 and 04:30, alerts already query the new day and fire against totals that don't match what the app shows. The fired-key date also changes 30 minutes early. Fix: carry a LocalTime through logicalDayDate, with the logicalDate/logicalDayWindow helpers from #407.

4. Text typed into the address bar may be recorded as page URLs in Chrome, Edge, Samsung Internet and Opera (needs a device repro; privacy). The extractors at watcher/WebWatcher.kt:98, :136 and :140 read url_bar from the event source without ignoreFocused. Brave and the detected Chromium forks pass ignoreFocused = true "to avoid recording typed text" (#307). If typing fires content-changed events whose source includes the focused bar, each partial query becomes a short visit with url="how t". The device test only covers Brave. This changes what gets recorded, so Erik should decide on it.

5. A blob export can split an emoji across a 256K bridge chunk (medium confidence). sendText (WebUIFragment.kt:167-168) slices by UTF-16 code units. A surrogate pair that straddles a chunk boundary is split, and the halves likely reach Java as U+FFFD. Fix: don't end a chunk on a high surrogate.

Checked and found no defect: the usage-stats import cursors, replay and dedupe (read back from the DB, so a kill just replays and merges), timestamp precision, MediaWatcher flushes, the SAF mirror cleanup, and the JSON parse/error paths.

Lingua principale
Kotlin
Stelle
289
Fork
67
Merge medio
8g 52m
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ActivityWatch/aw-android

Tutte le issue di ActivityWatch/aw-android

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.