From ed71e5e0229f2bd25e0ed623cd75e0cef6bc5f93 Mon Sep 17 00:00:00 2001 From: Hitesh Kumar Saini Date: Fri, 4 Aug 2023 02:44:39 +0530 Subject: [PATCH 1/2] fix(windows): memory leak in GetVideoWidth/GetVideoHeight --- media_kit_video/windows/video_output.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/media_kit_video/windows/video_output.cc b/media_kit_video/windows/video_output.cc index bd4e0196f..a122b0167 100644 --- a/media_kit_video/windows/video_output.cc +++ b/media_kit_video/windows/video_output.cc @@ -392,6 +392,7 @@ int64_t VideoOutput::GetVideoWidth() { } } } + mpv_free_node_contents(¶ms); } width = rotate == 0 || rotate == 180 ? dw : dh; @@ -440,6 +441,7 @@ int64_t VideoOutput::GetVideoHeight() { } } } + mpv_free_node_contents(¶ms); } width = rotate == 0 || rotate == 180 ? dw : dh; From 52e2fa5813f9371e81bd6650c1007dec9bbd7123 Mon Sep 17 00:00:00 2001 From: Hitesh Kumar Saini Date: Fri, 4 Aug 2023 02:46:00 +0530 Subject: [PATCH 2/2] fix(linux): GThread* leak in S/W render & video_output_get_(width|height) memory leak --- media_kit_video/linux/video_output.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/media_kit_video/linux/video_output.cc b/media_kit_video/linux/video_output.cc index c445e900e..6da4354c8 100644 --- a/media_kit_video/linux/video_output.cc +++ b/media_kit_video/linux/video_output.cc @@ -192,12 +192,11 @@ VideoOutput* video_output_new(FlTextureRegistrar* texture_registrar, // for slowing the UI thread as little as possible. It's a pity // that software rendering is feeling faster than hardware // rendering due to fucked-up GTK. - g_thread_new( - "mpv_render_context_set_update_callback", - [](gpointer data) -> gpointer { + gdk_threads_add_idle( + [](gpointer data) -> gboolean { VideoOutput* self = (VideoOutput*)data; if (self->destroyed) { - return NULL; + return FALSE; } g_mutex_lock(&self->mutex); gint64 width = video_output_get_width(self); @@ -218,7 +217,7 @@ VideoOutput* video_output_new(FlTextureRegistrar* texture_registrar, FL_TEXTURE(self->texture_sw)); } g_mutex_unlock(&self->mutex); - return NULL; + return FALSE; }, data); }, @@ -313,6 +312,7 @@ gint64 video_output_get_width(VideoOutput* self) { } } } + mpv_free_node_contents(¶ms); } width = rotate == 0 || rotate == 180 ? dw : dh; @@ -362,6 +362,7 @@ gint64 video_output_get_height(VideoOutput* self) { } } } + mpv_free_node_contents(¶ms); } width = rotate == 0 || rotate == 180 ? dw : dh;