Skip to content

image-source: Read the sub-second file time on Windows too - #565

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

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

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Description

On Windows, an Image source now also reloads an image replaced by one of the same size within the same second. #548 fixed that on Linux and macOS by comparing the sub-second part of the file's modification time, but on Windows os_stat() reports whole seconds only.

On Windows the source now reads the file's last write time and size with GetFileAttributesExW() (100 ns ticks), in a Windows-only plugins/image-source/image-file-version-win32.c, and converts them with image_file_version_from_filetime(), plain arithmetic built on every platform. Linux and macOS keep using stat() as before.

  1. test/cmocka: Add failing test for the image file time on Windows: adds image_file_version_from_filetime() with a stub that keeps whole seconds only (what Windows gets today), and test_image_file_version_filetime, built on every platform. The cases are:
    • write times 0.4 s apart in the same second: different versions (fails today);
    • the sub-second part is kept to the 100 ns tick (fails today);
    • controls: whole seconds convert to the Unix time stat() reports; a real file is read with image_file_version_get() (on Windows through the new code).
  2. image-source: Read the sub-second file time on Windows too: the fix, and the Windows file in the plugin and in the test. 4 of 4 pass.

Motivation and Context

Fixes #564, a follow-up to #548 (upstream obsproject/obs-studio#10700, reported by chocobclyn on Windows 11).

Not run on Windows. We have no Windows machine. The conversion is tested on Linux, and the Windows file was checked for syntax with clang against the documented Win32 declarations only. ci/ci_scope.py selects the Windows Tier 2 lane for this change (image-file-version-win32.c), which builds cmocka-tests and so compiles and runs the Windows code through test_image_file_version_filetime in both libobs modes; the Windows OBS app build (which also compiles the plugin) runs at the release gate or with ci-full.

How Has This Been Tested?

Both libobs lanes (ENABLE_RUST_LIBOBS OFF and ON) on Linux, on current master:

  • test_image_file_version_filetime: 2 of 4 fail at the RED commit, 4 of 4 pass at GREEN in each lane; test_image_file_version (the image-source: Reload an image replaced within the same second #548 test): 5 of 5.
  • Full ctest at GREEN: 163 of 163 in each lane, with only the known open_crashes_without_obs_core case skipped.
  • clang-format and gersemi 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 13:01
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Verified locally (Tier 2 OFF and ON):

  • RED 319b4ec: test_image_file_version_filetime fails sub_second_part_is_kept and same_second_write_times_differ
  • GREEN ac25111: 168/168
  • The Windows-only reader (image-file-version-win32.c) is only compiled by CI's Windows build; the conversion it uses is what the test covers here.
  • Rebased on master, local gate passed; pushed as d224e9b.

rdoupe and others added 2 commits October 13, 2026 06:30
The Image source loads its file again when it changed, and since the fix
for images replaced within the same second it compares the sub-second
part of the modification time. On Windows, though, libobs's os_stat()
reports whole seconds only (it copies _wstat's st_mtime), so there an
image replaced by one of the same size within the same second is still
missed. The upstream report of that bug is from Windows 11.

image_file_version_from_filetime() will turn a Windows file time (100 ns
ticks since 1601, as GetFileAttributesExW() reports the last write time)
into the version the source compares. The stub keeps what Windows gets
today: whole seconds only. It is plain arithmetic, so the test runs on
every platform. On master:

  write times 0.4 s apart, same second:  equal versions
  1 234 567 ticks past a second:         sub-second part 0

2 of 4 cases fail. The controls pass: whole seconds convert to the Unix
time stat() reports, and a real file read with image_file_version_get()
(os_stat() here) exists with the right size, and not after it is removed.

Refs obs-rust#564.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Image source compares the sub-second part of its file's modification
time to see an image replaced within the same second, but on Windows
os_stat() reports whole seconds only, so there an image replaced by one
of the same size within the second was still missed.

On Windows, read the file's last write time and size with
GetFileAttributesExW() (100 ns ticks) and convert them with
image_file_version_from_filetime(). Linux and macOS keep using stat().
The Windows file is image-file-version-win32.c, built only on Windows;
test_image_file_version_filetime builds it there too, so the Windows
Tier 2 lane compiles and runs it.

Not run on Windows here: the conversion is tested on Linux, the Windows
file only checked for syntax against the documented Win32 declarations.

Fixes obs-rust#564.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=fc8f579874ba1b2dd4cdfb4de74e09291be92928 secs=319 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791898539,"gate":"rust/all/fmt","host":"linux-x86_64","key":"87b968df0b110b096ec97e01a0960bfc6bce0542d4d6e0a40ac189c49a11cc31","lane":"lint","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":30,"stamp":"3851dc1ec257f61b0d76a75c15e1f73d","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"87b968df0b110b096ec97e01a0960bfc6bce0542d4d6e0a40ac189c49a11cc31","lane":"lint","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":30,"stamp":"d904fae1f49dee06862d987284b4d234","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"40dec6e1e8dd80d2482801eac6c63b70a654f16338ab3fe46fbf803ebb33219d","lane":"rust-test","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":113,"stamp":"64599b0a9818b8c5dcc0d7317376e74f","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"f38ad25cc1e1622e44709951b124bfc3","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"f109089be3e3c35066cb547d226686cc","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"5093fc63f352f08a249c1b3f60e91a4d","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"80805104ad113ee70e08d96ca555398b","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"0674aad3d18cca7af69fd5f9d9d99be2","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"d02db72b60fe700b89dcebef48f87774d2534c037a4801279d4437c7d657d09b","lane":"cross","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":95,"stamp":"2a6eeeb7f1a96b6a1f7b6f7ca2429a0b","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
Ci-Attestation: {"at":1791898539,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"0b5b656ee6028c4c5622474c30a1d21aa3825f31cd0eaa045e9087ce890550c8","lane":"tier2-linux","parents":["a6bc731c9c475ee5763bd439bedf69ee412900fa"],"secs":81,"stamp":"e54a7afdea9a4b09803369e6699d1271","tree":"fc8f579874ba1b2dd4cdfb4de74e09291be92928","v":1,"via":"run"}
@zackees
zackees force-pushed the fix/image-replace-windows branch from d224e9b to 751df1d Compare October 13, 2026 13:35
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Rebased onto master with #571 (the MSVC pragma fix): the earlier Windows Rust failure was master's base_drive.c GCC pragma (C4068 as error), not this PR. RED/GREEN as verified above (test_image_file_version_filetime: RED fails 2, GREEN 168/168).

  • Rebased on master, local gate passed; pushed as 751df1d.

@zackees
zackees merged commit ad98c23 into obs-rust:master Oct 13, 2026
19 checks passed
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 still missed on Windows (follow-up to #548)

2 participants