Skip to content

fix: prevent infinite resize loop when footer_links=[] on HuggingFace Spaces#13017

Closed
Ker102 wants to merge 1 commit intogradio-app:mainfrom
Ker102:fix/fill-height-infinite-growth
Closed

fix: prevent infinite resize loop when footer_links=[] on HuggingFace Spaces#13017
Ker102 wants to merge 1 commit intogradio-app:mainfrom
Ker102:fix/fill-height-infinite-growth

Conversation

@Ker102
Copy link
Copy Markdown

@Ker102 Ker102 commented Mar 13, 2026

Summary

Fixes #12992fill_height=True combined with footer_links=[] causes the interface to grow infinitely on HuggingFace Spaces.

Root Cause

handle_resize() in Blocks.svelte only runs when "parentIFrame" in window (HuggingFace Spaces iframe environment). It calculates box.bottom + footer_height + 32 and calls window.parentIFrame.size(new_height) to tell HF to resize the iframe.

This creates a feedback loop:

  1. ResizeObserver fires → calls handle_resize()
  2. handle_resize() reports height → HF resizes the iframe
  3. Iframe grows → box.bottom increases → ResizeObserver fires again
  4. New height is bigger → reports again → infinite loop

When the footer exists, footer_height is bound to the footer's clientHeight via bind:clientHeight={footer_height}. The footer acts as a stable height anchor — once content + footer height settles, the resize stabilizes. But with footer_links=[], the footer is removed from the DOM entirely ({#if footer_links.length > 0}), footer_height stays at 0, and there's nothing to break the feedback loop.

This explains the behavior reported in #12992:

  • Works locally — no parentIFrame, so handle_resize() is a no-op
  • Works embedded on custom sitesis_embed=true sets fill_height=false
  • Only breaks on HuggingFace SpacesparentIFrame exists and drives the resize

Fix

When fill_height is active and there is no footer (footer_height === 0), skip the parentIFrame.size() call entirely.

This is semantically correct — fill_height means "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 normally
  • fill_height=false, no footer → resize works normally
  • fill_height=false, footer present → completely unaffected

… 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
@pngwn
Copy link
Copy Markdown
Member

pngwn commented Mar 15, 2026

Don’t delete the template.

@pngwn pngwn closed this Mar 15, 2026
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.

"fill_height" makes interface grow to infinite if "footer_links=[]" on Hugging Face.

2 participants