5ae2817eea87c33d550e0cf5fc9dd4c1027ca224
The segfault: Qt destroys and recreates a widget's QOpenGLContext whenever it moves to another top-level window, then calls initializeGL() again. libmpv permits one render context per handle, so the second creation failed with "There is already a mpv_render_context set" -- and the except branch assigned self._render_ctx = None, dropping the last Python reference to the first context, which libmpv was still holding a function pointer into. python-mpv's MpvRenderContext has no __del__ and free() does not unregister the callback, so the ctypes trampoline was collected while registered and the next frame notification jumped into freed memory. Two invariants fix it. initializeGL() now tears down any existing render context first, so a second call is an ordinary recreation. Teardown clears update_cb, calls free() with the GL context current, and only then drops the reference -- and it is connected to QOpenGLContext.aboutToBeDestroyed, so it runs before the GL context dies instead of never. The local reference during teardown is load-bearing: it is what keeps the trampoline alive until free() returns. Three things were destroying that context. Fullscreen reparented the panel into a new top-level window (twice per toggle) and put it back at the end of the splitter, losing the pane layout; it now fullscreens the main window and hides the chrome, reparenting nothing. The tab cross-fade and the dialog blur both grab() the widget tree, which on an OpenGL surface forces a framebuffer readback and returns black -- the fade is skipped for pages holding the video, and dialogs dim rather than blur. Verified on a real Wayland GL context: ten forced context destroy/recreate cycles re-establish the render context every time, and the full app survives tab switching, six fullscreen toggles and resizes with no render-context error and a clean exit. Before this, the same startup dumped core. Also here because they are one-line consequences of touching _create_mpv: an explicit per-platform hwdec list ending in software decoding, and the restored volume actually reaching mpv -- the slider set its value before connecting its signal, so playback always started at 100. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
SageTube
A watch-first YouTube client for the desktop. Search, browse channels and playlists, follow subscriptions, and stream videos in an embedded mpv player — with the full yt-dlp download feature set inherited from YTSage.
Features
Watching
- 📺 Embedded mpv player (Wayland/X11/Windows/macOS) with quality selector, speed, volume, subtitles, fullscreen
- 🔍 In-app YouTube search with thumbnail card grid
- 📂 Channel browsing (Videos / Shorts / Live) and playlist views
- 🔔 Local subscriptions — no Google account needed — with an aggregated feed; optional real account feed via browser cookies
- ⏯️ Watch history with resume positions and a persistent play queue
- ⬇️ One click from any video card into the downloader
Downloading (from YTSage)
- Format table, audio extraction, subtitles, SponsorBlock, chapters, playlists, trimming, speed limits, proxies, cookies, custom yt-dlp commands, download history — see the upstream README
Install
pip install .
sagetube
Requires libmpv for playback (Arch: pacman -S mpv) — see
Building. Without it the app works as a downloader.
Fork notes
SageTube is a fork of YTSage by
oop7 (MIT). The internal package keeps the
ytsage name so upstream fixes remain mergeable — see
Tracking upstream. The fork also fixes a number of
upstream bugs (unsafe partial-file cleanup, unverified binary updates,
thread-safety issues, PATH corruption on Windows — see the git log).
License
MIT — see LICENSE.