Fix Gradio UI freezing when switching tabs#548
Merged
Conversation
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>
1962761 to
e2411f3
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
demo.load()with outputs breaks tab switching entirely. Any.loadhandler that outputs to a component causes an infinite client-side event loop.demo_text2plan.load()calls withbrowser_state.change(), which fires when BrowserState loads from localStorage on page load — same initialization, no.loadbug..changecallbacks that were outputting back to their trigger components (another potential infinite loop source) and removedbrowser_statefrom.changeoutputs.browser_state.changehandler since.loadcan no longer be used.Changes
frontend_single_user/app.py: Replace.loadwithbrowser_state.changefor settings init, simplify.changecallbacks, persist settings tobrowser_stateonly on submit/retryTest plan
🤖 Generated with Claude Code