Skip to content

Commit 9d868c4

Browse files
Copilotdanmarshall
andauthored
Fix mobile browser tombstoning detection with conservative approach to preserve user state (#90)
* Initial plan * Fix mobile browser tombstoning detection for blob URLs Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com> * Simplify tombstoning detection to avoid sandbox restrictions - Replace direct document access with conservative blob URL detection - Add health check message types to common messages (for future use) - Always recreate blob URL sandboxes on visibility change to ensure mobile tombstoning recovery Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com> * Address feedback: revert UMD file, remove half-implemented healthcheck, make restoration less aggressive Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com> * Make tombstoning detection less aggressive to preserve user state during tab switching Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com> * Revert packages/common/src/messages.ts to remove whitespace changes Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
1 parent 1cd7a45 commit 9d868c4

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

packages/host/src/listener.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,28 +288,31 @@ export class Listener {
288288
}
289289

290290
/**
291-
* Check if the sandbox iframe is still functional by testing if we can access its content window
291+
* Check if the sandbox iframe is still functional
292+
* Conservative approach that only detects clear evidence of tombstoning
292293
*/
293294
private isSandboxFunctional(): boolean {
294-
try {
295-
if (!this.sandbox || !this.sandbox.iframe) {
296-
return false;
297-
}
298-
299-
// Try to access the iframe's content window and check if the src is still valid
300-
const iframe = this.sandbox.iframe;
301-
const contentWindow = iframe.contentWindow;
302-
303-
// If we can't access the content window or the src is invalid, sandbox is not functional
304-
if (!contentWindow || !iframe.src || iframe.src === 'about:blank') {
305-
return false;
306-
}
307-
308-
return true;
309-
} catch (error) {
310-
// If accessing iframe throws an error, it's not functional
295+
if (!this.sandbox || !this.sandbox.iframe) {
296+
return false;
297+
}
298+
299+
const iframe = this.sandbox.iframe;
300+
const contentWindow = iframe.contentWindow;
301+
302+
// Only recreate if we have clear evidence of a broken iframe
303+
// Missing contentWindow is a clear sign of tombstoning
304+
if (!contentWindow) {
305+
return false;
306+
}
307+
308+
// Missing or invalid src indicates a problem
309+
if (!iframe.src || iframe.src === 'about:blank') {
311310
return false;
312311
}
312+
313+
// For normal cases (including blob URLs), assume functional to preserve user state
314+
// Only the clear failures above will trigger recreation
315+
return true;
313316
}
314317

315318
/**

0 commit comments

Comments
 (0)