Skip to content

obs-websocket: Label screenshots with the real MIME type - #652

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/ws-screenshot-jpeg-mime-bump
Oct 13, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/ws-screenshot-jpeg-mime-bump

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Description

obs-websocket's GetSourceScreenshot now labels its data URL with the real MIME type. Asking for jpg used to return data:image/jpg;base64,..., which is not a MIME type; it now returns image/jpeg, like jpeg already did. The other format names that are not their own MIME subtype (jfif, ppm, pgm, pbm, ico, cur, xbm, xpm) are fixed the same way. png, bmp and jpeg are unchanged.

  • The label was "image/" plus the requested format name, but the names are Qt image writer names, which are file extensions. Two fork commits: utils: Move the screenshot MIME type into a helper (no change in behaviour) and utils: Label screenshots with the real MIME type, which maps the writer's format names to their registered types and keeps image/ plus the name for anything else. This PR moves the submodule to them, as fix: reject over-deep pre-auth websocket frames #477 did for [crash] obs-websocket: deeply nested JSON/MsgPack payload overflows the stack pre-auth #99.
  • A fixed table and not Qt's MIME database: the database is read from the system's shared-mime-info, and without it every lookup answers application/octet-stream. With an empty XDG_DATA_DIRS, a QMimeDatabase version of this fix fails 4 of these 5 cases.

One commit, because the fix is already merged in obs-rust/obs-websocket#6: it adds test_ws_image_mime and moves the submodule from a4040cb (master's current pin, obs-rust/obs-websocket#9) to 3e46553, the merge of #6 on top of it, so #9 is kept. test_ws_image_mime builds the helper from the plugin source on its own (no libobs, no Qt, no display). Cases:

  • jpg and jfif give image/jpeg;
  • ppm gives image/x-portable-pixmap;
  • ico gives image/vnd.microsoft.icon;
  • guard: jpeg, png and bmp keep image/jpeg, image/png and image/bmp.

A separate RED commit would have had to point the submodule at the fork's helper-only commit (ff19a05), which predates #9 and would have undone it, so the RED run is shown against that commit instead (below).

Motivation and Context

Fixes #523 (upstream obsproject/obs-websocket#1298, reported by cmack on Linux). andrewsoncha (obsproject/obs-websocket#1337, Qt's MIME database) and iibaranov-IG (obsproject/obs-websocket#1354, jpg only) proposed fixes upstream; both are still open. This one covers every format the image writer offers and does not depend on the system's MIME data.

Reproduced in the current release (AppImage 33.0.0-beta6-799), headless over obs-websocket: jpg gives data:image/jpg, ppm gives data:image/ppm, while jpeg, png and bmp are right.

Why this one: wrong output from a documented request, reported by a Linux user. It is clearly a bug (image/jpg is not a registered type), and the fix is small. Demand is low: one reporter, plus the two upstream PRs.

How Has This Been Tested?

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

  • test_ws_image_mime with the submodule at the fork's helper-only commit ff19a05: 4 of 5 fail (the guard passes). At 3e46553: 5 of 5 pass, in both lanes, also with XDG_DATA_DIRS pointing nowhere. It needs no display and no libraries beyond cmocka, so it is registered on every platform.
  • Full ctest at this commit (private Xvfb, system OpenGL module masked as in CI, TMPDIR unset): 185 of 185 in each lane, with every PipeWire and PulseAudio test actually run.
  • clang-format 22.1.3 and gersemi 0.25.0 are clean.

