Repository navigation
libobs: Store the transition matrices under the transition mutex - #3640
Merged
Merged
Conversation
The Tier 1 fake now panics on a matrix stored without transition_mutex. The graphics thread and a caller of obs_transition_start() both store them, so matrix4_copy() races with itself. The tests fail until the store takes the lock. Refs #3570 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The graphics thread (tick) and a caller of obs_transition_start() both store the matrices, and matrix4_copy() writes four vectors, so a render could use a torn matrix. Store them under transition_mutex, with no call into a child source while it is held. render_child() uses the copy taken under the lock in place of the field. The C file changes with the Rust core, so Tier 3 still compares them. Refs #3570 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=b441027c4cd2d1990a07fa181381332bffb3393e secs=287 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793828334,"gate":"rust/all/fmt","host":"linux-x86_64","key":"26b9ce2d81dfc576f42a06f96780597da545447e3093d01e3696d0c7e1d8fc3c","lane":"lint","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":83,"stamp":"fc7c0a8a59b7c6dd2d4f9609abb4ec1e","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"26b9ce2d81dfc576f42a06f96780597da545447e3093d01e3696d0c7e1d8fc3c","lane":"lint","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":83,"stamp":"2eae3e8bc865f4bd24708139ebf22b35","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"4f5b450c6a9aa3268beee4f7a68f4c1f1d7849a192565c0e6a5a9456b07515b2","lane":"rust-test","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":101,"stamp":"80d001200d0c80a67c28acca1218b6a6","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"009834a90b341a796596287cff1eac2b31946eead7d8ccb9d3e6d4325b6a57bf","lane":"cross","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":75,"stamp":"523ffc66d983ddf3ffd5c6f1e7990885","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"009834a90b341a796596287cff1eac2b31946eead7d8ccb9d3e6d4325b6a57bf","lane":"cross","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":75,"stamp":"f5eff42039f9d0048daee52d46b655c5","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"009834a90b341a796596287cff1eac2b31946eead7d8ccb9d3e6d4325b6a57bf","lane":"cross","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":75,"stamp":"50c946cffe0027628327a2a1b83a81f7","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"009834a90b341a796596287cff1eac2b31946eead7d8ccb9d3e6d4325b6a57bf","lane":"cross","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":75,"stamp":"fc122a10c0ba722bc18df81af9dab7e4","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"} Ci-Attestation: {"at":1793828334,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"43acc412cd197cc099cab97688568d63e5473ad1a10e2631863608686b0653e9","lane":"tier2-linux","parents":["b8fb63d52f35ea70971db847f48e1dd1d764bb60"],"secs":286,"stamp":"8d1d4bff18e40ae60c6dc04899e6f9d3","tree":"b441027c4cd2d1990a07fa181381332bffb3393e","v":1,"via":"run"}
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.
Refs #3570
What and why
The
transition_matricespart of #3570. The other fields of that issue are not in this PR.The graphics thread stores the matrices in the tick, and a caller of
obs_transition_start()stores them too, with no lock.matrix4_copy()writes four vectors, so a render can use a torn matrix for a frame. This was the largest group in nightly 41851659014: 48 of 242 reports in OBS and test code.recalculate_matrixstores the matrix undertransition_mutex, inobs_source::transition_sizeand inlibobs/obs-source-transition-size.c.h, so Tier 3 still compares them. No call into a child source happens while the lock is held, so this adds no lock order.render_child()uses the copy that the render already takes under that lock, in place of the field. The two other reads already use that copy.RED → GREEN
transition_*Tier 1 and Tier 3 pass (259). Local gate: all Linux lanes passed.transition_*tests pass.matrix4_copyaftertest_source_transition_sizetest_transition_swaptest_transition_audio_rescaletest_transition_recursive_destinationtest_stinger_media_durationOne run on each side. The reports that remain are other fields of #3570 and other issues.
Performance
The tick takes the lock 2 more times per transition per frame, with no contention in the normal case. I did not measure it.
Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)🤖 Generated with Claude Code