Crash Recovery
Automatically detects if the previous session was killed and restarts at progressively lower quality.
Recovery Flow
- On page load: check
sessionStoragefor previous active state - If active flag set (page didn't clean exit): increment crash counter
- Select quality based on crash count: 1 =
medium, 2 =low, 3+ =minimal - Start stability timer (default 30 seconds)
- If stable: reset crash counter to 0
- If crashes again: counter stays, next load uses lower quality
Configuration
new IframeShield({ crashRecovery: { enabled: true, storageKey: 'iframe-shield-recovery', stabilityPeriodMs: 30000, maxRecoveryAttempts: 3, }, onCrashRecovered: (info) => { console.log('Crash #' + info.recoveryAttempt + ' — quality: ' + info.restoredQuality); }, });
Clean Exit Detection
The system registers beforeunload and pagehide listeners to mark clean exits. If these fire, no crash is detected on the next visit.