Don't use sync call for notifySwap while exiting. 57/320457/4
authorQiang Ji <qiang.ji@samsung.com>
Fri, 15 Nov 2024 08:38:13 +0000 (16:38 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 18 Nov 2024 02:18:29 +0000 (02:18 +0000)
When webview is exiting, as notifyswap is an async callback,
it maybe called after exiting. We need to avoid this.

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

index 4e465123e6c1de9021b732881ce4c0c656c0ecd2..6bf8b847cf045696ebfdf5ae22de9c45ba48c962 100644 (file)
@@ -377,6 +377,9 @@ Display::~Display() {
 
   if (damage_tracker_)
     damage_tracker_->RunDrawCallbacks();
+
+  client_ = nullptr;
+  LOG(INFO) << " Done";
 }
 
 void Display::Initialize(DisplayClient* client,
@@ -1589,7 +1592,8 @@ void Display::InitDelegatedInkPointRendererReceiver(
 
 #if BUILDFLAG(IS_EFL)
 void Display::NotifySwap(const size_t texture_id, bool sync) {
-  client_->NotifySwap(texture_id, sync);
+  if (client_)
+    client_->NotifySwap(texture_id, sync);
 }
 #endif
 
index d56a2a539bd00d39fb84386ecd53ae6c1d55305f..dae3cf1d8a769fa07621f645347a0eda7030d63e 100644 (file)
@@ -67,6 +67,10 @@ SkiaOutputDeviceOffscreen::SkiaOutputDeviceOffscreen(
 }
 
 SkiaOutputDeviceOffscreen::~SkiaOutputDeviceOffscreen() {
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO);
+  is_destroying = true;
+#endif
   DiscardBackbuffer();
 #if BUILDFLAG(IS_EFL)
   DeleteResizedTextures();
@@ -79,6 +83,10 @@ bool SkiaOutputDeviceOffscreen::Reshape(const SkImageInfo& image_info,
                                         float device_scale_factor,
                                         gfx::OverlayTransform transform) {
   DCHECK_EQ(transform, gfx::OVERLAY_TRANSFORM_NONE);
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (is_destroying)
+    return false;
+#endif
   DiscardBackbuffer();
   size_ = gfx::SkISizeToSize(image_info.dimensions());
   sk_color_type_ = image_info.colorType();
@@ -289,8 +297,14 @@ void SkiaOutputDeviceOffscreen::DeleteResizedTextures() {
                            &(resized_texture_queue_.front()));
     resized_texture_queue_.pop();
   }
+  LOG(INFO) << "Release the texture memory done";
 }
 bool SkiaOutputDeviceOffscreen::NeedSync() {
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Some crash shows notifySwapSync was called while destroying.
+  if (is_destroying)
+    return false;
+#endif
   if (!resized_texture_queue_.empty()) {
     return true;
   }
index e14791eb9630fcd2d102f862c98098525e63a0fa..db8872533b6c272c1dd4eca34e0209efae23d792 100644 (file)
@@ -85,6 +85,7 @@ class SkiaOutputDeviceOffscreen : public SkiaOutputDevice {
   uint64_t backbuffer_estimated_size_ = 0;
 #if BUILDFLAG(IS_TIZEN_TV)
   std::string chipset;
+  bool is_destroying = false;
 #endif
 };
 
index 7e1b8e3bb98e39a8f2b1f7861030f0f2eed57b75..e5ae536b66fb26efa078495b67523680dcc633a9 100644 (file)
@@ -325,6 +325,7 @@ SkiaOutputSurfaceImpl::~SkiaOutputSurfaceImpl() {
                  /*need_framebuffer=*/false);
   // Flush GPU tasks and block until all tasks are finished.
   FlushGpuTasksWithImpl(SyncMode::kWaitForTasksFinished, impl_on_gpu);
+  LOG(INFO) << " Done";
 }
 
 gpu::SurfaceHandle SkiaOutputSurfaceImpl::GetSurfaceHandle() const {