Skip to content

libobs: Keep group children in place when the group resizes - #280

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/9298-group-child-drift
Oct 11, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/9298-group-child-drift

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Moving one child of a group no longer drags the group's other children across the canvas.

Moving a child changes the group's content bounds, so the group is resized on the next video tick: resize_group() shifts the children to start at the group's origin and moves the group so the content stays where it was. It computed the group's new position from the content's exact size, but the group draws with its alignment offset taken from its rounded size (ceil() to whole pixels, scaled and truncated, integer halves for centred alignment). With centred, right or bottom alignment, every resize shifted the content by the rounding remainder, and the shifts added up.

  1. test: Moving a group child must not drag its siblings (RED): test_group_child_drift builds a two-child group on a 1920x1080 canvas, moves one child in 60 fractional steps (as dragging in a scaled preview does), waits for the group to resize after each, and measures the other child on the canvas. Today: (−0.66, −0.57) px with a centred group, (−29.3, −30.1) px with a bottom-right group; the top-left case passes and guards the fix. 2 of 3 fail.
  2. libobs: Keep group children in place when the group resizes: note where the content's corner is on the parent with the old transform, rebuild the transform with the new size, and move the group by the difference. The content stays exactly in place whatever the rounding, alignment, scale or rotation. 3 of 3 pass.

The group's own position can still differ from the content's exact edge by under a pixel, because its size is whole pixels; it no longer accumulates.

Motivation and Context

Fixes #279 (upstream obsproject/obs-studio#9298, reported by Durss)

Why this one: confirmed upstream by RytoEX and PatTheMav ("the calculated values for positions are wildly off"), with a video from the reporter; anyone laying out groups with centred or bottom/right alignment sees their sources creep while editing.

How Has This Been Tested?

Automated, in both libobs lanes (ENABLE_RUST_LIBOBS OFF and ON), on current master:

  • test_group_child_drift: 2 of 3 fail at the RED commit, 3 of 3 pass at GREEN.
  • Full ctest at GREEN: 89 of 89 in each lane, under a private Xvfb with software GL.
  • clang-format, gersemi and ci/test_registration.py are clean.
  • Without a display (like the Tier 2 Linux lane), obs_startup() fails and the new test's cases skip, as the other core tests do.

Not tested:

  • Manual dragging in the full OBS UI, and groups with rotation or scale (the fix uses the group's own transforms, so they are covered by construction, but no test exercises them).
  • Windows and macOS. The change is platform-independent C in libobs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR
  • I am an AI agent being used to assist with this pull request: Claude Code (Claude Opus 5.5) wrote the code, commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

rdoupe and others added 2 commits October 11, 2026 18:17
Moving one child of a group changes the group's content bounds, so the
group is resized on the next video tick: its children are shifted to
start at the group's origin and the group is moved so the content stays
where it was. The group's position is computed from the content's exact
size, but the group draws with its alignment offset taken from the
rounded size (ceil to whole pixels, scaled and truncated, integer halves
for centred alignment), so every resize moves the content by the
remainder and the moves add up.

test_group_child_drift moves one child of a two-child group in 60
fractional steps on a 1920x1080 canvas, as dragging in a scaled preview
does, and checks where the other child ends up. Today it moves by
(-0.66, -0.57) px with a centred group and by (-29.3, -30.1) px with a
bottom-right group; a top-left group stays put and guards the fix.

Reported upstream in obsproject/obs-studio#9298 by Durss, confirmed by
RytoEX and PatTheMav.

Refs obs-rust#279.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
resize_group() moved the group to where the content's alignment anchor
was, computed from the content's exact size, while the group draws
with its alignment offset taken from its rounded size. With centred,
right or bottom alignment each resize therefore shifted the content by
the rounding remainder, and dragging one child slowly dragged its
siblings across the canvas.

Measure instead: note where the content's corner is on the parent with
the old transform, rebuild the transform with the new size, and move
the group by the difference. The content then stays exactly in place
whatever the rounding, alignment, scale or rotation.

Fixes obs-rust#279.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rdoupe
rdoupe requested a review from zackees as a code owner October 11, 2026 22:18
@zackees
zackees merged commit 35bbf88 into obs-rust:master Oct 11, 2026
22 of 23 checks passed
rdoupe added a commit to rdoupe/obs-studio that referenced this pull request Oct 11, 2026
obs_startup() needs a display on Linux, and the Tier 2 Linux lane has
none. test_audio_clock_drift (obs-rust#271) and test_group_child_drift (obs-rust#280)
failed their group setup there instead of skipping, which turned that
lane red on master. test_pulse_monitor_device (obs-rust#275) has the same setup
and would fail the same way on a machine with PipeWire but no display.

Like the other core tests, they now skip their cases when libobs cannot
start (and the group test also when core video cannot be reset). Under
xvfb-run every case still runs.

Refs obs-rust#270, obs-rust#274 and obs-rust#279.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
zackees pushed a commit to rdoupe/obs-studio that referenced this pull request Oct 11, 2026
obs_startup() needs a display on Linux, and the Tier 2 Linux lane has
none. test_audio_clock_drift (obs-rust#271) and test_group_child_drift (obs-rust#280)
failed their group setup there instead of skipping, which turned that
lane red on master. test_pulse_monitor_device (obs-rust#275) has the same setup
and would fail the same way on a machine with PipeWire but no display.

Like the other core tests, they now skip their cases when libobs cannot
start (and the group test also when core video cannot be reset). Under
xvfb-run every case still runs.

Refs obs-rust#270, obs-rust#274 and obs-rust#279.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=b23e288a822896090994f89892a7a96b56da5f80 secs=109 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791758098,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9087272be2f5e155c698727d45922688d933308d2c4f08bc86b0f6e131472181","lane":"lint","parents":["35bbf88c776c3a4cb7073dae0b7869a9b75af833"],"secs":15,"stamp":"25c454c9d662469fb5114491251212e2","tree":"b23e288a822896090994f89892a7a96b56da5f80","v":1,"via":"run"}
Ci-Attestation: {"at":1791758098,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9087272be2f5e155c698727d45922688d933308d2c4f08bc86b0f6e131472181","lane":"lint","parents":["35bbf88c776c3a4cb7073dae0b7869a9b75af833"],"secs":15,"stamp":"103e935b7c7d4896cf51a6593a16411a","tree":"b23e288a822896090994f89892a7a96b56da5f80","v":1,"via":"run"}
Ci-Attestation: {"at":1791758098,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"2163bf0ab811b6bf62c711d254cc4f2bbd240ef3efeeb7f5425a8b720e0132d7","lane":"rust-test","parents":["35bbf88c776c3a4cb7073dae0b7869a9b75af833"],"secs":45,"stamp":"7a7452f3822e6646eb2e2c481ee772ca","tree":"b23e288a822896090994f89892a7a96b56da5f80","v":1,"via":"run"}
Ci-Attestation: {"at":1791758098,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"93153b10b0a7fc6c2e9fe5745e8f1b417bf629afda1d66c21fe151867ea291a7","lane":"tier2-linux","parents":["35bbf88c776c3a4cb7073dae0b7869a9b75af833"],"secs":49,"stamp":"9d46f419860c544d1aeb889a3d125f74","tree":"b23e288a822896090994f89892a7a96b56da5f80","v":1,"via":"run"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: moving one child of a group drags its siblings across the canvas (upstream #9298)

2 participants