diff --git a/flutter/lib/models/desktop_render_texture.dart b/flutter/lib/models/desktop_render_texture.dart index 0578bb688..e2bd8e691 100644 --- a/flutter/lib/models/desktop_render_texture.dart +++ b/flutter/lib/models/desktop_render_texture.dart @@ -40,7 +40,7 @@ class _PixelbufferTexture { final ptr = await textureRenderer.getTexturePtr(_textureKey); platformFFI.registerPixelbufferTexture(sessionId, display, ptr); debugPrint( - "create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id"); + "create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id, texturePtr:$ptr"); } }); } diff --git a/src/flutter.rs b/src/flutter.rs index ce706b447..a0600d456 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -330,11 +330,26 @@ impl VideoRenderer { fn register_pixelbuffer_texture(&self, display: usize, ptr: usize) { let mut sessions_lock = self.map_display_sessions.write().unwrap(); if ptr == 0 { + if let Some(info) = sessions_lock.get_mut(&display) { + if info.texture_rgba_ptr != usize::default() { + info.texture_rgba_ptr = usize::default(); + } + #[cfg(feature = "vram")] + if info.gpu_output_ptr != usize::default() { + return; + } + } sessions_lock.remove(&display); } else { if let Some(info) = sessions_lock.get_mut(&display) { - if info.texture_rgba_ptr != 0 && info.texture_rgba_ptr != ptr as TextureRgbaPtr { - log::error!("unreachable, texture_rgba_ptr is not null and not equal to ptr"); + if info.texture_rgba_ptr != usize::default() + && info.texture_rgba_ptr != ptr as TextureRgbaPtr + { + log::warn!( + "texture_rgba_ptr is not null and not equal to ptr, replace {} to {}", + info.texture_rgba_ptr, + ptr + ); } info.texture_rgba_ptr = ptr as _; info.notify_render_type = None; @@ -359,21 +374,34 @@ impl VideoRenderer { pub fn register_gpu_output(&self, display: usize, ptr: usize) { let mut sessions_lock = self.map_display_sessions.write().unwrap(); if ptr == 0 { + if let Some(info) = sessions_lock.get_mut(&display) { + if info.gpu_output_ptr != usize::default() { + info.gpu_output_ptr = usize::default(); + } + #[cfg(feature = "flutter_texture_render")] + if info.texture_rgba_ptr != usize::default() { + return; + } + } sessions_lock.remove(&display); } else { if let Some(info) = sessions_lock.get_mut(&display) { - if info.gpu_output_ptr != 0 && info.gpu_output_ptr != ptr { - log::error!("unreachable, gpu_output_ptr is not null and not equal to ptr"); + if info.gpu_output_ptr != usize::default() && info.gpu_output_ptr != ptr { + log::error!( + "gpu_output_ptr is not null and not equal to ptr, relace {} to {}", + info.gpu_output_ptr, + ptr + ); } info.gpu_output_ptr = ptr as _; info.notify_render_type = None; } else { - if ptr != 0 { + if ptr != usize::default() { sessions_lock.insert( display, DisplaySessionInfo { #[cfg(feature = "flutter_texture_render")] - texture_rgba_ptr: 0, + texture_rgba_ptr: usize::default(), #[cfg(feature = "flutter_texture_render")] size: (0, 0), gpu_output_ptr: ptr,