Commit graph

4 commits

Author SHA1 Message Date
Huang Xin
477381c8ac
fix(tts): play local AAC narration natively on Linux (#7240)
* fix(tts): play local AAC narration natively on Linux

Decode AAC-LC/ALAC MP4 narration with Symphonia 0.6.1 and send PCM to
CPAL, with SoundTouch preserving pitch when playback speed changes.
Read stored EPUB entries as byte windows and DEFLATE entries through a
bounded in-memory checkpoint index, without extracting audio to cache.
Reuse the native narration clock and controls; retain browser playback
for remote audio and local MP3/Ogg/Opus/WebM sources.

Cover source integrity, exact seeks and MP4 edit timing, bounded output,
audible playback position, ordered controls and cancellation of pending
loads. Run the native plugin and lifecycle regressions in PR CI.

Regression evidence: without the Linux source-descriptor change,
"hands Linux the raw compressed ZIP entry without reading its audio
bytes" fails because getMediaSource returns null instead of the path
and raw ZIP entry. Transport and device-stream lifecycle regressions
were also verified to fail before their corresponding fixes.

Verified on current origin/main: full Vitest suite (14687 passed,
16 skipped), lint, format check, web build, Rust formatting and CEF
Clippy with warnings denied. CEF unit tests: 201 app + 24 plugin tests
passed; 3 transport/device-stream lifecycle regressions passed.
Nix cargoDeps realization and actionlint passed. Full Nix app build
and mobile device tests not run.

Linux CEF runtime with Symphonia 0.6.1: captured audible AAC, verified
forward/backward seeks, rate, pause/frozen clock, abort, and compressed
EPUB playback through all three paragraph highlights to completion.
No reporter EPUB was supplied; used generated narration fixtures.
One earlier app run exited SIGBUS during a shared-target rebuild;
cause unconfirmed, fresh launch after checks passed the sequence.

Reported by DeathStroke19891 on GitHub. Fixes #7084.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(tts): enqueue Linux controls before async dispatch

Tauri schedules async command invocations independently, so pause/resume
could reach the Linux worker in reverse order even when blocking reply
waiters were kept separate. Dispatch Linux playout_control directly from
the synchronous plugin handler, then resolve its worker reply off-thread.
Retain the same IPC payload, ACL parsing, asset scope and non-Linux paths.
This also allows abort to cancel a pending load without waiting for its
reply, which a frontend promise chain would delay.

Regression evidence: reverse the first polls of the old command futures
and the ordering assertion fails with ["resume", "pause"] instead of
["pause", "resume"]. The updated production-handler regression asserts
pause/resume/load/abort enqueue before any response future is polled,
then runs response tasks and blocking waiters in reverse order.

Verified Rust formatting, CEF Clippy with warnings denied, 201 app and
24 plugin unit tests, 3 lifecycle regressions, and a rebuilt CEF app.
Runtime: 40 rapid pause/resume cycles preserved final state, pause froze
the clock, and abort canceled a 226 MB compressed recording load in
about 19 ms. Invalid payload and out-of-scope path rejections passed.
Independent review verified ACL handling and non-Linux routing.
Frontend checks are rerun by the repository's pre-push hook.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* refactor(tts): hide narration platforms (owner: remove the linux flag)

Move native source selection and backend capabilities into
NativeNarrationPlayer. MediaOverlayClient retains one native flag and
uses streaming, queueing, and cancellation capabilities without OS checks.
Preserve local ZIP playback, browser fallbacks, and mobile staging.

Validation: 93 focused tests passed; full Vitest suite passed 1,220 files
and 14,691 tests (4 files and 16 tests skipped). TypeScript, Biome lint,
format checking, and git diff --check passed. Lint reports one existing
informational diagnostic in nativePageTurn.ts. New loadSource tests fail
before delegation exists and pass afterward. In an isolated Linux CEF
app, compressed AAC playback advanced through all three paragraph
highlights using the native clock. Mobile device checks were not run.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(tts): finish canceled narration loads without errors

A native load can be canceled independently of the speak signal. Suppress
load failures when either signal was aborted, retaining the original
playback signal across invalidation so Rust cancellation errors are also
recognized. Other load failures still yield playback errors.

Validation: eight regression cases fail without this guard, yielding an
error instead of completing the generator. All 95 focused native/client/
player tests pass with the fix, including genuine load failures. TypeScript,
Biome lint and formatting, and git diff --check pass. In isolated Linux CEF,
stopping a large compressed recording during loading closes the player,
leaves native playback stopped, and logs no playback error. Mobile device
checks were not run. The pre-push hook runs the full frontend suite.

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-02 08:54:20 +01:00
Ardit Abrashi
23b8dd5b59
fix(nix): stabilize the dev shell and share Linux runtime dependencies (#6851) 2026-10-20 16:28:32 +02:00
Huang Xin
90f5fdd350
fix(nix): match the Android AVD ABI to the host architecture (#5732) (#5850)
The android devShell installs the arm64-v8a Android 34 system image on
aarch64-darwin and the x86_64 one on x86_64-linux, but its shellHook
always asked avdmanager for system-images;android-34;google_apis;x86_64.
That package is never installed on Apple Silicon (and the emulator could
not run it there anyway), so avdmanager create avd fails on every
aarch64-darwin `nix develop .#android`. Derive one androidAbi value from
the host CPU and use it for both the SDK image attributes and the -k
path so the two cannot drift apart again.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 18:10:00 +02:00
dastarruer
d4bf089ac2
feat: package for nix (#5605)
* refactor(nix): move nix files out of `ops/`

* feat(nix): package for nix

* docs(nix): add installation guide

* chore(workflows): add workflow to build on nix

* chore(workflows): move flake check to pull requests, and builds to cron

* fix(nix): only add ios shell on darwin

* chore(workflows): add workflow to update flake inputs periodically

* chore(workflows): rename nix.yml to nix-build.yml

* chore(workflows): add cachix to nix-build

* chore: check all systems

* chore: auto-update hashes

* fix: set platform to linux and add warning in docs

* fix: only evaluate android shell if system is not aarch64

* fix: drop soon-to-be-deprecated x86_64-darwin platform

* fix: use more explicit nix build command

* fix: respect .gitignore in src

* chore: only run nix build on push to main

* fix: remove duplicate nix installer action

* chore: fix script formatting

* chore: move build check to flake checks

* chore: remove automatic hash-mismatch fix

* fix: only give read permissions to nix build action

* fix: use more explicit matching

* fix: remove unnecessary passthru references

* fix: pin action versions

* fix: use cachix for nix flake check

* fix: remove unnecessary secret

* fix: do not push flake check builds

* fix: meta.platforms -> platforms

* fix(nix): wire up the public binary cache and drop aarch64-linux

The Cachix cache was populated by CI but unreachable by users: neither the
flake nor the README pointed at it, so every install compiled the Rust/Tauri
stack and webkitgtk from source. Add nixConfig substituters and document the
cachix use / nix.settings opt-ins.

skipPush was passed to install-nix-action, which has no such input, so PR
builds still pushed whenever the token was present. Move it to cachix-action
and drop authToken there: the cache is public, so pulling needs no token, and
PR-triggered builds no longer see the push token at all.

Restrict nix_flake_check to pull_request. It also ran on main pushes, where
nix-build.yml already builds and pushes the same paths.

Drop aarch64-linux from eachSystem. Nothing built or cached it, so ARM Linux
users got a cache miss on everything. That makes the two system != aarch64-linux
guards dead, so fold those attrsets back into their bases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(nix): refresh the pnpm deps hash after lockfile changes on main

nix flake check builds the pull_request merge ref, so the fixed-output
derivation covers main's pnpm-lock.yaml, not just the branch's. Two lockfile
changes landed on main after the hash was pinned (#5754, #5764), so the FOD
went stale and the check failed with a hash mismatch.

Cargo.lock and the turso plugin are unchanged over the same range, so
cargoHash and tursoPluginDeps still match.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* perf(nix): make the PR flake check evaluation only

nix flake check builds every attribute in `checks`, so `checks.build =
packages.default` turned the PR check into a full release build: cargo vendor,
a production Next.js build, and a cold release compile of the whole Tauri tree.
Nix builds in a pure sandbox, so it cannot use the sccache and rust-cache the
other Rust jobs rely on, and the binary cache is still empty, so nothing
amortized it. Observed over 45 minutes per run.

Drop the attribute. The flake outputs are still evaluated across systems, which
catches eval errors, and nix-build.yml keeps doing the real build on main and
pushing the result to the cache.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(nix): pin actions/checkout to a commit sha

nix-build.yml used the mutable v5 tag while the other 19 checkout usages in
this repo pin 3d3c42e5aac5ba805825da76410c181273ba90b1 (v7.0.1). A movable tag
lets the action change under us and is what the scorecard pinned-dependencies
check flags.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(nix): compress the README install and fix the dev shell commands

README: five code blocks down to three. The three interchangeable ways to opt
in to the cache collapse to one, and the two configuration.nix snippets merge
into a single block, since a NixOS user edits one file. Note why the cache has
to be repeated there: a flake input's nixConfig does not apply to the importing
system build, so the systemPackages path would otherwise build from source.

CONTRIBUTING: the documented shells pointed at ./ops, which this branch
deleted when it moved the flake to the repository root, so all three commands
failed. The web shell is also named default now, and ios is gated behind
isDarwin.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 18:03:22 +02:00