Skip to content

Fix black video preview in burn-in / visual sync windows (#12205)#12235

Merged
niksedk merged 1 commit into
mainfrom
fix/mpv-preview-core-not-initialized-12205
Jul 7, 2026
Merged

Fix black video preview in burn-in / visual sync windows (#12205)#12235
niksedk merged 1 commit into
mainfrom
fix/mpv-preview-core-not-initialized-12205

Conversation

@niksedk

@niksedk niksedk commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

The video preview in the burn-in and visual sync windows stayed black until the window was resized/maximized (#12205). The main window's player was unaffected.

Root cause

Those windows open the video right from their Loaded event, but the mpv core is initialized lazily by the rendering surface — e.g. the OpenGL control calls InitializeWithOpenGL (→ mpv_initialize) on its first render pass, which hasn't happened yet at that point. The loadfile command therefore failed with MPV_ERROR_UNINITIALIZED (-3) and was never retried; all follow-up calls failed the same way (pause, SetAudioTrack: "core not initialized" in error-log.txt). Traced by logging the loadfile result:

main window:  LoadFile[OpenGL]: loadfile err=0     ← surface already initialized
burn-in:      LoadFile[]:       loadfile err=-3    ← core not initialized, never retried

The main window only works because its player idles until the user opens a file, long after the surface initialized.

Fix

In LibMpvDynamicPlayer:

  • Track core initialization with a _coreInitialized flag, set after mpv_initialize succeeds in all four init paths (OpenGL, Metal, software rendering, native wid Initialize()).
  • LoadFile / LoadAudio now await WaitForCoreInitializedAsync() (25 ms polls, 5 s cap) before issuing loadfile. The wait is async on the UI thread, so the first render pass — which performs the initialization — is not blocked; the load fires right after init completes.

If the surface never initializes (e.g. mpv missing), the bounded wait falls through and the command fails/logs exactly as before.

Testing

  • macOS (mpv-opengl): burn-in preview and visual sync now show video immediately on open; main window playback unaffected.

Fixes #12205

🤖 Generated with Claude Code

Windows that open a video right from their Loaded event (the burn-in and
visual sync previews) issued mpv's "loadfile" before the rendering surface
had lazily initialized the mpv core (mpv_initialize runs on the OpenGL
control's first render pass). The command failed with
MPV_ERROR_UNINITIALIZED and was never retried, leaving the preview black -
along with all follow-up calls (pause, SetAudioTrack: "core not
initialized"). The main window was unaffected only because its player idles
until the user opens a file, long after the surface initialized.

Track core initialization in LibMpvDynamicPlayer (set after mpv_initialize
succeeds in all four init paths: OpenGL, Metal, software, native wid) and
make LoadFile/LoadAudio wait (bounded, 5s) for it before sending commands.
The wait is async on the UI thread, so the first render pass - which
performs the initialization - is not blocked.

Fixes #12205

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@niksedk niksedk merged commit bd7288e into main Jul 7, 2026
3 checks passed
@niksedk niksedk deleted the fix/mpv-preview-core-not-initialized-12205 branch July 7, 2026 13:02
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.

[Potential Bug] Preview Video in Burn in Window

1 participant