Skip to content

Fix playback race conditions, optimize DASH memory, and secure local media server - #65

Merged
ajisth69 merged 4 commits into
Clash-Projects:mainfrom
Umangnamdeo:main
Oct 20, 2026
Merged

ajisth69 merged 4 commits into
Clash-Projects:mainfrom
Umangnamdeo:main

Conversation

@Umangnamdeo

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request addresses several stability, performance, and security issues across the desktop audio pipeline:

  1. Security & Local Server Isolation (local_media_server.dart)

    • Enforced ephemeral authentication token verification on all loopback requests to prevent unauthorized local port scanning or stream interception.
  2. Audio Hardware Fallback & Safety (wasapi_engine.dart)

    • Added bounded timeouts and exception handling around device probing and volume control to prevent driver hangs and unhandled platform exceptions.
    • Added format support validation before attempting exclusive mode handoffs.
  3. Playback Race Conditions & State Integrity (playback_service.dart)

    • Resolved race conditions triggered by rapid track skipping by validating generation tokens across asynchronous boundaries.
    • Prevented outdated network requests and stale native operations from overriding active playback state or triggering false-positive error alerts.
  4. DASH Assembly Memory Optimization (dash_assembler.dart)

    • Reduced concurrent download parallelism from 12 to 6 to avoid excessive heap allocations on high-bitrate tracks.
    • Cleared memory buffers immediately after chunks are written to disk, preventing large RAM spikes and GC-induced audio stutters.
  5. UI Thread Responsiveness (signature_decipher.dart)

    • Offloaded player script regex parsing and cipher extraction to a background Dart worker isolate (Isolate.run), eliminating UI frame drops during YouTube stream resolution.

Testing & Verification

  • Verified all 5 modified files pass static analysis with 0 lint/analyzer errors.
  • Confirmed bit-perfect and shared-mode audio transitions function without driver crashes.
  • Tested rapid track skipping in the queue to confirm no audio overlapping or stuck buffering indicators.

@ajisth69
ajisth69 merged commit 2ddad40 into Clash-Projects:main Oct 20, 2026
3 checks passed
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.

2 participants