Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
clean up editor on window destruction to avoid race condition causing panic
PJ52afb24dbe93
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex eb9a12f00..d8a1edea1 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -2298,30 +2298,26 @@ pub async fn run() {}).on_window_event(|window, event| {let label = window.label();- if let CapWindow::Editor { project_id } = CapWindow::from_label(label) {- if let WindowEvent::CloseRequested { .. } = event {- let app_handle = window.app_handle().clone();- tokio::spawn(async move {- if let Some(editor) = remove_editor_instance(&app_handle, project_id).await- {- editor.dispose().await;- std::mem::drop(editor);- }-- tokio::task::yield_now().await;- });- }- }-let app = window.app_handle();match event {WindowEvent::Destroyed => {- if let CapWindow::Main = CapWindow::from_label(window.label()) {- if let Some(w) = (CapWindow::Camera { ws_port: 0 }).get(app) {- w.close().ok();+ match CapWindow::from_label(label) {+ CapWindow::Main => {+ if let Some(w) = (CapWindow::Camera { ws_port: 0 }).get(app) {+ w.close().ok();+ }}- }+ CapWindow::Editor { project_id } => {+ let app_handle = app.clone();+ tokio::spawn(async move {+ let _ = remove_editor_instance(&app_handle, project_id).await;++ tokio::task::yield_now().await;+ });+ }+ _ => {}+ };if let Some(settings) = GeneralSettingsStore::get(app).unwrap() {if settings.hide_dock_icon@@ -2375,10 +2371,6 @@ pub async fn remove_editor_instance(None};- if let Some(window) = app.get_webview_window(&format!("editor-{}", video_id)) {- window.close().ok();- }-result}diff --git a/crates/editor/src/editor_instance.rs b/crates/editor/src/editor_instance.rsindex 263b3f929..9573dac53 100644--- a/crates/editor/src/editor_instance.rs+++ b/crates/editor/src/editor_instance.rs@@ -237,6 +237,7 @@ impl EditorInstance {.await;}playback::PlaybackEvent::Stop => {+ // ! This editor instance (self) gets dropped herereturn;}}@@ -285,10 +286,19 @@ impl EditorInstance {).await;}+ // Does the editor instance here (self) get dropped??? I have no idea+ // The task gets cancelled, which should theoretically drop it})}}+impl Drop for EditorInstance {+ fn drop(&mut self) {+ // TODO: Ensure that *all* resources have been released by this point.+ println!("Editor instance {} has been released.", self.id);+ }+}+async fn create_frames_ws(frame_rx: mpsc::UnboundedReceiver<SocketMessage>,) -> (u16, mpsc::Sender<()>) {