fix: prevent infinite resize loop when footer_links=[] on HuggingFace Spaces#13017
Closed
Ker102 wants to merge 1 commit intogradio-app:mainfrom
Closed
fix: prevent infinite resize loop when footer_links=[] on HuggingFace Spaces#13017Ker102 wants to merge 1 commit intogradio-app:mainfrom
footer_links=[] on HuggingFace Spaces#13017Ker102 wants to merge 1 commit intogradio-app:mainfrom
Conversation
… Spaces When fill_height=true and footer_links=[] is set, the footer element is removed from the DOM entirely. On HuggingFace Spaces, handle_resize() reports content height to the parent iframe via parentIFrame.size(), which resizes the iframe, triggering another resize event. Without the footer as a stable height anchor, this creates an infinite feedback loop. The fix: when fill_height is active (meaning 'fill available space') and there is no footer, skip reporting height to the parent iframe. This is semantically correct — fill_height should adapt to the parent, not tell the parent to resize. Fixes gradio-app#12992
1 task
Member
|
Don’t delete the template. |
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
Fixes #12992 —
fill_height=Truecombined withfooter_links=[]causes the interface to grow infinitely on HuggingFace Spaces.Root Cause
handle_resize()inBlocks.svelteonly runs when"parentIFrame" in window(HuggingFace Spaces iframe environment). It calculatesbox.bottom + footer_height + 32and callswindow.parentIFrame.size(new_height)to tell HF to resize the iframe.This creates a feedback loop:
ResizeObserverfires → callshandle_resize()handle_resize()reports height → HF resizes the iframebox.bottomincreases →ResizeObserverfires againWhen the footer exists,
footer_heightis bound to the footer'sclientHeightviabind:clientHeight={footer_height}. The footer acts as a stable height anchor — once content + footer height settles, the resize stabilizes. But withfooter_links=[], the footer is removed from the DOM entirely ({#if footer_links.length > 0}),footer_heightstays at 0, and there's nothing to break the feedback loop.This explains the behavior reported in #12992:
parentIFrame, sohandle_resize()is a no-opis_embed=truesetsfill_height=falseparentIFrameexists and drives the resizeFix
When
fill_heightis active and there is no footer (footer_height === 0), skip theparentIFrame.size()call entirely.This is semantically correct —
fill_heightmeans "fill the available space in the parent container", so asking the parent to resize to match the content height is contradictory and creates the feedback loop.Testing
Verified with a simulation test covering 4 scenarios:
fill_height=true, footer_links=[]→ resize loop prevented (0 resize cycles)fill_height=true, footer present→ resize works normallyfill_height=false, no footer→ resize works normallyfill_height=false, footer present→ completely unaffected