Skip to content

macOS: main-thread panic in tauri-runtime-wry 2.8.1 freezes Cap mid Instant recording; the crashed recording then can't be recovered or reuploaded #2606

Open

Description

@officialjason

Description

About 45 minutes into an Instant-mode recording (window capture), Cap's main thread panicked and the app froze. Recording and segment upload both stopped at the moment of the panic. The process stayed alive with a frozen UI for about 5 hours, until I force-quit it.

After relaunch, the recording was marked Failed { error: "Recording crashed" }. Clicking Reupload shows "This recording isn't ready to upload yet", and the app offers no way forward. Yet every completed segment on disk was intact. The only damage was one in-progress trailing segment per track.

I think there are two separate problems here.

1. The panic (tauri-runtime-wry 2.8.1)

panic at tauri-runtime-wry-2.8.1/src/lib.rs:3572:38 thread='main': already mutably borrowed: BorrowError
   7: core::cell::panic_already_mutably_borrowed
   8: tauri_runtime_wry::handle_user_message
   9: tauri_runtime_wry::make_event_handler::{{closure}}
  10: <tao::platform_impl::platform::app_state::EventLoopHandler<T> as tao::platform_impl::platform::app_state::EventHandler>::handle_user_events
  11-14: objc2::exception::{try_no_ret, catch, ...}
  15: std::panic::catch_unwind
  16: tao::platform_impl::platform::observer::control_flow_end_handler
  17-28: <unknown>
  29: tao::platform_impl::platform::event_loop::EventLoop<T>::run
  30: tao::event_loop::EventLoop<T>::run
  31: cap_desktop_lib::run::{{closure}}
  • Line 3572 is the windows.0.borrow() in handle_user_message.
  • No Rust frame on the main thread's stack holds a borrow_mut() of the WindowsStore. That suggests the conflicting borrow came from another thread, which matches [bug] WindowsStore can be called outside of main thread, causing crashes due to previous assumptions tauri-apps/tauri#15003 and #14801 (WindowsStore is a RefCell with unsafe impl Send/Sync). Upstream tightened this in refactor: move unsafe send sync impl up to Context tauri-apps/tauri#14805 (merged 2026-07-06). In tauri-runtime-wry 2.12.2 the unsafe impl Send/Sync for WindowsStore lines are gone.
  • Cap 0.6.0 and current main (bd14dcc) both still resolve tauri-runtime-wry 2.8.1.
  • I couldn't reproduce it, so please treat the cross-thread explanation as a likely cause, not a confirmed one.
  • In the ~90 seconds before the panic, nothing was logged except normal Segment uploaded successfully lines. pmset -g log shows no sleep or wake around that time, so I don't think this is Recording crashes when Mac goes to sleep #1055.
  • Follow-on problem: tao's catch_unwind (frame 15) catches the panic, so the process keeps running in a broken state. Because of that, the crash sentinel and recovery didn't run until I force-quit. Exiting, or at least stopping and finalizing the active recording, on a main-thread panic would have saved several hours here.

2. A crashed Instant recording can't be recovered or reuploaded

After relaunch:

  • load_upload_resume_candidate_at changes InProgress to Failed { error: "Recording crashed" } (lib.rs:8644).
  • retry_existing requires local_ready and InstantRecordingMeta::Complete (lifecycle.rs:993, :1013), so Reupload can never proceed.
  • The Instant recovery path refuses any Failed meta with RequiredTrackFailure (recovery.rs:1773). An app crash with intact tracks is therefore handled the same way as a real track failure such as "required audio failed".

On-disk state after the crash:

Track Completed segments Trailing entry Manifest
display 1286, all sizes match the manifest segment_1287 {duration: 0, is_complete: false} + segment_1287.m4s.tmp is_complete: false
audio 891, all sizes match the manifest segment_892 (same pattern) + .m4s.tmp is_complete: false

Concatenating init.mp4 with the completed segments and muxing them with ffmpeg plays the full 44:40 with audio.

A manual recovery that worked. These edits reproduce what a clean stop would have written:

  1. In each track: remove the trailing incomplete entry, move the .m4s.tmp out of the folder, and set is_complete: true and total_duration.
  2. In recording-meta.json: change Failed { error } to Complete { fps: 30, sample_rate: null }, and set sharing from upload.pre_created_video.
  3. In tauri-upload.json: set local_ready: true.

On relaunch, Cap resumed the segment upload by itself, to the original share link. It completed, and cloud verification returned a receipt with fullDecode: true, hasAudio: true and requiredAudioVerified: true. The server-side duration (2680.35 s) matches the local recording exactly.

Suggestion. crashed_and_failed_projects_never_become_automatic_upload_candidates (lib.rs:10730) shows that never uploading these automatically is intentional, and that makes sense. What's missing is a manual, user-initiated "Recover" for crashed Instant recordings:

  • Tell an app crash apart from a track failure, e.g. with a separate Interrupted state.
  • Trim the trailing in-progress segment.
  • Run the existing strict validation (collect_segment_events / validate_recovery_manifests).
  • Mark the recording Complete so that Reupload works.

At the very least, the Reupload dead end should explain what happened and offer to export the local copy.

Reproduction

Not reliably reproducible. Context:

  • Instant mode, window capture of a browser video-call window.
  • The panic came about 45 minutes into the recording, about 92 minutes into the app session. It was the second long Instant recording in a row in that session; the first, about 46 minutes, completed and uploaded fine.
  • Segments were uploading concurrently, as normal for Instant mode.

Additional Context

  • Cap version: 0.6.0
  • Operating system, version: macOS 27.0 (Darwin 27.0.0), Apple Silicon
  • Logs: the panic and backtrace are from cap-desktop.log and panics.log; full logs are available on request.

Activity

  1. linear commented on Oct 15, 2026

    @linear
  2. officialjason commented on Oct 15, 2026

    @officialjason
    Author

    Follow-up: I just noticed apps/desktop-gpui/README.md says the GPUI app ships as Cap from 0.6.1 and the Tauri app last shipped in 0.6.0. So section 1 (the tauri-runtime-wry panic) is probably moot going forward.

    Section 2 looks like it still applies: the GPUI app also turns an interrupted InProgress instant recording into Failed (apps/desktop-gpui/src/recording.rs, "instant recording stopped before completion"), and the shared finalize_instant_output path still refuses Failed metas.

    Happy to retest once 0.6.1 is out.

  3. AatmanAJ commented on Oct 15, 2026

    @AatmanAJ
    Contributor

    Opened #2630 for section 2 on the GPUI side. Recordings marked Failed only because they were interrupted (Tauri's Recording crashed and GPUI's own instant recording stopped before completion) now show up in the Incomplete Recording prompt. Recover runs the normal strict recovery on them, and puts the original label back if that fails. Real track failures are still never reopened. Your on-disk layout (complete segments plus one trailing .m4s.tmp per track) is exactly what its tests reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions