Cap icon indicating copy to clipboard operation
Cap copied to clipboard

[Bug/UX]: Main Window opens and activates Webcam automatically after closing the Screenshot Editor

Open dennyschroeder opened this issue 6 months ago • 2 comments

Important Update & Steps to Reproduce (Tested with "Always show Dock icon" disabled)

I have deep-dived further into this bug and attached a new screenshot of my settings to prove that I have "Always show Dock icon" disabled. Despite this setting being OFF and restarting the app entirely, the broken window lifecycle persists.

Here is a critical real-world scenario I just encountered that showcases how disruptive this laggy behavior is:

  1. I finished a screenshot, copied it, and closed the Editor.
  2. The Main Window forced itself open automatically.
  3. I immediately clicked the red "X" to close it because I wanted to continue working in another app.
  4. The Glitch: Because the webcam initialization takes a split second to load in the background, the circular video preview spawned and stayed active on my screen after I had already closed the Main Window and switched to another software.
  5. The camera preview got stuck as a "ghost window". To get rid of it, I had to manually trigger "Open Main Window" from the Menubar a second time and close it again to force the webcam preview overlay to finally terminate.

Why this matters: This confirms that the app is completely losing track of its window and hardware states when forcing the Main Window open after a screenshot. It leads to heavy lag, unintended webcam activations, and ghost overlays popping up when the user is already focusing on something else.

Please consider adding a permanent toggle to never automatically launch the Main Window / Webcam after closing an editor view, allowing Cap to remain strictly and silently in the background Menubar. Thanks, Denny

dennyschroeder avatar May 21 '26 17:05 dennyschroeder

CAP-724

linear[bot] avatar May 21 '26 17:05 linear[bot]

Some context from the codebase that might help here:

The auto-open behavior is triggered by restore_main_windows_if_no_editors() in apps/desktop/src-tauri/src/lib.rs:5107. When any editor (video or screenshot) closes, this function checks if there are other editors still open. If not, it automatically shows the Main window and calls restore_main_window_inputs() followed by restore_camera_window(), which is what triggers the webcam initialization.

The call chain when closing a Screenshot Editor:

  1. CapWindowId::ScreenshotEditor Destroyed event fires (lib.rs:4725)
  2. restore_main_windows_if_no_editors() is called (lib.rs:4743)
  3. If no other editors are open, it shows Main window and calls restore_camera_window() (lib.rs:5117-5122)
  4. restore_camera_window() (lib.rs:5136) spawns an async task that shows the camera window if selected_camera_id is set

The "ghost window" issue you're seeing (camera preview staying visible after closing Main window) likely relates to a race condition in restore_main_window_inputs() (apps/desktop/src-tauri/src/windows.rs:284). This function spawns the camera window at line 374 (show_camera_window_unlocked) before the camera feed is fully initialized, and if you close the Main window during that brief init period, the camera window creation continues in the background and eventually appears.

Related issues:

  • #1859 - Tracks the related problem of Cap staying in Cmd+Tab after closing Main window
  • #1843 - The "Always show Dock icon" setting issue you mentioned
  • #1860 - Your feature request for customizable "After Capture" behaviors for screenshots, which would address the root cause by letting users skip the Editor entirely

The toggle you're requesting (to never auto-launch Main Window/Webcam after closing an editor) would likely require modifying restore_main_windows_if_no_editors() to check a new setting before proceeding with the auto-show logic. Alternatively, implementing #1860's "After Capture" behaviors could provide a more comprehensive solution.

tembo[bot] avatar May 21 '26 17:05 tembo[bot]