Skip to content

fix(playback): serve streams via WEB_REMIX only - #42

Open
mihaimetal wants to merge 4 commits into
NUber-dev:mainfrom
mihaimetal:fix/web-remix-streams
Open

mihaimetal wants to merge 4 commits into
NUber-dev:mainfrom
mihaimetal:fix/web-remix-streams

Conversation

@mihaimetal

Copy link
Copy Markdown
Contributor

Summary

  • Resolve progressive WebM streams with WEB_REMIX (YouTube Music cookies + SAPISIDHASH): raw Music /player plus youtubei.js decipher.
  • Probe googlevideo before registering the stream; headstart / pre-resolved poll for faster start.
  • Drop ANDROID_VR / yt-dlp from the hot path (subprocess and client noise removed). yt-dlp plumbing is left in place so it can be re-enabled later if needed.
  • Cap logs/stream.log at 2 MiB with rotation to stream.log.1.
  • Remove the player UI line under the artist (resolving… / WEB_REMIX / timing).

Why

Cold start with managed PyInstaller yt-dlp was very slow (~12s process spawn). WEB_REMIX with a proper cookie/SAPISIDHASH path gives reliable progressive playback without the multi-client fallback noise (ANDROID_VR LOGIN_REQUIRED, MWEB 403s, etc.).

Design notes for review

  • Intentional product choice: WEB_REMIX only for playback right now. Rare resolve misses will fail instead of falling back to yt-dlp until that path is re-enabled.
  • CSP allows 'unsafe-eval' so nsig decipher can run in the webview.
  • Stream method events still go to stream.log / console for debugging; just not shown under the artist.

Commits

  1. Intermediate cold-start work (in-process resolve / progressive path).
  2. Final WEB_REMIX-only cleanup (this is the intended end state).

Test plan

  • Play uncached tracks on macOS with a logged-in Music account
  • Confirm stream.log shows web_remix / probe / music+cookie path (no yt-dlp / android_vr spam)
  • Long tracks continue past early buffer
  • Release build: YTubic.app runs successfully
  • Windows smoke test with the same WEB_REMIX path (same cookie design; not fully verified here)

Related

Independent of the macOS packaging and auth PRs; can merge in any order, though packaging helps reviewers who build on Mac.

@mihaimetal
mihaimetal force-pushed the fix/web-remix-streams branch from 0cfd295 to 077c90c Compare July 27, 2026 13:43
@mihaimetal

Copy link
Copy Markdown
Contributor Author

Rebased onto current main after 0.4.0. This branch now carries the cold-start / native stream-resolve fix only — the follow-up "WEB_REMIX only" commit still conflicts hard on 0.4.0 and is not included here; can land separately if wanted.

@mihaimetal
mihaimetal force-pushed the fix/web-remix-streams branch 3 times, most recently from 3e7b852 to 8b62b1c Compare August 6, 2026 19:10
Seal cookie jars with an app-data AES key (mode 0600) instead of
macOS Keychain, so ad-hoc rebuilds no longer prompt for Keychain
access. Isolate login/keeper WebViews with per-account
data_store_identifier, inject a login script that fails WebAuthn so
Google offers password / another way, and keep 0.4.7's ServiceLogin
replay (NUber-dev#79) plus ytubic:// deep-link registration.

WEB_REMIX stream download (register_stream_source, no yt-dlp spawn)
lives in the same lib.rs overlay because spawn_downloader is not
separable from the auth helpers.
Resolve googlevideo URLs via Music/WEB_REMIX (cookies + decipher),
register them with Rust, and stream from that URL only. Drop the
launch-time yt-dlp download and do not spawn yt-dlp on a miss —
ANDROID_VR is also left disabled.

Keep 0.4.7's navigator.mediaSession handlers and Discord pause
clearing; audio-engine still calls streamUrlFor(), which now does
the WEB_REMIX head-start.
0.4.7's audio-engine still warms the upcoming queue item. Restore
prefetchStream against /stream after registering a WEB_REMIX URL so
that path does not 404 (the Rust /prefetch route was yt-dlp-only and
is gone).
Do not warm the upcoming queue item — that resolve/download competed
with the track the user just hit play on. Kick WEB_REMIX in the
background and hand /stream to the audio element immediately; Rust
already polls for the registered URL and starts progressive play at
the first 32 KB.
@mihaimetal
mihaimetal force-pushed the fix/web-remix-streams branch from 8b62b1c to 3f67c96 Compare August 26, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant