From f5030245e58e6a8621fb586e44b50a89494a7052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Thu, 27 Nov 2025 17:04:55 +0100 Subject: [PATCH] Fix audio AbortError race condition in all generation tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use gr.skip() instead of gr.update() for audio/waveform/duration/seed outputs during the initial "Generating..." status yield. This prevents Gradio's StaticAudio component from starting a fetch that gets aborted when the actual audio path arrives in the second yield. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/ui/tabs/audiogen_tab.py | 26 +++++++++++++------------- src/ui/tabs/jasco_tab.py | 26 +++++++++++++------------- src/ui/tabs/magnet_tab.py | 26 +++++++++++++------------- src/ui/tabs/musicgen_tab.py | 28 ++++++++++++++-------------- src/ui/tabs/style_tab.py | 26 +++++++++++++------------- 5 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/ui/tabs/audiogen_tab.py b/src/ui/tabs/audiogen_tab.py index f84c105..661aca2 100644 --- a/src/ui/tabs/audiogen_tab.py +++ b/src/ui/tabs/audiogen_tab.py @@ -163,21 +163,21 @@ def create_audiogen_tab( if not prompt: yield ( gr.update(value="Please enter a prompt"), - gr.update(), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) return yield ( gr.update(value="🔄 Generating..."), gr.update(visible=True, value=0), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio yet + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) try: @@ -206,10 +206,10 @@ def create_audiogen_tab( yield ( gr.update(value=f"❌ Error: {str(e)}"), gr.update(visible=False), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) generate_btn.click( diff --git a/src/ui/tabs/jasco_tab.py b/src/ui/tabs/jasco_tab.py index c382e0f..ef71284 100644 --- a/src/ui/tabs/jasco_tab.py +++ b/src/ui/tabs/jasco_tab.py @@ -219,21 +219,21 @@ def create_jasco_tab( if not chords: yield ( gr.update(value="Please enter a chord progression"), - gr.update(), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) return yield ( gr.update(value="🔄 Generating..."), gr.update(visible=True, value=0), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio yet + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) try: @@ -270,10 +270,10 @@ def create_jasco_tab( yield ( gr.update(value=f"❌ Error: {str(e)}"), gr.update(visible=False), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) generate_btn.click( diff --git a/src/ui/tabs/magnet_tab.py b/src/ui/tabs/magnet_tab.py index c7516bb..ec52e44 100644 --- a/src/ui/tabs/magnet_tab.py +++ b/src/ui/tabs/magnet_tab.py @@ -186,21 +186,21 @@ def create_magnet_tab( if not prompt: yield ( gr.update(value="Please enter a prompt"), - gr.update(), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) return yield ( gr.update(value="🔄 Generating..."), gr.update(visible=True, value=0), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio yet + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) try: @@ -231,10 +231,10 @@ def create_magnet_tab( yield ( gr.update(value=f"❌ Error: {str(e)}"), gr.update(visible=False), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) generate_btn.click( diff --git a/src/ui/tabs/musicgen_tab.py b/src/ui/tabs/musicgen_tab.py index 5205e2e..1e6a558 100644 --- a/src/ui/tabs/musicgen_tab.py +++ b/src/ui/tabs/musicgen_tab.py @@ -224,11 +224,11 @@ def create_musicgen_tab( if not prompt: yield ( gr.update(value="Please enter a prompt"), - gr.update(), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) return @@ -237,14 +237,14 @@ def create_musicgen_tab( if long_form and duration > 30: status_msg = f"🔄 Long-form generation ({duration}s, may take several minutes)..." - # Update status + # Update status - use gr.skip() for audio to prevent race condition yield ( gr.update(value=status_msg), gr.update(visible=True, value=0), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio yet + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) try: @@ -279,10 +279,10 @@ def create_musicgen_tab( yield ( gr.update(value=f"❌ Error: {str(e)}"), gr.update(visible=False), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) generate_btn.click( diff --git a/src/ui/tabs/style_tab.py b/src/ui/tabs/style_tab.py index 5bcdec9..80e1ba9 100644 --- a/src/ui/tabs/style_tab.py +++ b/src/ui/tabs/style_tab.py @@ -163,21 +163,21 @@ def create_style_tab( if not style_audio: yield ( gr.update(value="Please upload a style reference audio"), - gr.update(), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) return yield ( gr.update(value="🔄 Generating..."), gr.update(visible=True, value=0), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), # Don't update audio yet + gr.skip(), # Don't update waveform + gr.skip(), # Don't update duration + gr.skip(), # Don't update seed ) try: @@ -209,10 +209,10 @@ def create_style_tab( yield ( gr.update(value=f"❌ Error: {str(e)}"), gr.update(visible=False), - gr.update(), - gr.update(), - gr.update(), - gr.update(), + gr.skip(), + gr.skip(), + gr.skip(), + gr.skip(), ) generate_btn.click(