fix(playback): mask flashes between files - #21
Conversation
|
@FengZeng this is a bit of a weird one. To address this, I effectively added a "curtain" between the UI webview and the mpv layer while files are changing. |
|
Thanks for looking into this. The transparency was not intentional, it is indeed a bug. It can briefly occur when stopping playback or switching to the previous/next video. The root cause is that transparency is enabled globally in Your approach of disabling window
.as_ref()
.set_background_color(Some(
tauri::utils::config::Color(0, 0, 0, 0),
))?;This should provide better visual stability because only the WebView needs to support transparency; the native window itself does not need to be globally transparent. I also investigated why this approach exposes a white rectangle while switching or stopping playback. A simplified way to think about the rendering stack is as three layers:
The native window is initially created using the default size from When playback stops or changes files, the mpv layer is temporarily removed or hidden. If the WebView is transparent at that moment, the native window background becomes visible. This is why the result looks like a white rectangle matching the initial configured window size, surrounded by black. It remains visible until either the WebView becomes opaque again or mpv renders the next video over it. I think the cleanest solution is to paint the native window background using the current application theme's background color. That would make the transition visually seamless even when both the mpv layer and the WebView are temporarily transparent. It would also prevent differently colored edges from appearing while the user drags or resizes the window. |
|
@cjohnsto-nz I pushed a follow-up commit to your PR that implements native window background painting for windows only. Could you review it and check whether the transition behavior looks better now? |
|
The rendering logic on linux is different, so this issue doesn't occur there. The linux logic has been restored. |
Summary
Root cause
During a source transition, MPV's native render target can be absent or briefly contain its default or unpainted frame. Because the UI WebView is transparent during playback, that native transition can appear as a transparent or white flash. The source-loading flag cannot safely delimit this interval because it ends when MPV accepts the load command, before the first frame is necessarily presented.
The native host now provides a permanent black backing surface, and the WebView supplies a short black mask across the remaining render-target transition.
Platform safety
Validation
pnpm buildagainst current upstreammain