Skip to content

fix: resolve stream availability, blank login, playback freezing, WASAPI slowdown, and Linux OpenGL crash - #62

Merged
ajisth69 merged 3 commits into
Clash-Projects:mainfrom
YadneshTeli:fix/all-open-issues
Oct 19, 2026
Merged

ajisth69 merged 3 commits into
Clash-Projects:mainfrom
YadneshTeli:fix/all-open-issues

Conversation

@YadneshTeli

Copy link
Copy Markdown
Contributor

Description

This pull request addresses and fixes all currently open stability, playback, authentication, and driver crash issues across Windows, Linux, and cross-platform desktop targets, including review feedback on stream filtering, audio caching, and window lifecycle.

Issues Addressed & Closes


Detailed Summary of Changes

1. Audio Streaming & Download Fixes (#52 & #42)

  • Direct Client Prioritization: Set _fastPreferredClient = 'ANDROID' in lib/features/innertube/innertube_api.dart. YouTube frequently blocks web/desktop/visionOS guest clients, whereas ANDROID & IOS direct streams return valid unthrottled streams.
  • Pure Audio & Video Codec Filtering: Updated _isCompatibleAudio and format collectors to inspect the complete codec list and MIME string. Compound streams containing video codecs (avc1, hvc1, vp9, av01, etc.) or video/* MIME types are strictly rejected, preventing mislabeled video downloads and high bandwidth usage. Pure adaptive audio streams (audio/webm Opus, audio/mp4 AAC) are prioritized.
  • Decipher Script URL Escaping: Fixed jsUrl extraction in lib/features/innertube/signature_decipher.dart by capturing complete JSON string values and decoding JSON escapes (such as \/ and \\). This ensures sts and deciphering functions are resolved even when the script path in YouTube's bootstrap object contains escaped slashes.

2. YouTube Music Login Fixes (#38 & #54)

  • Controller Initialization Delay: In lib/features/innertube/yt_web_login.dart, added a 300ms delay before loading the login URL to give the native WebView controller time to bind.
  • Stuck about:blank Auto-Recovery: Added isBlankUrl() detection; if the controller is stuck on about:blank, it automatically relaunches and executes window.location.href to trigger the login redirect.
  • Strict YouTube Session Verification: Updated _readHeader to verify that .youtube.com session cookies (LOGIN_INFO, SAPISID, etc.) are present before concluding login, preventing Google-domain accounts.google.com cookies from ending the login flow prematurely.
  • Dismissed Window Lifecycle Protection: Added window visibility and dismissal tracking in YtWebviewGuard (linux/runner/yt_webview_guard.cc and lib/features/innertube/yt_webview_guard.dart). When the user dismisses the sign-in window on Linux via the window manager close button, retry loops immediately stop without reopening the hidden window.

3. Playback Unresponsiveness & Audio Output (#13 & #15)

  • WASAPI Format Probe Cache: In windows/runner/wasapi_engine.cpp, added a thread-safe cache (g_probe_cache) keyed by device ID. Supported formats are probed once and retrieved in microseconds, eliminating repeated ~30s bus-level sample rate probes on playback.
  • Cache Invalidation on Device State Changes: In NotificationClient, calls InvalidateProbeCache() upon OnDeviceStateChanged, OnDeviceAdded, and OnDeviceRemoved so reconfigured or reconnected endpoints re-probe their capabilities accurately.
  • Selective Property Notification Filtering: Rather than discarding all property notifications, OnPropertyValueChanged now filters to relevant device identity properties (PKEY_Device_FriendlyName, PKEY_DeviceInterface_FriendlyName, PKEY_Device_DeviceDesc, PKEY_Device_EnumeratorName) while ignoring high-frequency playback, volume, and meter updates.
  • Hotplug Debounce Batch Action Preservation: In lib/features/audio_output/output_controller.dart, accumulated all events across the 300ms debounce batch so a subsequent event does not drop removal actions (pause(), DAC disconnected) or skip player configuration (applyToPlayer()).
  • Transport Debounce & Timeout: Debounced playback_service.dart toggle events by 150ms, added error guards to transport methods, and placed a 1-second timeout on _refreshAoFormat()'s property lookup.

4. Linux OpenGL 2.1 Hardware Compatibility (#53)

  • Software Rendering & Impeller Fallback Flags: In linux/runner/main.cc and linux/runner/my_application.cc, added --no-enable-impeller, --disable-impeller, --enable-software-rendering, and --software flags. Configures fl_dart_project_set_enable_impeller(project, FALSE) and exports LIBGL_ALWAYS_SOFTWARE=1.
  • Automatic OpenGL Version Detection in AppRun: Updated .github/workflows/desktop.yml AppRun wrapper to inspect glxinfo on launch. If the host GPU only supports OpenGL < 3.0 (where Impeller fails), it automatically sets LIBGL_ALWAYS_SOFTWARE=1 (LLVMpipe provides OpenGL 4.5+ with glBlitFramebuffer).

5. Windows Kernel BugCheck 0xD1 & Test Stability

  • Windows Kernel Crash Prevention: Skipped the Unix domain socket loopback test in test/presence_ipc_test.dart on Windows (skip: Platform.isWindows). On Windows, Discord IPC uses named pipes (\\.\pipe\discord-ipc-N), and attempting to bind an AF_UNIX socket in a temporary path triggered a known BugCheck 0xD1 (DRIVER_IRQL_NOT_LESS_OR_EQUAL) in Windows' afunix.sys.
  • Feed Normalization Regex: Fixed a regex typo (\vert{} -> |) in feed_repository.dart for parenthesized featured credits.
  • Karaoke Candidate Ranking: Updated unit test expectations in test/karaoke_lyrics_test.dart to align with the synced-over-static candidate selection logic.

Verification & Testing

  • flutter analyze: 0 issues found (passed with clean analysis)
  • flutter test: 394 passed, 9 skipped, 0 failed across all 46 test suites

…API slowdown, and Linux OpenGL crash

- Fix Clash-Projects#52, Clash-Projects#42: prioritize ANDROID/IOS direct streaming clients, support compatible progressive MP4 AAC audio containers, fix compound codec parsing, normalize audio MIME types, and update player script regex.

- Fix Clash-Projects#38, Clash-Projects#54: add initialization delay before webview navigation, detect and recover from stuck about:blank pages, and expand session cookie recognition.

- Fix Clash-Projects#13: debounce toggle transport in playback service, add non-blocking timeouts for audio output format queries, and silence property change hotplug events.

- Fix Clash-Projects#15: add thread-safe format probe cache for WASAPI exclusive mode to eliminate 30s sample rate bus probe delays, and debounce endpoint notifications.

- Fix Clash-Projects#53: add --no-enable-impeller / --software fallback flags in linux runner, and detect OpenGL < 3.0 in AppImage AppRun wrapper to auto-fallback to software rendering.

- Test fixes: skip Windows AF_UNIX socket loopback test to avoid kernel afunix.sys bugcheck 0xD1, fix regex syntax in feed artist normalization, and update candidate ranking test assertion.
@ajisth69
ajisth69 merged commit 0ae394d into Clash-Projects:main Oct 19, 2026
@YadneshTeli
YadneshTeli deleted the fix/all-open-issues branch October 21, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment