Fix browser source tearing with hardware acceleration - #531
Open
hubert-blasttv wants to merge 1 commit into
Open
Fix browser source tearing with hardware acceleration#531hubert-blasttv wants to merge 1 commit into
hubert-blasttv wants to merge 1 commit into
Conversation
|
I have independently tested the patch and this solves our issue! |
TheB1gG
pushed a commit
to TheB1gG/obs-studio
that referenced
this pull request
Aug 29, 2026
…ation Cherry-pick of obsproject/obs-browser#531 (839d3e9) by Hubert Walczak. CopyAcceleratedTexture() now copies CEF's pooled texture into an OBS-owned texture inside OnAcceleratedPaint instead of sampling the pooled handle later (obsproject#488).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since the CEF M124 OSR rework,
OnAcceleratedPainthands out a texture from a small internal pool, with no keyed mutex. The handle "cannot be cached and cannot be accessed outside of this callback" and the contents "should be copied to a texture owned by the client application". "Resources will be released to the underlying pool for reuse when the callback returns" and that the texture "is instantiated without a keyed mutex".The current implementation does the opposite: open the handle, keep the resource as
bs->texture, and let the render thread sample it during composition at some later point. When the compositor falls behind under CPU load, CEF is already writing a later frame into that same pooled texture while we sample it, which shows up as the one-frame swaps and tears from the issue.Fix
CopyAcceleratedTexture()now copies the frame into a texture we own, inside the callback, while the handle is guaranteed valid. The copy target is reused across frames and only reallocated when the size or format changes.gs_flush()submits the copy before the callback returns, since the pooled texture can be reused after that. The render thread then samples our private, stable copy.The
gs_texture_acquire_sync(shared, 1, 50)is a no-op right now but it cooperates, with a bounded wait, if a future producer exposes a keyed mutex.One note: the flush submits the copy but cannot fence it, because CEF exposes no fence through this API. This is as close to the documented contract as a consumer can get. The exposure window shrinks from a full compositor frame of sampling to command submission granularity, and the pool depth gives the copy several frame intervals of slack in practice.
Motivation and Context
Recurrence of #488
How Has This Been Tested?
Retested multiple times against example from #488, and with python script to detect tear artifacts.
Types of changes
Checklist: