From 510b4233270267ed71e4851ae5dffab9f47234bc Mon Sep 17 00:00:00 2001 From: pax Date: Thu, 9 Apr 2026 20:51:06 -0500 Subject: [PATCH] main_window: skip embedded preview stop() when popout is open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit behavior change: _on_video_stream no longer calls stop() on the embedded preview's mpv when the popout is the visible target. The embedded preview is hidden and idle — the synchronous command('stop') round-trip was wasting ~50-100ms on the click-to-first-frame critical path with no visible benefit. loadfile("replace") in the popout's play_file handles the media swap atomically. --- booru_viewer/gui/main_window.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/booru_viewer/gui/main_window.py b/booru_viewer/gui/main_window.py index a447ca5..f6e2497 100644 --- a/booru_viewer/gui/main_window.py +++ b/booru_viewer/gui/main_window.py @@ -1461,21 +1461,25 @@ class BooruApp(QMainWindow): flag in that closure so it doesn't re-call set_media with the local path mid-playback (which would interrupt mpv and reset position to 0). + + When the popout is open, the embedded preview's mpv is not + stopped — it's hidden and idle, and the synchronous stop() + call would waste critical-path time for no visible benefit. """ - # Stop any video player currently active in the embedded - # preview before swapping it out — mirrors the close-old-mpv - # discipline of `_update_fullscreen`. - self._preview._video_player.stop() if self._fullscreen_window and self._fullscreen_window.isVisible(): - # Popout open — only stream there, keep embedded preview clear. + # Popout is the visible target — leave the embedded preview's + # mpv alone. It's hidden and idle; stopping it here wastes + # synchronous time on the critical path (command('stop') is a + # round-trip into mpv's command queue). loadfile("replace") in + # the popout's play_file handles the media swap atomically. self._preview._info_label.setText(info) self._preview._current_path = url self._fullscreen_window.set_media(url, info, width=width, height=height) self._update_fullscreen_state() else: - # Embedded preview's set_media doesn't take width/height - # (it's in a docked panel and doesn't fit-to-content) so - # the pre-fit hint goes nowhere here. Just hand it the URL. + # Embedded preview is the visible target — stop any active + # playback before handing it the new URL. + self._preview._video_player.stop() self._preview.set_media(url, info) self._status.showMessage(f"Streaming #{Path(url.split('?')[0]).name}...") # Note: no `_update_fullscreen_state()` call when popout is