Crash Recovery

Automatically detects if the previous session was killed and restarts at progressively lower quality.

Recovery Flow

  1. On page load: check sessionStorage for previous active state
  2. If active flag set (page didn't clean exit): increment crash counter
  3. Select quality based on crash count: 1 = medium, 2 = low, 3+ = minimal
  4. Start stability timer (default 30 seconds)
  5. If stable: reset crash counter to 0
  6. 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.