fix: mpv dispose deadlock on wayland

This commit is contained in:
edde746
2026-02-19 22:32:32 +01:00
parent 582809427e
commit ad4b23b18b
2 changed files with 41 additions and 20 deletions
+8 -5
View File
@@ -159,11 +159,9 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
}
}
} else if (strcmp(method, "dispose") == 0) {
if (self->player) {
self->player->Dispose();
// Don't reset player here — stray g_idle callbacks still reference it.
// It will be replaced on next initialize() call.
}
// Disconnect and unregister texture FIRST — this stops Flutter from
// calling populate(), preventing concurrent mpv_render_context_render()
// during player disposal.
if (self->texture) {
mpv_texture_dispose(self->texture);
fl_texture_registrar_unregister_texture(self->texture_registrar,
@@ -171,6 +169,11 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
g_object_unref(self->texture);
self->texture = nullptr;
}
if (self->player) {
self->player->Dispose();
// Don't reset player here — stray g_idle callbacks still reference it.
// It will be replaced on next initialize() call.
}
self->initialized = FALSE;
self->visible = FALSE;
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));