浏览代码

fix(tauri-runtime-wry): window draw span not closing (#9718)

* fix(tauri-runtime-wry): window draw span not closing

* use .retain
Lucas Fernandes Nogueira 1 年之前
父节点
当前提交
2eb21378a6
共有 2 个文件被更改,包括 12 次插入10 次删除
  1. 5 0
      .changes/fix-draw-tracing.md
  2. 7 10
      core/tauri-runtime-wry/src/lib.rs

+ 5 - 0
.changes/fix-draw-tracing.md

@@ -0,0 +1,5 @@
+---
+"tauri-runtime-wry": patch:bug
+---
+
+Fixes redraw tracing span not closing.

+ 7 - 10
core/tauri-runtime-wry/src/lib.rs

@@ -248,14 +248,11 @@ pub struct ActiveTraceSpanStore(Rc<RefCell<Vec<ActiveTracingSpan>>>);
 
 #[cfg(feature = "tracing")]
 impl ActiveTraceSpanStore {
-  pub fn remove_window_draw(&self, window_id: WindowId) {
-    let mut store = self.0.borrow_mut();
-    if let Some(index) = store
-      .iter()
-      .position(|t| matches!(t, ActiveTracingSpan::WindowDraw { id, span: _ } if id == &window_id))
-    {
-      store.remove(index);
-    }
+  pub fn remove_window_draw(&self) {
+    self
+      .0
+      .borrow_mut()
+      .retain(|t| !matches!(t, ActiveTracingSpan::WindowDraw { id: _, span: _ }));
   }
 }
 
@@ -2839,8 +2836,8 @@ fn handle_event_loop<T: UserEvent>(
     }
 
     #[cfg(feature = "tracing")]
-    Event::RedrawRequested(id) => {
-      active_tracing_spans.remove_window_draw(id);
+    Event::RedrawEventsCleared => {
+      active_tracing_spans.remove_window_draw();
     }
 
     #[cfg(all(desktop, feature = "global-shortcut"))]