Skip to content

obs-graphics: Port the libnsgif state machine and public API (#2510) - #2514

Merged
zackees merged 6 commits into
masterfrom
port/2510-gif-state
Oct 27, 2026
Merged

zackees merged 6 commits into
masterfrom
port/2510-gif-state

Conversation

@vpacher

@vpacher vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member

Fixes #2510

Slice 2c, the last one of libnsgif: the state machine and the public API of nsgif.h (libobs/graphics/libnsgif/gif.c.h), ported to obs_graphics::gif. With it, the hybrid libobs has no libnsgif C left: the LZW decoder (#2466), the block parsers (#2488), the frame decode (#2501) and now the state and the API are Rust.

What changed

  • rust/obs-graphics/src/gif.rs (safe core) and src/ffi/gif.rs (shim) for the fourteen functions of nsgif.h. nsgif_t is NsgifCtx: the safe Gif plus the buffer of the last scan, which the C keeps too and the decodes read. nsgif_info_t and nsgif_frame_info_t are #[repr(C)] in the state, since nsgif_get_info and nsgif_get_frame_info return pointers to them. nsgif_bitmap_cb_vt is BitmapCbVt, which implements the Bitmaps trait of the core over the client's function pointers. Not EXPORT, so the shims are hidden (rust-hidden.txt, rust-exports.map, rust-unexports-macos.txt).
  • gif.c.h moves from libobs.nsgif to the ported group libobs.ported-nsgif-gif (its PCH renamed with it). ci/test_ported_sources.py, rust/README.md, rust/obs-build (Windows warning options of the renamed group).
  • The C oracle no longer builds libnsgif as a library. image-file.c.h in the oracle calls the Rust shims, as libobs does, so the cargo image_file tests run on Rust libnsgif. oracle/gif.c is gif.c.h renamed, calling the C oracles of the other three files, for the parity test.
  • test_effect_parser_lifecycle_rust, test_sprite_geometry_steps_rust and test_nsgif_decode_rust take libnsgif from the staticlib instead of compiling the group.
  • The host endianness check of the bitmap format map is in src/platform/ (Dylint platform boundary).

Kept, characterized, not endorsed

  • A scan in parts that stops inside a frame does not recover. When the data ends inside a frame's image data or local colour table, or on the last byte of an extension, nsgif_data_scan keeps the position where the frame's parse stopped, not the frame's start. The next scan reads the rest of the frame as the next block: NSGIF_ERR_DATA_FRAME from then on, also with all the data. OBS scans whole files, so libobs never gets there. Upstream libnsgif has the same code. A fix with its own issue and PR follows this PR.
  • With play once (no loop extension), one more nsgif_frame_prepare after the last frame (infinite delay) shows frame 0 again before NSGIF_ERR_ANIMATION_END.

Intentional differences (C dereferences null; no caller gets there)

  • A null nsgif_t, callback table or out-pointer makes nsgif_create return NSGIF_ERR_DATA, and the other calls do nothing (or return NSGIF_ERR_DATA, NULL, false).
  • A missing create or get_buffer callback is a bitmap that cannot be made (NSGIF_ERR_OOM) or has no pixels.

RED → GREEN

  1. Characterization 2b6891848: ten gif_* cases in test_nsgif_decode through nsgif.h, on GIFs that a small writer in the test builds: the strings; the nine bitmap formats and their byte orders; a whole scan (info, frame info, the default delay, local palettes, a second scan, a scan after nsgif_data_complete); scans in two parts and byte by byte; the screen size quirk; GIFs without frames, a trailer as image data, a minimum code size of 12, not a GIF; nsgif_data_complete for cut frames; the frame order of nsgif_frame_prepare (redraw area, delay rules, play once, loop forever, data not complete, one frame); the disposal across frames, a restart, a cached frame; the bitmap callbacks and a wider row span. 39/39 on the C.
  2. RED d5891b032: Tier 1 render::gif, the ten cases 1:1 with the same writer, plus edge cases and a proptest (random and mutated GIFs, scanned in parts, then random calls: no panic, the frame count never shrinks): 0 of 13 pass (todo!()).
  3. GREEN 3c3475dcb: 13 of 13, and Tier 3 render::gif_parity against the whole of libnsgif in C: the strings, and 3 000 random cases of generated GIFs (one to four frames, every disposal, delays, transparency, rectangles inside and past the screen, interlace, local tables, loop counts, the screen size quirk), mutated or cut, and random bytes; scanned whole or in two to four parts, with or without nsgif_data_complete, in all nine bitmap formats, with or without the optional callbacks and a wider row span; then random prepares, decodes, resets and delay rules. After every call the result, the info, every frame info, both palettes, the prepare outputs, the decoded bitmap and the callback counts match. 3 of 3 with the shim-only null pointer test.

Mutation check (done once, not committed): 14 of 16 applied mutants fail Tier 1 or Tier 3; two of them first survived (a trailer as the second byte of the image data, a minimum code size of 12 in the scan), and two cases now cover them in all tiers. The two survivors are equivalent: >= to > in the restart condition of nsgif_frame_decode (the equal case returns the cached frame before it) and in the frame bound of nsgif_local_palette (the scan raises the partial frame count before a local table can be set).

port_comparison (M1 Max, five 1920×1080 frames scanned and decoded through the API, Rust on Rust, C on C, three runs): 49.3 to 50.6 ms, C 53.0 to 54.4 ms.

Tier 2 (Linux x86_64, Debian 13)

  • Lint lane (ci/local_gate.py --lane lint) passes.
  • test_nsgif_decode, test_nsgif_decode_rust, test_image_file, test_image_file_version, test_image_file_version_filetime, test_media_gif_last_frame, test_effect_parser_lifecycle, test_effect_parser_lifecycle_rust, test_sprite_geometry_steps and test_sprite_geometry_steps_rust pass on the hybrid libobs and on libobs-c-reference (10/10 each). test_nsgif_decode_rust runs the thirty-nine cmocka cases against the shims without any libnsgif C, with AddressSanitizer and UBSan.
  • Exported symbols: 1766 on both; the shims are local. The hybrid build has no libnsgif object.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: not applicable (no change in behaviour for GIF decoding)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes: not applicable
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

🤖 Generated with Claude Code

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

Coordinator review: the last libnsgif unit, the state machine and public API, in the same shape as #2471, #2492 and #2503. It brings a C reference copy, a parity test, a bench and the export maps, and the decode tests remove no assertions. Queuing; it merges when CI is green.

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

Windows failure (run 40375738347, Rust Tier 2 windows-2025-vs2026): native_libobs::windows_tests::core_builds_from_the_canonical_manifest panics at rust/obs-build/tests/libobs/windows.rs:34 with "compiler options refer to sources outside this target". This PR edits libobs/cmake/os-windows.cmake and rust/obs-build/src/platform/libobs_windows.rs. The new libobs.ported-nsgif-gif group probably isn't in the Windows canonical manifest's source list, or a per-file option still names libobs.nsgif+.h.c, which this PR removes. #2516 is stacked on this, so it's blocked too.

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed:

  • gif.c moves into the ported group, and the Windows warning options follow it (that was the earlier test failure).
  • The exports, hidden and macOS-unexport lists all gain the new symbols, and there's a C oracle copy, parity tests and a bench.
  • In test_nsgif_decode.c, only the header comment and one #endif guard are removed; no assertion is removed, and the file adds 735 lines of new cases. The test's cmake files drop the compiled-in libobs.nsgif+.h.c copies, which the Rust exports replace.
  • No public header is touched.

Auto-merge is on; it goes in once the Fast Gate re-run (after a runner shutdown) is green. #2516 needs a rebase after this lands.

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

Fast Gate has failed twice in a row with "The runner has received a shutdown signal" (exit 143). Both times it happened during cargo nextest, at about 190 s and 215 s. That usually means the runner ran out of memory or disk. I've re-run it once more. If it happens a third time, check whether a new nsgif test (a proptest or a large GIF) uses a lot of memory, or run soldr cargo nextest run -p obs-graphics locally under /usr/bin/time -v.

@vpacher

vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

I measured the memory of the new tests in advance, in case the third run fails too.

On Linux x86_64 (Debian 13), at 6a417d4, each of the 93 GIF, LZW and image_file tests of obs-tests-graphics ran alone, and I recorded its peak RSS:

  • The largest is render::gif_parity::api with 39 MB. All others are below 10 MB.
  • The longest is render::lzw_parity::emitter_streams with 4.3 s of CPU.

So the nsgif tests do not use enough memory to stop a runner. I did not measure the runner's disk use.

In both failed attempts, the tests that nextest reports as SLOW before the shutdown are obs-data parity tests that this PR does not change: obs_core::audio_discard_parity::random_cases_match (more than 120 s in attempt 2) and source::video_tick_parity::parity_proptest_tick_runs. If the third run also stops, these tests and the runner are the better place to look.

@zackees
zackees added this pull request to the merge queue Oct 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 26, 2026
@zackees
zackees force-pushed the port/2510-gif-state branch from 6a417d4 to 8cbad5f Compare October 26, 2026 21:13
@zackees
zackees enabled auto-merge October 26, 2026 21:13
@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

The merge queue ejected this. Configure failed on every platform with libobs/build/libobs.nsgif+.h.c cannot be read (run 40397316988). #2528 landed first and added test_graphics_state_stacks_rust, which compiles that group. I rebased onto master and pushed a fixup: that drops it from that target, as this PR already did for test_sprite_geometry_steps_rust. Auto-merge is back on.

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

The Windows Rust Tier 2 failure here (LNK2005 on matrix4_* in test_graphics_state_stacks_rust) comes from master, not this PR. #2534 fixes it, and once it lands this PR needs a rebase or re-run.

@zackees
zackees force-pushed the port/2510-gif-state branch from d2f833c to 17f4235 Compare October 26, 2026 22:12
@vpacher

vpacher commented Oct 26, 2026 •

Copy link
Copy Markdown
Member Author

The macOS Rust Tier 2 failure on this run (job 121885792485) is an intermittent crash, not the earlier assertion:

[ RUN      ] test_find_data_file
[  ERROR   ] --- Test failed with exception: Segmentation fault: 11(11)

The lldb step after it found no crash in 30 runs. I built master's test_obs_core_info_characterization (with #2534) on macOS 26.7.1 and ran it 120 times, 60 against libobs-c-reference and 60 against the hybrid libobs: no crash. Every run took the new macOS path (test_find_data_file skipped, 7 passed).

A possible cause, not proven: the group setup calls obs_startup(), so libobs threads run during each test, and cmocka's signal handler reports a SIGSEGV from any thread as a failure of the current test. I re-ran the failed job. If it crashes again, a stack from all threads in the ctest run itself would show where it comes from.

@vpacher

vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Note on the rebase: the rust/README.md row for libobs/graphics/libnsgif/gif.c.h was lost. It was next to #2528's graphics-state-stacks.c.h row, and the GREEN commit now adds no README lines. Nothing else changed (checked with git range-diff). So this PR does not have to run CI again, #2516 adds the row back, together with its own change to that row.

@vpacher

vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Found the cause of the macOS crash. It is not in this PR, and it is not random.

In both runs, the two normal ctest suites pass (339/339 against libobs-c-reference and 339/339 against the hybrid libobs). The crash is in the later stage Cargo [obs-c-reference] unchanged ctest suite. That stage runs the tests against build_rust/cargo-native-core/obs-c-reference/libobs.framework, which obs-build makes. stage_identity (rust/obs-build/src/platform/libobs_macos.rs) copies only libobs and Versions/A/libobs into it: there is no Info.plist, so there is no bundle identifier.

So in that stage, [NSBundle bundleWithIdentifier:@"com.obsproject.libobs"] in find_libobs_data_file (libobs/obs-cocoa.m.h) returns nil, the path string is nil, and strlen(libobsDataPath.UTF8String) is strlen(NULL): SIGSEGV in test_find_data_file. The lldb step and my local runs used the CMake frameworks, which have the identifier, so they did not crash. Before #2534 the first normal suite already failed at line 154, so the script never got to the cargo stage.

Fix: I will open an issue and a small PR that makes find_libobs_data_file return NULL when the libobs bundle is not found. Then obs_find_data_file searches the data paths, as on Linux and Windows. A separate follow-up could give the cargo-built framework an Info.plist.

@vpacher

vpacher commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Windows Rust Tier 2 on the rebased head (run 40422466703) failed on a crash in a test from #2508, not in this PR's code:

So it looks intermittent, maybe in the obs_startup()/obs_shutdown() teardown of that test. I will re-run the Windows job when the run is complete. If it crashes again, the cargo hybrid suite and that test's teardown are the place to look.

@vpacher

vpacher commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

The Windows re-run (job 121928441055) crashed again in test_scene_canvas_characterization (#2508), this time in the first suite, against the CMake libobs-c-reference\obs.dll, which has no Rust code. So it is not the cargo build and not this PR: it is that test (or the libobs C it calls) on Windows. That is two crashes in two Windows runs, so master's Windows Rust Tier 2 lane can fail on it for any PR that selects the lane. Again, the cdb re-run did not crash (11 passed, 2 skipped).

What the log shows: obs_startup() without graphics, the transition type is "not found", a private source is created anyway, and the two transition cases skip. A crash in that path or in the teardown of the canvases and transitions is possible, but I could not reproduce it.

Proposal: quarantine test_scene_canvas_characterization on Windows (CTest DISABLED or a skip under _WIN32, with an issue) until someone reproduces it, so this PR and the others can go through. Linux and macOS (now green with #2540) are clean on this head.

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

The Windows Tier 2 failure here isn't from this PR: test_scene_canvas_characterization (from #2508) segfaults in scene_find_source_recursive on master's Windows lane. It's filed as #2543. Everything else here is green, including macOS, which confirms #2540.

vpacher and others added 5 commits October 27, 2026 08:47
…nsgif.h (#2510)

Ten cases for gif.c before its port, on GIFs that a small writer in the
test builds (header, screen descriptor, colour tables, graphic control
and loop count extensions, images of one colour from the LZW emitter):
the error and disposal strings; the nine bitmap formats and their byte
orders, and the default black and white table; a whole scan (info, frame
info, the default delay of a frame without a graphic control extension,
local palettes, a second scan, a scan after nsgif_data_complete); scans
in two parts and byte by byte; the screen size quirk with the first
frame setting or growing the size; a GIF without frames, a cut one and
not a GIF; nsgif_data_complete for a frame cut in its image data (also
frame 0, which gets transparency); the frame order of
nsgif_frame_prepare with the redraw area, the delay rules, play once,
loop forever, data not complete and one frame; the disposal across
frames (restore background with and without transparency, restore
previous), a restart, a cached frame and a bad frame number; the bitmap
callbacks and a row span wider than the image. 39/39 on the C.

Kept, characterized, not endorsed:
- When a scan stops at the end of the data inside a frame,
  nsgif_data_scan keeps the position where the frame's parse stopped,
  not the frame's start. The next scan reads image data or an
  extension's terminator as the next block: a bad frame from then on,
  also with all the data. A split inside the image data or on an
  extension's last byte breaks a scan in parts; OBS scans whole files.
- With play once (no loop extension), one more nsgif_frame_prepare after
  the last frame (infinite delay) shows frame 0 again before
  NSGIF_ERR_ANIMATION_END.

Refs #2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The safe core of libobs/graphics/libnsgif/gif.c.h as obs_graphics::gif,
with todo!() bodies: Gif<B: Bitmaps> with new, set_frame_delay_behaviour,
data_scan, data_complete, reset, frame_prepare, frame_decode, info,
frame_info, global_palette and local_palette, and strerror and
str_disposal. Info and FrameInfo have the C layout of nsgif_info_t and
nsgif_frame_info_t, which the API returns pointers to. Bitmaps is the
client's nsgif_bitmap_cb_vt, with default methods for the optional
callbacks. Every call that reads the GIF data takes it. gif_blocks'
disposal constants get UNSPECIFIED and NONE.

Tier 1 (render::gif in obs-tests-graphics): the ten cmocka cases one to
one with the same GIF writer, edge cases (dropping a Gif destroys its
bitmap; a bitmap that cannot be created is out of memory) and a proptest
(random and mutated GIFs, scanned in parts, then random calls: no panic,
the frame count never shrinks).

RED: 0 of 13 pass.

Refs #2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GREEN for obs_graphics::gif: the safe core (the frame table and the scan
positions of nsgif_data_scan with its frame parse on the gif_blocks
parsers, nsgif_data_complete, the frame order, loop count and delay
rules of nsgif_frame_prepare, nsgif_frame_decode with the disposal
across frames, the saved frame and the bitmap callbacks on the gif_frame
decode, the palettes and the strings; the C's uint32_t arithmetic as
wrapping operations) and a thin hidden #[no_mangle] shim for the
fourteen functions of nsgif.h. nsgif_t is NsgifCtx: the safe Gif plus the
buffer of the last scan; Info and FrameInfo have the C layout, as the API
returns pointers to them; nsgif_bitmap_cb_vt is BitmapCbVt, which
implements the Bitmaps trait over the client's function pointers.

gif.c.h, the last C file of libnsgif, moves from libobs.nsgif to the
ported group libobs.ported-nsgif-gif (its PCH renamed with it), so the
hybrid libobs has no libnsgif C left. The C oracle no longer builds
libnsgif as a library: image-file.c.h in the oracle calls the Rust shims,
as libobs does, and oracle/gif.c is gif.c.h renamed, calling the C
oracles of the other three files, for the parity test. The _rust test
executables (test_effect_parser_lifecycle_rust,
test_sprite_geometry_steps_rust, test_nsgif_decode_rust) take libnsgif
from the staticlib instead of compiling the group.

Tier 1: 13/13. Tier 3 (render::gif_parity): the strings, and 3 000 random
cases of generated GIFs (one to four frames, every disposal, delays,
transparency, rectangles inside and past the screen, interlace, local
tables, loop counts, the screen size quirk), mutated or cut, and random
bytes; scanned whole or in two to four parts, with or without
nsgif_data_complete, in all nine bitmap formats, with or without a row
span wider than the image and the optional callbacks; then random
prepares, decodes, resets and delay rules. After every call the result,
the info, every frame info, both palettes, the prepare outputs, the
decoded bitmap and the callback counts match the whole of libnsgif in C.
3/3 with the shim-only null pointer test. test_nsgif_decode_rust runs the
thirty-nine cmocka cases against the shims without any libnsgif C.

port_comparison (M1 Max, five 1920x1080 frames scanned and decoded through
the API, Rust on Rust, C on C, three runs): 49.3 to 50.6 ms, C 53.0 to
54.4 ms.

Refs #2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Windows Rust build of libobs (rust/obs-build) gave the C group
libobs.nsgif /wd4244 /wd4267. #2510 moves gif.c.h to the ported group
libobs.ported-nsgif-gif, which is not in that build target (the hybrid
takes libnsgif from Rust), and the build refuses options for sources
outside its target ("compiler options refer to sources outside this
target", native_libobs::windows_tests::core_builds_from_the_canonical_manifest
in Rust Tier 2 windows). The other three ported libnsgif groups have no
entry either.

Refs #2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…group

#2528 added test_graphics_state_stacks_rust on master with
libobs.nsgif+.h.c, which this PR moves into the Rust staticlib; #2537 then
gave that file MSVC warning options. Drop the file and its MSVC block. Also
drop the two MSVC set_source_files_properties blocks that no longer name a
file (test_sprite_geometry_steps_rust, test_effect_parser_lifecycle_rust).

Co-Authored-By: Zach Vorhies <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Coordinator tick (2026-10-27). This PR is DIRTY against master and its last Windows Tier 2 run failed, so it cannot be queued yet. Both parts are below; the first is mechanical and I resolved it locally to check the shape, the second needs you.

1. Rebase conflict: master moved the bench-unit list into build.rs (#1997).

rust/obs-c-oracle/benches/port_comparison.rs no longer carries a hand-kept mod list plus modules![...]: master's rust/obs-c-oracle/build.rs generates both from the directory (write_port_comparison_units), exactly so two ports touching one file stop colliding. Resolution: take master's port_comparison.rs unchanged. Your port_comparison/gif.rs is picked up by the generator with no edit to any shared file.

2. Rebase conflict: master now links test_graphics_state_stacks_rust on MSVC (#2533).

Master added /FORCE:MULTIPLE /IGNORE:4006 /IGNORE:4075 link options for the LNK2005 duplicate matrix4_* case, which is the very problem the if(NOT MSVC) gate and its "follow-up: restore the Windows run" comment work around. Resolution: keep master's block (so Windows runs the test again) and only remove the ${CMAKE_SOURCE_DIR}/libobs/build/libobs.nsgif+.h.c source, plus its set_source_files_properties entry, since this PR ports that group. That is what you already did for test_sprite_geometry_steps.cmake in this branch.

3. Windows Tier 2 failure (run 40422466703, test_scene_canvas_characterization, SEGFAULT).

error: Required value 'audio_render' for 'test_scene_canvas_char_transition' not found.  obs_register_source failed.
239 - test_scene_canvas_characterization (SEGFAULT)     native-core

The failing test is not one this PR touches, so the first question is whether the ported libobs.ported-nsgif-gif+.h.c wiring in libobs/build/source-sets.json / rust/obs-build/src/platform/libobs_windows.rs changes which test sources register on Windows, or whether this is a master-side flake. Master's last green push run (40461279816, before the #962 CI commits) passed the same test. Please rebase onto current master, then say whether the segfault reproduces on the new head; if it does, it is this PR's and it needs a RED test.

I did not push a rebase: the branch needs a force-push and this session cannot rewrite a remote branch. The resolution above applies cleanly with git rebase --autostash origin/master.

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Two corrections to my comment above, after reading the thread properly.

The Windows failure is not yours. You already diagnosed it at 00:10 and 00:20: test_scene_canvas_characterization crashes in a test from #2508, in both runs, and against the CMake libobs-c-reference suite as well. I should have read the thread before asking you to re-derive it; ignore item 3 of my comment.

Your own note at 22:46 is still open: the rust/README.md row is missing. At head 1479e1e3d, rust/README.md has no row for libobs/graphics/libnsgif/gif.c.h:

$ git show 1479e1e3d:rust/README.md | grep -c "libnsgif/gif.c.h"
0

The branch's only README change against master is the loss of three rows that master gained after you branched (graphics-state-stacks.c.h, output-stop.c.h, canvas-rules.c.h), which a rebase restores, so the row you say was dropped in your rebase is still dropped. A port PR without its README row leaves the port ledger silent about the unit.

The two rebase resolutions in my comment above stand: take master's generated port_comparison.rs, and keep master's MSVC link-options block for test_graphics_state_stacks_rust, dropping only the libobs.nsgif+.h.c source from it. I did the rebase locally to check it applies cleanly and it does.

@vpacher

vpacher commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Thanks, on it. The rebase onto current master is done locally and the force-push comes shortly, after the local Tier 2 run finishes:

  • port_comparison.rs: master's generated version, unchanged (gif.rs is discovered).
  • test_graphics_state_stacks.cmake: master's MSVC link-options block kept; only the libobs.nsgif+.h.c source and its set_source_files_properties entry removed. Also removed: the two MSVC set_source_files_properties blocks in test_sprite_geometry_steps.cmake and test_effect_parser_lifecycle.cmake that no longer named a file.
  • rust/README.md: the libobs/graphics/libnsgif/gif.c.h row is back, in the port commit where it was before the rebase onto obs-graphics: Port the graphics state stacks (#2517, fixes #2519) #2528. With the rebase, the README diff against master is that one row only.

@vpacher
vpacher force-pushed the port/2510-gif-state branch from 1479e1e to 4261f81 Compare October 27, 2026 08:46
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
@vpacher
vpacher removed this pull request from the merge queue due to a manual request Oct 27, 2026
… data

Two defects in render::gif_parity::api (#2510), both from random seeds:

- A mutated logical screen descriptor can ask the bitmap callback for up
  to 65535 x 65535 pixels. cb_create allocated and filled that (17 GB),
  for the C and the Rust decoder. This starved the 16 GB CI runners:
  all three Fast Gate exit-143 runner losses of this PR (runs
  40380261405 attempts 1 and 2, merge queue run 40478704942). With a
  6 GB limit, 3 of 10 runs were OOM-killed. cb_create now returns NULL
  above 4 M pixels (16 MiB), as an out-of-memory host does; both sides
  get the same callback.

- After a scan that stops inside a frame's local colour table,
  nsgif_local_palette in C decodes the table from past the end of the
  data (buf_len); the Rust decodes only the bytes in the data. This is
  an intentional difference (OBS does not call nsgif_local_palette).
  The views now compare, for frames at or after frame_count, only
  whether there is a local palette and its size. The shrunk case is
  kept in proptest-regressions/gif_parity.txt; rust/README.md lists the
  difference.

Verified: the saved case passes; 50 runs (150 000 random cases) pass,
maximum resident size 154 MB; obs-tests-graphics 420/420; clippy clean.

Refs #2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher

vpacher commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

I removed this PR from the merge queue and cancelled queue run 40478704942. Its Fast Gate runner died in the unit tests (exit 143), and the cause is this PR's own test, not GitHub. New head 8653afd4a:

  • Runner losses. In render::gif_parity::api, a mutated logical screen descriptor can ask the test's bitmap callback for up to 65535 x 65535 pixels. The callback allocated and filled that (17 GB), for both decoders, which starved the 16 GB runner. This caused all three exit-143 Fast Gate losses of this PR (run 40380261405 attempts 1 and 2, and the queue run). In about 100 Fast Gate runs of the last three days, no other PR had one. With a 6 GB limit on CT104, 3 of 10 runs were OOM-killed. Fix: the callback returns NULL above 4 M pixels (16 MiB), as an out-of-memory host does; both sides get the same callback.
  • A rare parity mismatch (about 1 seed in 50), found while verifying the fix. After a scan that stops inside a frame's local colour table, nsgif_local_palette in C decodes the table from past the end of the data; the Rust decodes only the bytes in the data. This is an intentional difference (OBS does not call nsgif_local_palette), now excluded in the test, listed in the test header and in rust/README.md. The shrunk case is kept in proptest-regressions/gif_parity.txt.

Verified: 50 runs (150 000 random cases) pass, maximum resident size 154 MB; obs-tests-graphics 420/420; clippy clean. Before the push, CT104 ran the full CMake build and the 580 cmocka tests against libobs-c-reference and the hybrid libobs; the only failures were environment ones (VA-API, xvfb deinterlace timeouts, one pipewire flake that also fails on the C reference).

Separately, the queue stall: the dead job stayed in_progress with no retry, and only the job timeout-minutes: 60 or the queue check_response_timeout_minutes: 120 would have ended it. I will put that in a CI issue with the rest of the CI-time data.

@zackees
zackees enabled auto-merge October 27, 2026 10:12
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit e406c6f Oct 27, 2026
38 checks passed
@zackees
zackees deleted the port/2510-gif-state branch October 27, 2026 10:54
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Done in obs-rust Multiview Oct 27, 2026
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
…dle (obs-rust#2538) (obs-rust#2540)

On macOS, find_libobs_data_file() built the path from
[NSBundle bundleWithIdentifier:@"com.obsproject.libobs"]. When libobs is
loaded from a libobs.framework with no bundle identifier (no
Info.plist), the bundle is nil, the path string is nil and
strlen(libobsDataPath.UTF8String) is strlen(NULL): the first
obs_find_data_file() call crashed.

The macOS Rust Tier 2 stage "Cargo [obs-c-reference] unchanged ctest
suite" runs the cmocka tests against such a framework (obs-build makes
it without an Info.plist), so test_obs_core_info_characterization
(test_find_data_file) crashed there with SIGSEGV.

Now the function returns NULL when the bundle or its path is not found,
and obs_find_data_file() searches the data paths, as on Linux and
Windows. With the bundle present, nothing changes.

RED: master's macOS Rust Tier 2 cargo stage (two runs of obs-rust#2514), and
locally test_obs_core_info_characterization against a libobs.framework
without Info.plist: SIGSEGV in test_find_data_file. GREEN: the same
framework 8/8; the CMake libobs-c-reference and hybrid frameworks 7/8
plus the macOS skip, as before (5 runs each).

Fixes obs-rust#2538

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

rust: Port the libnsgif state machine and public API (graphics/libnsgif/gif.c.h) to obs-graphics (libnsgif slice 2c)

2 participants