OpenGenerativeUI icon indicating copy to clipboard operation
OpenGenerativeUI copied to clipboard

bug: widget renderer height grows infinitely for viewport-filling content

Open jerelvelarde opened this issue 8 months ago • 0 comments

Bug

The widget renderer iframe keeps expanding vertically when the generated content includes elements that fill available space (e.g. height: 100%, height: 100vh, or canvas elements that scale to their container).

Root Cause

There's a feedback loop between the iframe height and the content height measurement:

  1. Inside the iframe, reportHeight() measures content.offsetHeight and posts it to the parent (widget-renderer.tsx:459-463)
  2. The parent sets the iframe height to e.data.height + 8 — adding 8px padding each cycle (widget-renderer.tsx:576)
  3. If the content has elements that fill available space (common with Canvas/Three.js/SVG visualizations using 100vh or 100%), the content expands to match the now-taller iframe
  4. ResizeObserver fires again, reporting the larger height
  5. Parent adds another +8px → content grows → repeat

The periodic setInterval(reportHeight, 200) running for 15 seconds (widget-renderer.tsx:468-469) accelerates this, causing ~8px growth every 200ms (~600px over the interval lifetime).

Reproduction

Ask the agent to create any visualization that uses viewport-relative or percentage-based heights (e.g. "I want to understand the difference between BFS and DFS. Create an interactive comparison on a node graph."). The widget will visibly expand over time with growing empty space below the actual content.

Possible Fixes

  • Remove the + 8 from the height setter or apply it as CSS padding on the wrapper instead of inflating the measurement
  • Measure scrollHeight of individual children rather than offsetHeight of the container, so the measurement is independent of iframe dimensions
  • Debounce and cap consecutive increases — if the reported height keeps growing without new content changes, stop updating
  • Set max-height or overflow: auto on the iframe content wrapper to prevent viewport-filling elements from driving unbounded growth

jerelvelarde avatar Mar 26 '26 15:03 jerelvelarde