Skip to content

Fix Gradio UI freezing when switching tabs#548

Merged
neoneye merged 14 commits intomainfrom
fix/settings-tab-hang
Apr 10, 2026
Merged

Fix Gradio UI freezing when switching tabs#548
neoneye merged 14 commits intomainfrom
fix/settings-tab-hang

Conversation

@neoneye
Copy link
Copy Markdown
Member

@neoneye neoneye commented Apr 10, 2026

Summary

  • The Gradio UI froze (100% CPU, browser unresponsive) when clicking any tab (Settings, Advanced, Join the community)
  • Root cause: Gradio 6.11 has a bug where demo.load() with outputs breaks tab switching entirely. Any .load handler that outputs to a component causes an infinite client-side event loop.
  • Fix: Replace all demo_text2plan.load() calls with browser_state.change(), which fires when BrowserState loads from localStorage on page load — same initialization, no .load bug.
  • Additionally fixed .change callbacks that were outputting back to their trigger components (another potential infinite loop source) and removed browser_state from .change outputs.
  • "Open Output Dir" button visibility check moved into the browser_state.change handler since .load can no longer be used.

Changes

  • frontend_single_user/app.py: Replace .load with browser_state.change for settings init, simplify .change callbacks, persist settings to browser_state only on submit/retry

Test plan

  • Tab switching works (Settings, Advanced, Join the community)
  • Settings restore from localStorage on page load
  • Changing settings updates profile display
  • Submit/retry persists settings
  • "Open Output Dir" hidden when service not running

🤖 Generated with Claude Code

The .change callbacks no longer write to browser_state, which could
re-trigger .load and cascade into an infinite loop. Settings are now
persisted to browser_state only on submit/retry, and session_state
is updated immediately on change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neoneye neoneye force-pushed the fix/settings-tab-hang branch from 1962761 to e2411f3 Compare April 10, 2026 12:05
neoneye and others added 13 commits April 10, 2026 14:08
All components hidden except a placeholder markdown.
If the tab still hangs, the issue is outside the Settings tab.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
If tabs still hang, the issue is in the UI components or Gradio itself.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Testing if the hang is caused by .load or by .change callbacks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Testing if outputting to radio/textbox components from .load causes hang.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Testing if a single .load is fine on its own.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Testing if .load itself causes the hang regardless of what it does.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Testing if any .load output causes hang, or only specific components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Gradio 6.11 .load with outputs breaks tab switching.
BrowserState fires .change when it loads from localStorage,
so we can use that to restore settings instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root cause: Gradio 6.11 .load with outputs breaks tab switching.
Fix: use browser_state.change for settings initialization instead.
All Settings tab components, Examples, .change callbacks, and purge
button restored. Zero .load handlers used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Moved the runtime visibility check into initialize_browser_settings
since .load handlers can no longer be used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neoneye neoneye changed the title Fix Settings tab freezing browser Fix Gradio UI freezing when switching tabs Apr 10, 2026
@neoneye neoneye merged commit 8645d55 into main Apr 10, 2026
3 checks passed
@neoneye neoneye deleted the fix/settings-tab-hang branch April 10, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant