Repository navigation
feat: use a picture instead of a webcam - #4465
richiemcilroy wants to merge 6 commits into
Conversation
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 12 credits · Review details |
| /// A still picture, relative to the project, shown where the camera would | ||
| /// be in a recording that has no camera track. It sits outside `camera` | ||
| /// so presets and style segments, which copy `camera` whole, never carry | ||
| /// one project's picture into another. | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub camera_picture: Option<String>, |
There was a problem hiding this comment.
preset_config saves camera_picture, but with_preset does not preserve the current project's value. Applying an older or built-in preset therefore removes the chosen picture. A default preset also removes the picture that finalize_studio just saved.
Exclude cameraPicture from saved presets and preserve the current project's value when applying them.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/project/src/configuration.rs
Line: 3229-3234
Comment:
**Presets remove the picture**
`preset_config` saves `camera_picture`, but `with_preset` does not preserve the current project's value. Applying an older or built-in preset therefore removes the chosen picture. A default preset also removes the picture that `finalize_studio` just saved.
Exclude `cameraPicture` from saved presets and preserve the current project's value when applying them.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let path = project_path.join(relative); | ||
| let frame = match decode_camera_picture(&path) { |
There was a problem hiding this comment.
Projects can read outside images
relative comes from the saved cameraPicture field, but this join accepts absolute paths and ... A crafted project without a camera track can make the renderer read an image outside the project and include it in exported frames.
Reject paths that resolve outside the project, including links that point outside it.
How this was verified: Opening a project loads cameraPicture without a path check, and the export passes it to this loader and then to the camera layer.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/rendering/src/camera_picture.rs
Line: 38-39
Comment:
**Projects can read outside images**
`relative` comes from the saved `cameraPicture` field, but this join accepts absolute paths and `..`. A crafted project without a camera track can make the renderer read an image outside the project and include it in exported frames.
Reject paths that resolve outside the project, including links that point outside it.
**How this was verified:** Opening a project loads `cameraPicture` without a path check, and the export passes it to this loader and then to the camera layer.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let picture_aspect = feeds | ||
| .read(cx) | ||
| .camera_picture | ||
| .as_ref() | ||
| .map(|picture| picture.aspect()); |
There was a problem hiding this comment.
Linux loses the picture position
Picture-only Studio recordings cannot save the bubble's position on Linux. studio_snapshot gets Linux bounds through recording_snapshot, which requires frame_dims from a delivered camera frame. A picture supplies no such frame, so no placement is saved and the editor falls back to its camera position.
Use the picture dimensions when taking this snapshot.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/camera_window.rs
Line: 1983-1987
Comment:
**Linux loses the picture position**
Picture-only Studio recordings cannot save the bubble's position on Linux. `studio_snapshot` gets Linux bounds through `recording_snapshot`, which requires `frame_dims` from a delivered camera frame. A picture supplies no such frame, so no placement is saved and the editor falls back to its camera position.
Use the picture dimensions when taking this snapshot.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| /// Normalizes `source` into the project, returning the path to store in | ||
| /// `ProjectConfiguration::camera_picture`. |
There was a problem hiding this comment.
These descriptions repeat the function names and visible code. AGENTS.md requires comments to explain non-obvious context and explicitly bans narrating what code does. The same pattern appears above select_or_choose and load.
Remove these descriptions or keep only the parts that explain a real constraint. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/camera_picture.rs
Line: 145-146
Comment:
**Comments repeat the code**
These descriptions repeat the function names and visible code. `AGENTS.md` requires comments to explain non-obvious context and explicitly bans narrating what code does. The same pattern appears above `select_or_choose` and `load`.
Remove these descriptions or keep only the parts that explain a real constraint. This repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| if let Ok(entries) = std::fs::read_dir(&dir) { | ||
| for entry in entries.flatten() { | ||
| if entry.path() != destination { | ||
| let _ = std::fs::remove_file(entry.path()); |
There was a problem hiding this comment.
Pending imports can delete the active recording picture
Medium Severity
With picture A selected, choose B and start a Studio recording while normalization is pending. Startup never checks picking_camera_picture, so it retains A's path. This cleanup deletes A, then choose discards B because can_change is now false. Feeds and the restart configuration still reference the deleted file; restarting or making the next recording fails the picture copy and silently omits the picture. Retire the previous file only after the replacement is accepted, or block recording startup until import completes; a rejected import must preserve the selected asset.
| Some(( | ||
| XY::new(picture.width(), picture.height()), | ||
| picture, | ||
| segment_frames.recording_time, |
There was a problem hiding this comment.
Replacing a picture leaves the paused preview showing the old image
Medium Severity
CameraLayer::prepare and prepare_with_encoder treat equal recording timestamps as identical frames even when frame storage changes. Replacing a picture while an ordinary Studio recording is paused supplies a new decoded image with the same timestamp here, so the layer skips uploading it and continues displaying the old texture until playback or seeking. The settled-preview reset does not rescue normal recordings: it is gated on the optional display-source.mp4 retained by certain imports. Invalidate the camera frame cache when the picture changes, or make still-frame upload identity independent of the recording timestamp in both preparation paths.

Use a picture instead of a webcam. Pick it from the camera menu or straight from the camera bubble, record with it, or add one in the editor to a recording made without a camera.
Stacked on #4462 (camera toolbar hints), which gives the new bubble buttons their hints.
Switch from the bubble
Camera, then Use a picture, then Change picture / Use your camera:
Camera menu
The same choice is in the recording picker's camera menu. The picture replaces the camera (and the other way round), the pill reads On, and no camera permission is needed.
Recording with it
A real 5 s Studio recording with the picture and no camera device. The project has only
display.mp4, no camera track, andcameraPictureset:Exported frame:
A recording made without a camera (on main the Camera tab is disabled for these):
How it works
apps/desktop-gpui/src/camera_picture.rs): EXIF orientation applied, transparency flattened onto white, scaled to at most 1024 px, saved as JPEG. Nothing heavy happens while recording.cameraPicturewith the bubble's shape and position, blur off.crates/rendering/src/camera_picture.rs):RenderVideoConstants::camera_picturedecodes the file once and hands the camera layer one shared frame, so the layer's storage-identity check uploads it to the GPU once. It applies only when the recording has no camera track, and the per-frame background blur is skipped for it. Editor preview, export and every othercap-renderingcaller get it with no decoder changes.ProjectConfiguration::camera_picturesits outsidecamera, so presets and style segments (which copycamerawhole) never carry one project's picture into another.All new strings are translated in every catalog.
Fix picture preservation and project path checks before merging, and satisfy the repository's comments policy.
Findings
Fix with agent prompt
Summary
Adds still pictures as an alternative to a webcam.
Reviews (1) · Last reviewed commit: "feat: switch between camera and picture ..." · Reviewed by Greptile