Not tested: a build of OBS with this obs-websocket, taking a screenshot over the wire. The helper is exactly what GetSourceScreenshot uses for the label, and the request is otherwise unchanged.

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 22:53
GetSourceScreenshot labelled its data URL "image/" plus the requested
format name, but the names are Qt image writer names (file extensions),
so "jpg" came back as "data:image/jpg", which is not a MIME type, and
"ppm" as "data:image/ppm". obs-rust/obs-websocket#6 maps the writer's
format names to their registered types with a fixed table (no
dependency on the system's MIME data).

Move the submodule from a4040cb (obs-rust/obs-websocket#9) to 3e46553,
the merge of obs-rust#6 on top of it, and add test_ws_image_mime, which builds
the helper from the plugin source on its own: 4 of 5 cases fail against
the fork's helper-only commit and all 5 pass here.

Reported upstream in obsproject/obs-websocket#1298 by cmack.

Fixes obs-rust#523.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=0bda6cde7d6d43558b289e6a4c5657ba5b79a390 secs=511 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791932642,"gate":"rust/all/fmt","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"7a0219afa75b08288667d44530d9d3dc","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"56712ff4f494234c658dde9bf072511f27f83b32e5258647edaa0960ff822b1e","lane":"lint","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":36,"stamp":"a28fdc6843d0a6a1efb8f56c1c23226c","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0a26a3da188ac6df7cacddf394b31ac8aee4f17722f8fcfb7e16f16c6545607d","lane":"rust-test","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":188,"stamp":"648509e8d3aa287a22e48e49b3d4b8c4","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"7a9f0013c352502c3d51ad804772dad6","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"e20920cba594d6cff6c18eaa58f06dda","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"97a31be153dbb8d7326d6ca770662db7","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"fcccde5645d69a4439666be55bb76a20","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"a281400a7593e0cc03ff5597876b023f","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"31e220a9f75224a0652e009c7cefda6842c7b689923577113c66ea6c038bbc7f","lane":"cross","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"6bbeb0ed509658dbfbb9c9f55bad2381","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
Ci-Attestation: {"at":1791932642,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1b19e58298733d30e063360d21c4f9aada312536ef6a1ce1e471a24ff8dd5d5c","lane":"tier2-linux","parents":["b2557dea89bc3f730d829ca66241fa9e1d46a9aa"],"secs":143,"stamp":"d422d5aa241f41f79924b3f80fbea575","tree":"0bda6cde7d6d43558b289e6a4c5657ba5b79a390","v":1,"via":"run"}
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Verified red → green by compiling test_ws_image_mime against the two fork commits (ubuntu:26.04, g++ + libcmocka):

  • ff19a05 (helper only, old behaviour): 4 FAILED: jpg → image/jpg, jfif → image/jfif, ppm → image/ppm, ico → image/ico; test_unchanged_formats OK.
  • 3e46553 (this PR's pin): 5 PASSED.

Submodule check: 3e46553 descends from master's a4040cb and from the #99 fix 7d89109c9, so nothing is reverted.

  • Rebased on master, local gate passed; pushed as 61338b1.

@zackees
zackees force-pushed the fix/ws-screenshot-jpeg-mime-bump branch from bba1191 to 61338b1 Compare October 13, 2026 23:04
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

The one red check (Rust Tier 2 Windows: test_preview_audio_sources segfaults in obs_shutdown) is master's, not this PR's: #620 enabled that test on Windows and the double-destroy it exposes is being fixed in #653. I'll rebase this onto master once #653 lands and merge when green.

@zackees
zackees merged commit 73f060f into obs-rust:master Oct 13, 2026
21 checks passed
zackees added a commit to ProtonDev-sys/obs-studio that referenced this pull request Oct 15, 2026
obs-rust#652's submodule bump does not compile: RequestHandler_Sources.cpp uses
Utils::ImageFormat::MimeType without including utils/ImageFormat.h, so
every full build fails. Fork PR obs-rust/obs-websocket#10 adds it.

The fork's master also carries the already-merged fork PRs obs-rust#4 (obs-rust#514),

Local-Gate: v1 tree=2c043672b59777c9875e71d75f8962a2fdcb2e27 secs=390 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791938027,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0081647f2e1e319399eadebe73c4c68f82d82cf39f79ff14c6ce573cf603b987","lane":"lint","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":44,"stamp":"d8f293eff24644b378fcc7f31784e730","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0081647f2e1e319399eadebe73c4c68f82d82cf39f79ff14c6ce573cf603b987","lane":"lint","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":44,"stamp":"f941a2368ea561c6cc1dd404c2254082","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"b13eada16907902b0fe80a2fe16e3a0b69505f862a9c2cf24825f5001a0fb44e","lane":"rust-test","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":110,"stamp":"90332b84a5900768164f7d01a143f8d9","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"e3d99bf3954d09c8d88d4448fb238619","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"ba366c0508bf9aaa859018ca425f4155","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"b24b299806567a535ad007d4d651ba6e","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"bcdc3176b3f88ddf85a00b2b33e3f740","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"0a29c50a3e9953e8b80c58d25a705081","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"e53f213473aa96a3b2882f11a7db911cb5cf490f619ab3ed4a39d7155ed11370","lane":"cross","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":73,"stamp":"7df3b007f64dbc45d235c8b685613569","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
Ci-Attestation: {"at":1791938027,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"e892aee0e6c73f12c54e4b950ce1a04d39e07265b66aec3f515500b36ff4f4e2","lane":"tier2-linux","parents":["08483ba1e85e1fd3b79c46a9f9924a968b31a47c"],"secs":163,"stamp":"ea01d6463104759ff9cf3a70a9074f33","tree":"2c043672b59777c9875e71d75f8962a2fdcb2e27","v":1,"via":"run"}
obs-rust#5 (obs-rust#519) and obs-rust#7 (obs-rust#536).
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: obs-websocket: GetSourceScreenshot labels jpg screenshots image/jpg (upstream obsproject/obs-websocket#1298)

2 participants