Repository navigation
perf(app): decode and combine Offline Sync recording audio on background isolate (#22126) - #23497
Conversation
|
The production change here is correct and nicely scoped - decode/combine now runs off the UI thread with output bytes and error behavior preserved; two small follow-up asks below. app/lib/utils/audio_player_utils.dart
app/test/unit/audio_player_utils_test.dart - the new assertions pin the actual invariant ( app/changelog/unreleased/20261024-offline-sync-share-background-isolate.json - accurate user-facing description; ios+android platform list matches the shared Flutter code path. Performance: per call, one isolate spawn plus (Opus only) one dynamic-library load - milliseconds against the multi-second decode it replaces; full-PCM-in-memory per file is unchanged. UX: sharing a long recording no longer freezes the UI. Security: none - no new permissions, background modes, or data flows, and the share sheet still opens on the main isolate. Blast radius: confined to WAL playback/share decode; a failed decode still returns null exactly as before. USER IMPACT: sharing a long Offline Sync recording no longer freezes the app while the audio is decoded and combined; the exported WAV is unchanged. Still wanted as a reviewer:
Leaving formal sign-off to a human maintainer. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for the review @Git-on-my-level! Added follow-up coverage in
|
|
Thanks @Git-on-my-level! Addressed both follow-up points in
|
6dfbc83 to
d8a17d9
Compare
|
Verdict: The production change is correct and nicely scoped — moving Offline Sync audio decode/combine off the UI isolate is the right fix for #22126, and the implementation preserves the existing cache and output semantics.
Performance: multi-hour recording decode/combine no longer blocks the UI isolate; per-call isolate spawn adds ~ms. Security: no new data flows or permissions — audio stays on device. Blast radius: local recording playback/share paths only. USER IMPACT: Sharing or first-playing an Offline Sync recording no longer freezes the app while audio is decoded; the exported audio itself is unchanged. Still would like as a reviewer: a real-device sanity check on a multi-hour recording (the in-memory combine's memory ceiling is unchanged, just moved off-thread) — nothing else blocking. Leaving for human maintainer review before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
What changed and why
Fixes #22126. Offline Sync sharing decodes and combines long recordings on a background isolate while file selection, platform-directory lookup and share-sheet invocation stay on the UI isolate. This finishes the existing contributor implementation rather than opening a duplicate PR; @ocakciomursel-pixel's commits are preserved.
The shared worker handles disk and memory-backed WALs, initializes native Opus inside each worker, streams frames/PCM with bounded buffering, and preserves oldest-first mixed Opus/PCM output. Existing missing/unreadable-part behavior remains. Zero-length payloads are skipped before Opus can synthesize packet-loss concealment, and decoder views retain only their selected sample range. Each job owns its scratch directory; inputs and playback caches are retained. WAV publication uses a same-directory staging file and atomic rename, so a failed combine cannot overwrite an earlier complete export. Concurrent shares use unique output directories.
Why isn't this a shared primitive instead? It is: single-file playback/share and whole-recording export use the same WAL decoder and PCM WAV header. WavCombiner owns atomic final publication for its existing callers too. No new generic guard or policy was added.
Verification
bash app/test.sh test/unit/audio_player_utils_test.dart test/utils/wav_combiner_test.dart: 36 focused tests and 138 protected spine tests passed. Cases include worker failure/no sheet, retries, cleanup, cache/source preservation, concurrent shares, streaming frame boundaries and corrupt/truncated parts.OMI_APP_PROFILE=local_dev flutter test integration_test/offline_recording_export_native_test.dart -d <simulator> --flavor dev --dart-define=OMI_APP_PROFILE=local_dev.make preflight: all 26 selected checks passed. Five new failure/cleanup/empty-payload tests were demonstrated red on the original implementation.715130b4649befa8127407b7f417f71948c234e0: Flutter analyzer/tests, generated files, formatting, hygiene, PR metadata and Mobile Release Eligibility passed. The full Flutter suite passed 7,688 tests, with four skipped. Native/platform jobs excluded by the diff scope are not claimed as CI runtime coverage.No backend, firmware, account state or recording custody metadata changes. Mobile app release follows merge. Architecture and implementation checklist:
app/lib/utils/audio/README.md. Mid-range physical Android hardware and a customer's recording have not been used; simulator acceptance is reported separately from physical hardware evidence.Product invariants affected
INV-PERF-1 — audio frame conversion and recording combination stay off the UI isolate.
Failure class (fixes)
Failure-Class: none
This scoped audio-export CPU/temporary-file defect has no matching registered failure class; it does not change capture/upload custody or provider selection.
UI evidence
UI-Evidence: none -- export execution and temporary-file handling only; no layout or visual changes.
Main was rechecked at
ca1d6079d1after CI: this export fix is still absent. Main advanced only in unrelated backend listen/feature-flag files; mobile sources exercised by the evidence are unchanged. #22126 can close as technically completed once this verified implementation lands on main; mobile distribution follows separately.