Repository navigation
libobs: Treat an unknown bounds type as no bounds - #2307
Merged
Merged
Conversation
A scene item bounds type outside OBS_BOUNDS_NONE..OBS_BOUNDS_MAX_ONLY is stored as it comes. compute_item_transform() treats it as bounded and obs_bounds_fit_scale() leaves the scale alone, so the item draws at its own scale inside a phantom box the size of its bounds. test_scene_bounds_type_range puts two items over one 200x100 source in a scene (scale 1.5, top-left alignment, an 800x600 box aligned to its centre) and feeds the subject a bounds type through each way one comes in: - obs_sceneitem_set_bounds_type(); - obs_sceneitem_set_info2(); - frontend undo data, obs_scene_load_transform_states(); - a scene collection, obs_load_source() and obs_source_load2() (scene_load_item()). The values are every valid type, then 7, 99, -1, INT_MAX, INT_MIN, and for the loads 2^32 + 2 and INT64_MIN, which a cast to the enum truncates to 2 and 0. Each must read back (get_bounds_type and get_info2) as the value if valid, else OBS_BOUNDS_NONE, and the item's draw and box matrices must equal bit for bit those of the reference item set directly to that type. valid_types_draw_differently checks that every valid type but NONE moves this item, so the comparison can tell them apart. Without a fix the out-of-range values read back as given (2^32 + 2 as SCALE_INNER) and draw in the phantom box; the valid values and INT64_MIN pass. Refs obs-rust#2281
A scene item bounds type outside OBS_BOUNDS_NONE..OBS_BOUNDS_MAX_ONLY was stored as it came, from a scene collection (scene_load_item()), frontend undo data (load_transform_states()), obs_sceneitem_set_bounds_type() and obs_sceneitem_set_info2(). compute_item_transform() treats any type but OBS_BOUNDS_NONE as bounded and obs_bounds_fit_scale() leaves the scale alone for a type it does not know, so the item drew at its own scale inside a phantom box the size of its bounds, and the transform dialog showed no bounds type for it. valid_bounds_type() maps such a value to OBS_BOUNDS_NONE at each of the four entry points. The loads check the int64 they read before any cast, so 2^32 + 2 no longer truncates to SCALE_INNER; the setters check the enum value as int64, which catches a negative value whether the compiler makes the enum signed or unsigned. Valid values are stored unchanged. obs-websocket already maps unknown names to NONE and is unchanged; the Rust bounds functions (obs-scene::bounds) are pure and keep their parity with the C ones. Fixes obs-rust#2281
rdoupe
force-pushed
the
fix/bounds-type-range
branch
from
October 25, 2026 02:06
47c65bb to
d47844e
Compare
rdoupe
marked this pull request as ready for review
October 25, 2026 02:07
zackees
enabled auto-merge
October 25, 2026 02:11
5 of 7 tasks
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.
Fixes #2281
What and why
A scene item bounds type outside
OBS_BOUNDS_NONE..OBS_BOUNDS_MAX_ONLYwas stored as it came, from four places:scene_load_item());load_transform_states(), throughobs_scene_load_transform_states());obs_sceneitem_set_bounds_type();obs_sceneitem_set_info2().compute_item_transform()treats any type butOBS_BOUNDS_NONEas bounded, andobs_bounds_fit_scale()leaves the scale alone for a type it doesn't know. So the item drew at its own scale inside a phantom box the size of its bounds, offset by that box's alignment, and the transform dialog showed no bounds type for it.A new
valid_bounds_type()inobs-scene.c.hmaps such a value toOBS_BOUNDS_NONEat each of the four entry points:int64they read before any cast, so a value like 2^32 + 2 no longer truncates toSCALE_INNER.int64, which catches a negative value whether the compiler makes the enum signed or unsigned.What this leaves alone:
obs-scene::bounds,obs_bounds_fit_scale/obs_bounds_place) are pure and keep their parity with the C. None of the four entry points is ported.compute_item_transform()is a separate item and is not touched here.RED → GREEN
test_scene_bounds_type_range, real libobs, graphics suite). On master it fails on all three lanes: C libobs, hybrid libobs and libobs-c-reference (first run on 47c65bb, based on 55ee6e8).set_bounds_type_rangeandset_info2_range: 20 mismatches each.undo_transform_states_range: 24 mismatches.scene_load_range: 24 mismatches.SCALE_INNER), and the item is drawn at (350, 275) instead of (100, 50).valid_types_draw_differentlypasses, and every valid value round-trips.test_scene_bounds_type_rangepasses 5/5 with no skips on C libobs, hybrid libobs and libobs-c-reference. Every scene, group, bounds and transform test, including the websocket transform and bounds tests, also passes: 34/34 on C, 39/39 on hybrid and 39/39 on c-ref. Exported symbols are identical on all three lanes (1766).obs_load_source()andobs_source_load2().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