From aab0e0bcf795d4efbf406b136093a5baa4c822c5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 13:56:12 +0900 Subject: [PATCH 01/16] Add mutex protection when gsource_destroy Change-Id: I50e841fa3895e6f145249396574e6a8267f1e663 Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 41c5101..51a6dc7 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -161,6 +161,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) tpl_gsource *gsource = (tpl_gsource *)source; gboolean ret = G_SOURCE_CONTINUE; GIOCondition cond = g_source_query_unix_fd(source, gsource->tag); + tpl_gthread *thread = gsource->thread; TPL_IGNORE(cb); @@ -183,7 +184,6 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) gsource->intended_destroy == TPL_TRUE) { tpl_gsource *del_source = (tpl_gsource *)gsource->data; if (!g_source_is_destroyed(&del_source->gsource)) { - tpl_gthread *thread = del_source->thread; g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(del_source); @@ -203,8 +203,10 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) if (gsource->type == SOURCE_TYPE_DISPOSABLE || gsource->type == SOURCE_TYPE_FINALIZER) { + g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(gsource); ret = G_SOURCE_REMOVE; + g_mutex_unlock(&thread->thread_mutex); } return ret; @@ -290,6 +292,9 @@ tpl_gsource_create(tpl_gthread *thread, void *data, int fd, static void __gsource_remove_and_destroy(tpl_gsource *source) { + if (g_source_is_destroyed(&source->gsource)) + return; + TPL_DEBUG("[GSOURCE_DESTROY] tpl_gsource(%p) type(%d)", source, source->type); @@ -301,25 +306,24 @@ __gsource_remove_and_destroy(tpl_gsource *source) void tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) { + tpl_gthread *thread = source->thread; + if (g_source_is_destroyed(&source->gsource)) { TPL_WARN("gsource(%p) already has been destroyed.", source); return; } + g_mutex_lock(&thread->thread_mutex); if (source->type == SOURCE_TYPE_NORMAL && source->finalizer) { tpl_gsource *finalizer = source->finalizer; if (destroy_in_thread) { - tpl_gthread *thread = source->thread; - g_mutex_lock(&thread->thread_mutex); - finalizer->intended_destroy = TPL_TRUE; tpl_gsource_send_message(finalizer, 1); g_cond_wait(&thread->thread_cond, &thread->thread_mutex); - g_mutex_unlock(&thread->thread_mutex); } else { __gsource_remove_and_destroy(finalizer); source->finalizer = NULL; @@ -329,6 +333,7 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) if (!destroy_in_thread) { __gsource_remove_and_destroy(source); } + g_mutex_unlock(&thread->thread_mutex); } void -- 2.7.4 From 5b60b3b5509130d859f9448a37d7d516cf7444d7 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 15:37:10 +0900 Subject: [PATCH 02/16] Clear all cached buffer when queue_force_flush Change-Id: Ic232153cfbdea49aea1a9fd862ac81f673f7814c Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 43342c0..8e633d6 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2259,11 +2259,19 @@ _tbm_queue_force_flush(tpl_wl_egl_surface_t *wl_egl_surface) int i; tpl_wl_egl_buffer_t *wl_egl_buffer = NULL; for (i = 0; i < BUFFER_ARRAY_SIZE; i++) { + buffer_status_t status; tpl_gmutex_lock(&wl_egl_surface->buffers_mutex); wl_egl_buffer = wl_egl_surface->buffers[i]; tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); - if (wl_egl_buffer && wl_egl_buffer->status == COMMITTED) { - wl_egl_buffer->status = RELEASED; + if (wl_egl_buffer) { + tpl_gmutex_lock(&wl_egl_buffer->mutex); + status = wl_egl_buffer->status; + tpl_gmutex_unlock(&wl_egl_buffer->mutex); + } else { + continue; + } + + if (status > ENQUEUED && status <= COMMITTED) { tsq_err = tbm_surface_queue_release(wl_egl_surface->tbm_queue, wl_egl_buffer->tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) @@ -2278,6 +2286,8 @@ _tbm_queue_force_flush(tpl_wl_egl_surface_t *wl_egl_surface) "wl_egl_surface(%p) tbm_queue(%p)", wl_egl_surface, wl_egl_surface->tbm_queue); + _print_buffer_lists(wl_egl_surface); + return TPL_ERROR_NONE; } @@ -3535,6 +3545,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_display_flush(wl_egl_display->wl_display); } + tpl_gmutex_lock(&wl_egl_buffer->mutex); #if TIZEN_FEATURE_ENABLE if (wl_egl_buffer->buffer_release) { zwp_linux_buffer_release_v1_destroy(wl_egl_buffer->buffer_release); @@ -3580,6 +3591,9 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->bo_name = -1; wl_egl_buffer->status = RELEASED; + tpl_gmutex_unlock(&wl_egl_buffer->mutex); + tpl_gmutex_clear(&wl_egl_buffer->mutex); + tpl_gcond_clear(&wl_egl_buffer->cond); free(wl_egl_buffer); } -- 2.7.4 From 9344c0e1889d02135ab6e73a271f9ad933df3039 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 16:31:34 +0900 Subject: [PATCH 03/16] Package version up to 1.8.20 Change-Id: I27eb1758e92fcafa69fd5203fc85fd7cca1d6fac Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 54ce804..71334f1 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 8 -%define TPL_VERSION_PATCH 19 +%define TPL_VERSION_PATCH 20 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 0d43525e605b706edb79ed955ff2ee30b3ffa337 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Jan 2022 16:48:11 +0900 Subject: [PATCH 04/16] Remove finalizer source to before cond_signal Change-Id: Iaeb1b75ecff8860f10f82a21e8ea2be972e70dad Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 51a6dc7..0c3b203 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -187,9 +187,12 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(del_source); + __gsource_remove_and_destroy(gsource); g_cond_signal(&thread->thread_cond); g_mutex_unlock(&thread->thread_mutex); + + return G_SOURCE_REMOVE; } } } @@ -201,8 +204,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) gsource, gsource->fd, cond); } - if (gsource->type == SOURCE_TYPE_DISPOSABLE || - gsource->type == SOURCE_TYPE_FINALIZER) { + if (gsource->type == SOURCE_TYPE_DISPOSABLE) { g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(gsource); ret = G_SOURCE_REMOVE; -- 2.7.4 From bc6617520f099f4d2398472310e000e20711d117 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Jan 2022 16:53:24 +0900 Subject: [PATCH 05/16] Package version up to 1.8.21 Change-Id: I21d36be947889a69c48b7b51c448d95abef6b0c9 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 71334f1..814b85a 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 8 -%define TPL_VERSION_PATCH 20 +%define TPL_VERSION_PATCH 21 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 6cb8c3426bbe2a6c869756dd7ef1b527101334e2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 11 Jan 2022 15:41:03 +0900 Subject: [PATCH 06/16] Call dispatch cb for disposable source when IO error occured. Change-Id: I8a84a32b5c246c65a9b7a3ab5e5bc0e69afe51ae Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 0c3b203..3352a0d 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -202,6 +202,11 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) * There may be problems with the screen, but it does not affect the operation. */ TPL_WARN("Invalid GIOCondition occured. tpl_gsource(%p) fd(%d) cond(%d)", gsource, gsource->fd, cond); + + if (gsource->type == SOURCE_TYPE_DISPOSABLE) { + if (gsource->gsource_funcs && gsource->gsource_funcs->dispatch) + ret = gsource->gsource_funcs->dispatch(gsource, 0); + } } if (gsource->type == SOURCE_TYPE_DISPOSABLE) { -- 2.7.4 From c5d2f6139b2f3d2f6b67e94e238b7baa558d12b1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Jan 2022 17:52:48 +0900 Subject: [PATCH 07/16] Move unref to outside from buffer mutex. Change-Id: If2c0eb9ee17edf6febc830ec058b274b1eba5431 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 8e633d6..d7b730e 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2956,11 +2956,11 @@ __cb_buffer_fenced_release(void *data, tbm_surface = wl_egl_buffer->tbm_surface; if (tbm_surface_internal_is_valid(tbm_surface)) { + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE; tpl_gmutex_lock(&wl_egl_buffer->mutex); if (wl_egl_buffer->status == COMMITTED) { tpl_wl_egl_surface_t *wl_egl_surface = wl_egl_buffer->wl_egl_surface; - tbm_surface_queue_error_e tsq_err; zwp_linux_buffer_release_v1_destroy(wl_egl_buffer->buffer_release); wl_egl_buffer->buffer_release = NULL; @@ -2984,12 +2984,13 @@ __cb_buffer_fenced_release(void *data, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err); - - tbm_surface_internal_unref(tbm_surface); } tpl_gmutex_unlock(&wl_egl_buffer->mutex); + if (tsq_err == TBM_SURFACE_QUEUE_ERROR_NONE) + tbm_surface_internal_unref(tbm_surface); + } else { TPL_ERR("Invalid parameter | tbm_surface(%p)", tbm_surface); } @@ -3007,11 +3008,11 @@ __cb_buffer_immediate_release(void *data, tbm_surface = wl_egl_buffer->tbm_surface; if (tbm_surface_internal_is_valid(tbm_surface)) { + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE; tpl_gmutex_lock(&wl_egl_buffer->mutex); if (wl_egl_buffer->status == COMMITTED) { tpl_wl_egl_surface_t *wl_egl_surface = wl_egl_buffer->wl_egl_surface; - tbm_surface_queue_error_e tsq_err; zwp_linux_buffer_release_v1_destroy(wl_egl_buffer->buffer_release); wl_egl_buffer->buffer_release = NULL; @@ -3033,12 +3034,13 @@ __cb_buffer_immediate_release(void *data, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err); - - tbm_surface_internal_unref(tbm_surface); } tpl_gmutex_unlock(&wl_egl_buffer->mutex); + if (tsq_err == TBM_SURFACE_QUEUE_ERROR_NONE) + tbm_surface_internal_unref(tbm_surface); + } else { TPL_ERR("Invalid parameter | tbm_surface(%p)", tbm_surface); } -- 2.7.4 From 1c7f979934bc8508c879e3bf158885a335cd9198 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 14 Jan 2022 10:51:51 +0900 Subject: [PATCH 08/16] Fixed to use last_enq_buffer instead of last_deq_buffer. - last_deq_buffer has a risk to be free from thread. Change-Id: I677704a5b9bbf8a7c405689663a856d83df595f4 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 52 ++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index d7b730e..18652be 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -116,7 +116,7 @@ struct _tpl_wl_egl_surface { tpl_wl_egl_buffer_t *buffers[BUFFER_ARRAY_SIZE]; int buffer_cnt; /* the number of using wl_egl_buffers */ tpl_gmutex buffers_mutex; - tpl_wl_egl_buffer_t *last_deq_buffer; + tpl_wl_egl_buffer_t *last_enq_buffer; tpl_list_t *presentation_feedbacks; /* for tracing presentation feedbacks */ @@ -1708,7 +1708,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->buffer_cnt = 0; } - wl_egl_surface->last_deq_buffer = NULL; + wl_egl_surface->last_enq_buffer = NULL; { struct tizen_private *tizen_private = NULL; @@ -2145,7 +2145,7 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface) wl_egl_surface->wl_egl_window = NULL; } - wl_egl_surface->last_deq_buffer = NULL; + wl_egl_surface->last_enq_buffer = NULL; wl_egl_surface->wl_surface = NULL; wl_egl_surface->wl_egl_display = NULL; @@ -2442,25 +2442,32 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_surface_h tbm_surface = NULL; TPL_OBJECT_UNLOCK(surface); - if (wl_egl_surface->reset == TPL_TRUE && wl_egl_surface->last_deq_buffer) { - tpl_wl_egl_buffer_t *last_deq_buffer = wl_egl_surface->last_deq_buffer; + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + if (wl_egl_surface->reset == TPL_TRUE && wl_egl_surface->last_enq_buffer) { + tpl_wl_egl_buffer_t *last_enq_buffer = wl_egl_surface->last_enq_buffer; - tpl_gmutex_lock(&last_deq_buffer->mutex); - if (last_deq_buffer->status > ENQUEUED && - last_deq_buffer->status < COMMITTED) { + tpl_gmutex_lock(&last_enq_buffer->mutex); + if (last_enq_buffer->status > ENQUEUED && + last_enq_buffer->status < COMMITTED) { tpl_result_t wait_result; - wait_result = tpl_cond_timed_wait(&last_deq_buffer->cond, - &last_deq_buffer->mutex, + TPL_INFO("[DEQ_AFTER_RESET]", + "waiting for previous buffer(%p) commit", last_enq_buffer); + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + wait_result = tpl_cond_timed_wait(&last_enq_buffer->cond, + &last_enq_buffer->mutex, 200); /* 200ms */ - - if (wait_result == TPL_ERROR_TIME_OUT) + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + if (wait_result == TPL_ERROR_TIME_OUT) { TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", - last_deq_buffer); + last_enq_buffer); + wl_egl_surface->last_enq_buffer = NULL; + } } - tpl_gmutex_unlock(&last_deq_buffer->mutex); + tpl_gmutex_unlock(&last_enq_buffer->mutex); - wl_egl_surface->last_deq_buffer = NULL; } + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + tsq_err = tbm_surface_queue_can_dequeue_wait_timeout( wl_egl_surface->tbm_queue, CAN_DEQUEUE_TIMEOUT_MS); TPL_OBJECT_LOCK(surface); @@ -2552,8 +2559,6 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tpl_gmutex_lock(&wl_egl_buffer->mutex); wl_egl_buffer->status = DEQUEUED; - wl_egl_surface->last_deq_buffer = wl_egl_buffer; - /* If wl_egl_buffer->release_fence_fd is -1, * the tbm_surface can be used immediately. * If not, user(EGL) have to wait until signaled. */ @@ -2614,9 +2619,6 @@ __tpl_wl_egl_surface_cancel_buffer(tpl_surface_t *surface, tpl_gmutex_unlock(&wl_egl_buffer->mutex); } - if (wl_egl_buffer == wl_egl_surface->last_deq_buffer) - wl_egl_surface->last_deq_buffer = NULL; - tbm_surface_internal_unref(tbm_surface); tsq_err = tbm_surface_queue_cancel_dequeue(wl_egl_surface->tbm_queue, @@ -2754,6 +2756,10 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, return TPL_ERROR_INVALID_OPERATION; } + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + wl_egl_surface->last_enq_buffer = wl_egl_buffer; + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + tbm_surface_internal_unref(tbm_surface); TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); @@ -3416,6 +3422,8 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, tpl_gmutex_unlock(&wl_egl_buffer->mutex); + wl_egl_surface->last_enq_buffer = NULL; + TPL_LOG_T("WL_EGL", "[COMMIT] wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p) bo(%d)", wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface, @@ -3522,10 +3530,6 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->idx = -1; } - - if (wl_egl_surface->last_deq_buffer == wl_egl_buffer) - wl_egl_surface->last_deq_buffer = NULL; - tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { -- 2.7.4 From c2dbc7de022374c04af17369be31a2afff53535d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 11 Jan 2022 16:49:33 +0900 Subject: [PATCH 09/16] Package version up to 1.8.22 Change-Id: I0a1ab000f80ab7a3c2aaaab0acfaca6591e95d53 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 814b85a..2400d0a 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 8 -%define TPL_VERSION_PATCH 21 +%define TPL_VERSION_PATCH 22 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From b878cb5845cae4f83baacbff67310fe6319874dc Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 18 Jan 2022 15:17:49 +0900 Subject: [PATCH 10/16] Change the handle of last_enq_buffer to tbm_surface_h - to check validation for the handle of last_enq_buffer. Change-Id: Ib92b28cd3bc6bfa553fb5de57afd9fc8cfcf0cdc Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 18652be..44d8f92 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -116,7 +116,7 @@ struct _tpl_wl_egl_surface { tpl_wl_egl_buffer_t *buffers[BUFFER_ARRAY_SIZE]; int buffer_cnt; /* the number of using wl_egl_buffers */ tpl_gmutex buffers_mutex; - tpl_wl_egl_buffer_t *last_enq_buffer; + tbm_surface_h last_enq_buffer; tpl_list_t *presentation_feedbacks; /* for tracing presentation feedbacks */ @@ -2443,28 +2443,33 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, TPL_OBJECT_UNLOCK(surface); tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - if (wl_egl_surface->reset == TPL_TRUE && wl_egl_surface->last_enq_buffer) { - tpl_wl_egl_buffer_t *last_enq_buffer = wl_egl_surface->last_enq_buffer; - - tpl_gmutex_lock(&last_enq_buffer->mutex); - if (last_enq_buffer->status > ENQUEUED && - last_enq_buffer->status < COMMITTED) { - tpl_result_t wait_result; - TPL_INFO("[DEQ_AFTER_RESET]", - "waiting for previous buffer(%p) commit", last_enq_buffer); - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); - wait_result = tpl_cond_timed_wait(&last_enq_buffer->cond, - &last_enq_buffer->mutex, - 200); /* 200ms */ - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - if (wait_result == TPL_ERROR_TIME_OUT) { - TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", - last_enq_buffer); - wl_egl_surface->last_enq_buffer = NULL; + if (wl_egl_surface->reset == TPL_TRUE && + tbm_surface_internal_is_valid(wl_egl_surface->last_enq_buffer)) { + tpl_wl_egl_buffer_t *enqueued_buffer = + _get_wl_egl_buffer(wl_egl_surface->last_enq_buffer); + + if (enqueued_buffer) { + tpl_gmutex_lock(&enqueued_buffer->mutex); + if (enqueued_buffer->status >= ENQUEUED && + enqueued_buffer->status < COMMITTED) { + tpl_result_t wait_result; + TPL_INFO("[DEQ_AFTER_RESET]", + "waiting for previous wl_egl_buffer(%p) commit", + enqueued_buffer); + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + wait_result = tpl_cond_timed_wait(&enqueued_buffer->cond, + &enqueued_buffer->mutex, + 200); /* 200ms */ + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + if (wait_result == TPL_ERROR_TIME_OUT) { + TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", + enqueued_buffer); + } } + tpl_gmutex_unlock(&enqueued_buffer->mutex); } - tpl_gmutex_unlock(&last_enq_buffer->mutex); + wl_egl_surface->last_enq_buffer = NULL; } tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); @@ -2757,7 +2762,7 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, } tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - wl_egl_surface->last_enq_buffer = wl_egl_buffer; + wl_egl_surface->last_enq_buffer = tbm_surface; tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); tbm_surface_internal_unref(tbm_surface); @@ -3422,8 +3427,6 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, tpl_gmutex_unlock(&wl_egl_buffer->mutex); - wl_egl_surface->last_enq_buffer = NULL; - TPL_LOG_T("WL_EGL", "[COMMIT] wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p) bo(%d)", wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface, -- 2.7.4 From 1b4ee77a5e06d92ece17db7d43dd9de083a24c41 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 18 Jan 2022 11:06:30 +0900 Subject: [PATCH 11/16] Package version up to 1.8.23 Change-Id: I39e166a5eba110731a2a3b5e8fa6a14f7b90bdad Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 2400d0a..96581ed 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 8 -%define TPL_VERSION_PATCH 22 +%define TPL_VERSION_PATCH 23 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From dc23e646d3167b9519486088b514e07dd63f2c3d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 20 Jan 2022 17:16:52 +0900 Subject: [PATCH 12/16] Prevents the incorrect signal on gcond of wl_egl_buffer. As with g_cond_wait() it is possible that a spurious or stolen wakeup could occur. For that reason, waiting on a condition variable should always be in a loop, based on an explicitly-checked predicate. Change-Id: I388e71a48dc91c1636490c856698c4a7f8d3fafd Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 44d8f92..95b9af0 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2449,24 +2449,28 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, _get_wl_egl_buffer(wl_egl_surface->last_enq_buffer); if (enqueued_buffer) { + tbm_surface_internal_ref(wl_egl_surface->last_enq_buffer); + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); tpl_gmutex_lock(&enqueued_buffer->mutex); - if (enqueued_buffer->status >= ENQUEUED && - enqueued_buffer->status < COMMITTED) { + while (enqueued_buffer->status >= ENQUEUED && + enqueued_buffer->status < COMMITTED) { tpl_result_t wait_result; TPL_INFO("[DEQ_AFTER_RESET]", "waiting for previous wl_egl_buffer(%p) commit", enqueued_buffer); - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + wait_result = tpl_cond_timed_wait(&enqueued_buffer->cond, &enqueued_buffer->mutex, 200); /* 200ms */ - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); if (wait_result == TPL_ERROR_TIME_OUT) { TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", enqueued_buffer); + break; } } tpl_gmutex_unlock(&enqueued_buffer->mutex); + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + tbm_surface_internal_unref(wl_egl_surface->last_enq_buffer); } wl_egl_surface->last_enq_buffer = NULL; -- 2.7.4 From e8bb5ba082503aed6f7d41c6b0898d054d729291 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 26 Jan 2022 15:26:31 +0900 Subject: [PATCH 13/16] Initialize last_enq_buffer to null when it committed. - If the last_enq_buffer of wl_egl_surface has been committed, it is not necessary to have this handle pointer. Change-Id: I3153b3cc9cb133f1d51321dc7aaa92f57b1e5ed8 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 95b9af0..f439bd6 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2445,11 +2445,12 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tpl_gmutex_lock(&wl_egl_surface->surf_mutex); if (wl_egl_surface->reset == TPL_TRUE && tbm_surface_internal_is_valid(wl_egl_surface->last_enq_buffer)) { + tbm_surface_h last_enq_buffer = wl_egl_surface->last_enq_buffer; tpl_wl_egl_buffer_t *enqueued_buffer = - _get_wl_egl_buffer(wl_egl_surface->last_enq_buffer); + _get_wl_egl_buffer(last_enq_buffer); if (enqueued_buffer) { - tbm_surface_internal_ref(wl_egl_surface->last_enq_buffer); + tbm_surface_internal_ref(last_enq_buffer); tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); tpl_gmutex_lock(&enqueued_buffer->mutex); while (enqueued_buffer->status >= ENQUEUED && @@ -2470,7 +2471,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, } tpl_gmutex_unlock(&enqueued_buffer->mutex); tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - tbm_surface_internal_unref(wl_egl_surface->last_enq_buffer); + tbm_surface_internal_unref(last_enq_buffer); } wl_egl_surface->last_enq_buffer = NULL; @@ -3426,6 +3427,8 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, wl_egl_buffer->need_to_commit = TPL_FALSE; wl_egl_buffer->status = COMMITTED; + if (wl_egl_surface->last_enq_buffer == wl_egl_buffer->tbm_surface) + wl_egl_surface->last_enq_buffer = NULL; tpl_gcond_signal(&wl_egl_buffer->cond); -- 2.7.4 From 744b882abc193b7c573cdcc3cfd94ebe43e7c2bc Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 26 Jan 2022 16:04:51 +0900 Subject: [PATCH 14/16] Package version up to 1.9.1 - the minor version for tizen_7.0 is '9' Change-Id: I21627d64a70f3d9a137ae73106be90d36328ce03 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 96581ed..ffb86c4 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -3,8 +3,8 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 -%define TPL_VERSION_MINOR 8 -%define TPL_VERSION_PATCH 23 +%define TPL_VERSION_MINOR 9 +%define TPL_VERSION_PATCH 1 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From ad32a58551cc80ef33176ee092b0320ef9f936a5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 15 Feb 2022 14:06:30 +0900 Subject: [PATCH 15/16] Make clear about use_explicit_sync feature flag. - if the boolean flag use_explicit_sync is true, it includes the meaning surface_sync is not null. - so, it need to be simplified with using only use_explicit_sync flag. Change-Id: Icdcc55a76d72b28d9bd38a96de1093ab56edc135 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index f439bd6..b8830a7 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2574,7 +2574,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, * If not, user(EGL) have to wait until signaled. */ if (release_fence) { #if TIZEN_FEATURE_ENABLE - if (wl_egl_surface->surface_sync) { + if (wl_egl_display->use_explicit_sync) { *release_fence = wl_egl_buffer->release_fence_fd; TPL_DEBUG("wl_egl_surface(%p) wl_egl_buffer(%p) release_fence_fd(%d)", wl_egl_surface, wl_egl_buffer, *release_fence); @@ -2869,7 +2869,7 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface) if (wl_egl_buffer->acquire_fence_fd != -1) { #if TIZEN_FEATURE_ENABLE - if (wl_egl_surface->surface_sync) + if (wl_egl_display->use_explicit_sync) ready_to_commit = TPL_TRUE; else #endif @@ -3280,7 +3280,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, #if TIZEN_FEATURE_ENABLE if (!wl_egl_display->use_explicit_sync || - !wl_egl_surface->surface_sync) + wl_egl_buffer->acquire_fence_fd == -1) #endif { wl_buffer_add_listener((struct wl_buffer *)wl_egl_buffer->wl_buffer, @@ -3395,7 +3395,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, wl_egl_buffer->serial); #if TIZEN_FEATURE_ENABLE if (wl_egl_display->use_explicit_sync && - wl_egl_surface->surface_sync) { + wl_egl_buffer->acquire_fence_fd != -1) { zwp_linux_surface_synchronization_v1_set_acquire_fence(wl_egl_surface->surface_sync, wl_egl_buffer->acquire_fence_fd); -- 2.7.4 From faef443a84b61b2676fdc9854212e1f2d5b4e842 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 15 Feb 2022 14:33:26 +0900 Subject: [PATCH 16/16] Package version up to 1.9.2 Change-Id: I3c744d64eaa7bfeb2f4dc00fe813e5de09331901 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index ffb86c4..d4228f2 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 9 -%define TPL_VERSION_PATCH 1 +%define TPL_VERSION_PATCH 2 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4