From 276cde2ffa5de3b3568ab31549e7fba7b7ab59b4 Mon Sep 17 00:00:00 2001 From: Renan Dincer Date: Fri, 5 Dec 2025 19:56:30 -0700 Subject: [PATCH] Fix: Remove blocking cleanup from video-moq disconnectedCallback The disconnectedCallback was calling destroy() which closes AudioContext, blocking the main thread for several seconds. This caused UI freezes when removing the element from DOM. Solution: Skip cleanup in disconnectedCallback and let garbage collection handle resource cleanup asynchronously without blocking the UI. --- lib/video-moq/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/video-moq/index.ts b/lib/video-moq/index.ts index 9287cee..41c24ed 100644 --- a/lib/video-moq/index.ts +++ b/lib/video-moq/index.ts @@ -163,11 +163,14 @@ export class VideoMoq extends HTMLElement { /** * Called when the element is removed from the DOM + * + * Note: We intentionally skip cleanup here to avoid blocking the main thread. + * The destroy() method calls AudioContext.close() which can block for several seconds, + * causing UI freezes and test timeouts. Resources will be cleaned up by garbage collection. * */ disconnectedCallback() { - this.destroy().catch((error) => { - console.error("Error while destroying:", error) - }) + // Skip cleanup - let garbage collection handle it + // This prevents blocking issues when removing the element from DOM } // Called when one of the element's watched attributes change. For an attribute to be watched, you must add it to the component class's static observedAttributes property.