From: Joonbum Ko Date: Wed, 12 Sep 2018 04:13:31 +0000 (+0900) Subject: tpl_vk_wsi_thread: Enhanced thread safety for destroy swapchain. X-Git-Tag: accepted/tizen/unified/20180913.063829~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F188942%2F1;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git tpl_vk_wsi_thread: Enhanced thread safety for destroy swapchain. - If wayland events handled in the event thread during destroy_swapchain, unexpected problem can occur related wayland-tbm. Change-Id: I0b80e2784f8a51590ad238ffb63dcc783db2f969 Signed-off-by: Joonbum Ko --- diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 2242975..73378d1 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -685,39 +685,45 @@ static tpl_result_t __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) { tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL; tpl_result_t res = TPL_ERROR_NONE; unsigned int ref; TPL_ASSERT(surface); TPL_ASSERT(surface->backend.data); TPL_ASSERT(surface->display); + TPL_ASSERT(surface->display->backend.data); wayland_vk_wsi_surface = (tpl_wayland_vk_wsi_surface_t *) surface->backend.data; - TPL_ASSERT(wayland_vk_wsi_surface); + wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *) surface->display->backend.data; - ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference); - if (ref > 0) { - TPL_LOG_T("WL_VK", - "This swapchain is still valid. | twe_surface(%p)", - wayland_vk_wsi_surface->twe_surface); - return TPL_ERROR_NONE; - } + if (twe_display_lock(wayland_vk_wsi_display->twe_display) == TPL_ERROR_NONE) { + ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference); + if (ref > 0) { + TPL_LOG_T("WL_VK", + "This swapchain is still valid. | twe_surface(%p)", + wayland_vk_wsi_surface->twe_surface); + return TPL_ERROR_NONE; + } - if (wayland_vk_wsi_surface->reset) { - TPL_LOG_T("WL_VK", - "Since reset is in the TRUE state, it will not be destroyed."); - return TPL_ERROR_NONE; - } + if (wayland_vk_wsi_surface->reset) { + TPL_LOG_T("WL_VK", + "Since reset is in the TRUE state, it will not be destroyed."); + return TPL_ERROR_NONE; + } - res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); - if (res != TPL_ERROR_NONE) { - TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", - wayland_vk_wsi_surface->twe_surface); - return res; - } + res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); + if (res != TPL_ERROR_NONE) { + TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", + wayland_vk_wsi_surface->twe_surface); + return res; + } - wayland_vk_wsi_surface->tbm_queue = NULL; + wayland_vk_wsi_surface->tbm_queue = NULL; + + twe_display_unlock(wayland_vk_wsi_display->twe_display); + } return TPL_ERROR_NONE; }