Skip to content

Commit 2e46e7f

Browse files
hughesscursoragent
authored andcommitted
fix(sandbox): re-lay out frames Safari 27.0 leaves at 0x0 after client-side navigation (#2442)
Co-authored-by: Cursor <cursoragent@cursor.com> GitOrigin-RevId: 7e37b0e26fb65a85c17f76f7d9820ab4c6ab4b49
1 parent d1b2f3e commit 2e46e7f

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎core/src/user-components/sandbox/SandboxFrame.svelte‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,31 @@
215215
frameWidth: rect ? Math.round(rect.width) : null,
216216
frameHeight: rect ? Math.round(rect.height) : null,
217217
...(collapsed ? { collapsedAncestors: describeCollapsedAncestors(frame) } : {}),
218+
...(healAttempts > 0 ? { healAttempts } : {}),
218219
...report
219220
});
220221
}
221222
223+
const MAX_HEAL_ATTEMPTS = 2;
224+
let healAttempts = 0;
225+
226+
// Safari 27.0 can leave a frame inserted by client-side navigation at 0×0 despite a definite height, until a window resize forces a fresh layout.
227+
function healCollapsedFrame(): void {
228+
const frame = iframeEl;
229+
const container = frame?.parentElement;
230+
if (!frame || !container || !frame.isConnected || healAttempts >= MAX_HEAL_ATTEMPTS) return;
231+
const definiteHeight = height ?? (minHeight ? Math.max(minHeight, reportedHeight) : 0);
232+
if (definiteHeight <= 0) return;
233+
if (frame.getBoundingClientRect().height > 0) return;
234+
// Charts inside closed tabs, accordions or other hidden sections are legitimately 0×0.
235+
if (!frame.checkVisibility?.()) return;
236+
healAttempts++;
237+
container.style.display = 'none';
238+
void container.offsetHeight;
239+
container.style.removeProperty('display');
240+
requestAnimationFrame(healCollapsedFrame);
241+
}
242+
222243
function completeRenderTask(): void {
223244
markRenderComplete?.();
224245
markRenderComplete = undefined;
@@ -236,6 +257,7 @@
236257
onError?.(undefined);
237258
onRendered?.();
238259
completeRenderTask();
260+
requestAnimationFrame(healCollapsedFrame);
239261
return;
240262
case 'height': {
241263
// Drop bad payloads (NaN/Infinity/negative/non-number) — they'd

‎core/src/user-components/sandbox/render-diagnostics.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export interface SandboxDiagnosticsReport {
2020
frameHeight: number | null;
2121
/** Set when the iframe lays out at 0×0: its ancestors up to the first one with a real size. */
2222
collapsedAncestors?: string;
23+
/** Set once the parent has forced a fresh layout of a frame that measured 0 tall despite a definite height. */
24+
healAttempts?: number;
2325
metrics: SandboxDiagnosticsMetrics;
2426
}
2527

‎docs/changelog.mdx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ rss: true
77

88
{/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT MODIFY DIRECTLY */}
99

10+
<Update label="November 13, 2026" description="" tags={["Bug Fix"]}>
11+
12+
### 🐛 Recover blank custom charts in Safari 27.0 after sidebar navigation
13+
14+
When Safari 27.0 leaves a custom chart or HTML block blank after you open a report from the sidebar, the chart is now re-laid out automatically instead of waiting for a window resize.
15+
16+
</Update>
17+
1018
<Update label="November 12, 2026" description="" tags={["Bug Fix"]}>
1119

1220
### 🐛 More reliable library imports in HTML blocks

0 commit comments

Comments
 (0)