NotifySwap is called after ~SkiaOutputSurfaceImpl 43/319043/2
authorQiang Ji <qiang.ji@samsung.com>
Mon, 14 Oct 2024 06:39:28 +0000 (14:39 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 15 Oct 2024 03:37:40 +0000 (03:37 +0000)
Add security check to avoid NotifySwap is called after SkiaOutputSurfaceImpl::dtor

Change-Id: I1b1838a0cb38533b4c9a1daa7a7bb49bf1f0dc28
Signed-off-by: Qiang Ji <qiang.ji@samsung.com>
components/viz/service/display_embedder/skia_output_surface_impl.cc

index 145745b1dcbff7dfc9240ccee064ef3cd52ed0ae..7e1b8e3bb98e39a8f2b1f7861030f0f2eed57b75 100644 (file)
@@ -1328,6 +1328,11 @@ void SkiaOutputSurfaceImpl::DidSwapBuffersComplete(
     gfx::GpuFenceHandle release_fence) {
   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
   DCHECK(client_);
+  if (!client_) {
+    LOG(ERROR) << "client is empty, wrong state.";
+    return;
+  }
+
   last_swapped_mailbox_ = params.primary_plane_mailbox;
 
   if (frame_buffer_damage_tracker_ &&
@@ -1350,7 +1355,11 @@ void SkiaOutputSurfaceImpl::DidSwapBuffersComplete(
     client_->DidSwapWithSize(pixel_size);
 #if BUILDFLAG(IS_EFL)
   // we need notify swap for both onscreen and offscreen.
-  client_->NotifySwap(impl_on_gpu_->GetTextureID(), impl_on_gpu_->NeedSync());
+  // impl_on_gpu_ maybe reset in SkiaOutputSurfaceImpl::dtor.
+  if (impl_on_gpu_)
+    client_->NotifySwap(impl_on_gpu_->GetTextureID(), impl_on_gpu_->NeedSync());
+  else
+    LOG(ERROR) << "impl_on_gpu_ is already destroyed.";
 #endif
 }