Skip to content

image-source: Reload an image replaced within the same second - #548

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/image-replace
Oct 13, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/image-replace

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Description

An Image source now shows the new image when its file is deleted and replaced, or overwritten, within the same second as the version it had loaded. Before, the old image stayed on screen until the file changed again in a later second.

The source checks its file once a second and loads it again when it changed, but compared only the modification time in whole seconds (st_mtime), which both versions share. It now also compares the sub-second part of the modification time where stat() reports it (Linux, macOS, BSDs) and the file size, which also covers Windows' os_stat() and file systems that keep whole or two seconds whenever the new image differs in size.

  1. test/cmocka: Add failing test for an image replaced within a second: moves the check into plugins/image-source/image-file-version.c (image_file_version_get() / image_file_version_equal()), which image-source.c now calls, with no change in behaviour, and adds test_image_file_version. It sets the modification times of real files with utimensat() and compares. The cases are:
    • a new file 0.4 s after the old one, same second, same size: fails today (unchanged);
    • same time, different size: fails today (unchanged);
    • controls: an untouched file is unchanged; a deleted file, and a file created after it, are changes; a missing file stays equal to itself.
  2. image-source: Reload an image replaced within the same second: the fix. 5 of 5 pass.

Motivation and Context

Fixes #547 (upstream obsproject/obs-studio#10700, reported by chocobclyn, who updates an overlay image by deleting and rewriting it).

Reproduced in the current release (AppImage 33.0.0-beta6-799), headless, private config, over obs-websocket (GetSourceScreenshot to read the shown color): a source that has loaded a white image, which is then deleted and replaced by a yellow image of the same size in the same second, still shows white 3.5 s later. Deleting, waiting 2 s and writing a new image works.

A frontend build of this branch (Rust libobs, obs-websocket) shows the same stale white at the RED commit and yellow at GREEN (2 of 2 runs).

Why this one: wrong content on screen with no error, on a common overlay workflow (tools that rewrite an image file), reported by a real user; small fix in the plugin, reproduced in our release.

How Has This Been Tested?

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

  • test_image_file_version: 2 of 5 cases fail at the RED commit and 5 of 5 pass at GREEN in each lane. It needs no graphics and no display, so it runs in CI without skipping; it is not built on Windows (utimensat()).
  • Full ctest at GREEN: 158 of 158 in each lane.
  • clang-format and gersemi (0.25.0) are clean.

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
rdoupe requested a review from zackees as a code owner October 13, 2026 11:34
rdoupe and others added 2 commits October 13, 2026 04:43
An Image source whose file is deleted and replaced by a new file of the
same name, or overwritten, keeps showing the old image when the new file
is written within the same second as the one the source had loaded. In
the current release, a source that has loaded a white image, which is then
deleted and replaced by a yellow one of the same size in that second,
still shows white seconds later (and until the file changes again).

The source checks its file once a second and loads it again when the
modification time changed, but get_modified_timestamp() compared st_mtime,
whole seconds. Both files have the same second.

image_file_version_get() and image_file_version_equal() in
plugins/image-source/image-file-version.c are the helper image-source.c
now uses for that check; the stub keeps the current logic (the
modification time in whole seconds, a missing file distinct from any
other). The test sets the modification times of real files and compares.
On master:

  replaced 0.4 s later, same second, same size:  unchanged
  same time, different size:                     unchanged

2 of 5 cases fail. The controls pass: an untouched file is unchanged, a
deleted file and a file created after it are changes, and a missing file
stays equal to itself.

The test needs no graphics and no display. It uses POSIX utimensat(), so
it is not built on Windows.

Reported upstream by chocobclyn.

Refs obs-rust#547.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Image source checks its file once a second and loads it again when it
changed, but compared only the modification time in whole seconds. A file
deleted and replaced, or overwritten, within the second of the version the
source had loaded looked unchanged, and the old image stayed on screen
until the file changed again.

Compare the sub-second part of the modification time as well, where
stat() reports it (Linux, the BSDs, macOS), and the file size, which also
covers file systems and platforms that keep whole seconds (Windows'
os_stat(), FAT's two seconds) whenever the new image differs in size.

Fixes obs-rust#547.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=879c9baf1ba3b9685560a42330f2918e39f0df95 secs=669 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791892453,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ac70c8c4e606a8c871ed8a54e0156b7f399a959b228232d74159d35dd3c16a3f","lane":"lint","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":42,"stamp":"1e9f900ac379a145039571a622c73611","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ac70c8c4e606a8c871ed8a54e0156b7f399a959b228232d74159d35dd3c16a3f","lane":"lint","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":42,"stamp":"5302b2d797da0164662a2e54d94e2e7b","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"97823c5c2cd77346cb3ee63977b1d299ddcf27bd067e663b9ce2994c57608d94","lane":"rust-test","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":302,"stamp":"5eb4ff0980ae1cea78834e39df642929","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"cedae1e8306c9840793728da404726be","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"e36751ed290d781d6fd1f0ef9a44a9a5","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"25a6e0e973db22eab6b3a2aa41f3bcf9","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"d5a0a64685595fc3c895cdabf9b05a86","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"ba4edfb17305cdb103f2df60da8febd0","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"b775cce1d3f4ec44c4afea21f83ac3e42ebb288457259cc461d7a9e51845d01a","lane":"cross","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":200,"stamp":"b0aa79cfa82d7598015a1d493cf7687d","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
Ci-Attestation: {"at":1791892453,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f6eefdb57bee0343d9a5f15c91c23d7f033d1d7ffa909d487707eae2aaf57e54","lane":"tier2-linux","parents":["e5ad20d5f1d36cead26aee23983191d76b99af5e"],"secs":126,"stamp":"c6418354c8bc9212b2c1f53e5d67da0e","tree":"879c9baf1ba3b9685560a42330f2918e39f0df95","v":1,"via":"run"}
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Verified locally (Tier 2 OFF and ON):

  • RED 0d1903d: test_image_file_version fails replaced_in_same_second_is_changed and same_time_other_size_is_changed
  • GREEN 42fc18c: 162/162
  • Rebased on master, local gate passed; pushed as e1b0a91.

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: image-source: an image replaced within the same second is never reloaded (upstream obsproject/obs-studio#10700)

2 participants