내용으로 건너뛰기

__CAPGO_KEEP_11__

GitHub

__CAPGO_KEEP_2__

__CAPGO_KEEP_3__
__CAPGO_KEEP_4__
npm install @capgo/capacitor-webview-crash
npx cap sync

__CAPGO_KEEP_6__

__CAPGO_KEEP_7__
import { WebViewCrash } from '@capgo/capacitor-webview-crash';
__CAPGO_KEEP_10__

__CAPGO_KEEP_11__

import { WebViewCrash } from '@capgo/capacitor-webview-crash';
await WebViewCrash.addListener('webViewRestoredAfterCrash', async (info) => {
console.log('Recovered after a WebView crash', info);
// Rehydrate critical state, reopen the correct screen, or prompt the user to retry.
await WebViewCrash.clearPendingCrashInfo();
});
await WebViewCrash.addListener('webViewRestoredAfterRestart', async (info) => {
console.log('Recovered after a native WebView restart', info);
await WebViewCrash.clearPendingCrashInfo();
});
const pending = await WebViewCrash.getPendingCrashInfo();
// Note: the listener callback may have already cleared the pending marker.
if (pending.value) {
console.log('Pending crash or restart marker', pending.value);
}

재시작 옵션을 설정하여 capacitor.config.ts 자연스럽게 JavaScript 런타임이 충돌하거나 로드되지 않은 경우에도 code의 결정이 유지되도록 하세요.

import type { CapacitorConfig } from '@capacitor/cli';
import type { WebViewCrashPluginConfig } from '@capgo/capacitor-webview-crash';
const webViewCrash: WebViewCrashPluginConfig = {
// Enabled by default. Keep this on for long-running apps.
restartOnCrash: true,
// Use a 5-field cron schedule in the device local timezone.
// Do not combine restartCron with an active restartIntervalMs.
restartCron: '0 3 * * *',
// Optional delay before restarting after a crash.
restartAfterCrashDelayMs: 0,
};
const config: CapacitorConfig = {
plugins: {
WebViewCrash: webViewCrash,
},
};
export default config;

사용 restartIntervalMs 항상 켜져 있는 앱을 위해 사용하세요. 사용자는 동일한 WebView를 여러 날 동안 열 수 있습니다: 키오스크 화면, 제어실 대시보드, 창고 스캐너, POS 터미널, 차량 태블릿, 디지털 시그니처. 사용 restartCron 벽시계 재시작을 위해 사용하세요. 예를 들어 0 3 * * * 일정 재시작을 위해 03:00에 장치의 지역 시간대에서 재시작을 하세요. 예약된 재시작은 reason: 'periodicRestart', 그리고 Android는 호스트 액티비티를 재생성하고 iOS는 Capacitor 브릿지 뷰를 다시 빌드하여 새로운 WKWebView code에서 생성된

__CAPGO_KEEP_0__ restartCron __CAPGO_KEEP_0__ *__CAPGO_KEEP_0__ restartCron __CAPGO_KEEP_0__ restartIntervalMs __CAPGO_KEEP_0__ 0__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__ restartWebView() __CAPGO_KEEP_0__

await WebViewCrash.restartWebView();

__CAPGO_KEEP_0__ reason: 'manualRestart'code을 재생성하고 새로운 code를 생성하도록 native code에게 요청합니다. Android는 호스트 액티비티를 재생성하고 iOS는 새로운 Capacitor 브릿지 뷰를 재구성하여 새로운 WKWebView 페이지가 대신 로드됩니다.

API 개요

API 개요

getPendingCrashInfo

__CAPGO_KEEP_0__ 개요

__CAPGO_KEEP_0__ 개요 null __CAPGO_KEEP_0__ 개요

const pending = await WebViewCrash.getPendingCrashInfo();
if (pending.value) {
console.log(pending.value.platform, pending.value.reason);
}

clearPendingCrashInfo

__CAPGO_KEEP_0__ 개요

__CAPGO_KEEP_0__ 개요

await WebViewCrash.clearPendingCrashInfo();

simulateCrashRecovery

__CAPGO_KEEP_0__ 개요

__CAPGO_KEEP_0__을 사용하여 QA 및 로컬 디버깅을 위해 실제 WebView가 충돌하지 않도록 recovry 경로를 연습할 수 있도록 가짜 충돌 마커를 생성합니다.

const simulated = await WebViewCrash.simulateCrashRecovery();
console.log(simulated.value);

code에게 새로운 WebView를 생성하기 위해 native를 요청하고, 수동으로 재시작 마커를 저장합니다.

await WebViewCrash.restartWebView();
  • Android는 onRenderProcessGone, didCrash , rendererPriorityAtExit ,
  • ,를 포함하여 제공할 때 플랫폼에서 제공하는 충돌 메타데이터를 저장합니다. iOS는 webViewWebContentProcessDidTerminate __CAPGO_KEEP_0__
  • Capacitor
  • __CAPGO_KEEP_1__ reason: 'periodicRestart'__CAPGO_KEEP_2__ reason: 'manualRestart'.
  • __CAPGO_KEEP_3__

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

PendingCrashInfoResult

__CAPGO_KEEP_6__
export interface PendingCrashInfoResult {
/**
* Stored crash or restart metadata, or `null` when no marker is pending.
*/
value: WebViewCrashInfo | null;
}

WebViewCrashPluginConfig

__CAPGO_KEEP_8__
export interface WebViewCrashPluginConfig {
/**
* Restart the WebView from native code when the renderer process dies.
*
* @default true
*/
restartOnCrash?: boolean;
/**
* Fixed native interval, in milliseconds, for proactively replacing long-running WebViews.
*
* Set to `0` to disable interval restarts. Do not combine an active interval
* with `restartCron`; native initialization fails fast when both schedules are configured.
*
* @default 0
*/
restartIntervalMs?: number;
/**
* Cron schedule for proactively replacing long-running WebViews.
*
* Uses standard 5-field cron syntax in the device local timezone:
* `minute hour day-of-month month day-of-week`.
*
* Examples:
* - `0 3 * * *` restarts every day at 03:00.
* - `0,30 * * * *` restarts every 30 minutes.
*
* Do not combine this with an active `restartIntervalMs`; native initialization
* fails fast when both schedules are configured.
*/
restartCron?: string;
/**
* Delay, in milliseconds, before restarting after a crash.
*
* @default 0
*/
restartAfterCrashDelayMs?: number;
}

WebViewCrashInfo

__CAPGO_KEEP_10__
export interface WebViewCrashInfo {
/**
* Platform that detected and stored the marker.
*/
platform: WebViewCrashPlatform;
/**
* Unix timestamp in milliseconds for when the marker was written.
*/
timestamp: number;
/**
* ISO-8601 version of `timestamp`.
*/
timestampISO: string;
/**
* Platform-specific reason for the crash or restart marker.
*/
reason: WebViewCrashReason;
/**
* Last known WebView URL when the marker was written.
*/
url?: string;
/**
* Android-only hint from `RenderProcessGoneDetail.didCrash()`.
*/
didCrash?: boolean;
/**
* Android-only renderer priority reported at exit.
*/
rendererPriorityAtExit?: number;
/**
* iOS-only application state captured when the WebView process died.
*/
appState?: WebViewCrashAppState;
}

WebViewCrashPlatform

WebViewCrashPlatform 섹션
export type WebViewCrashPlatform = 'android' | 'ios' | 'web';

WebViewCrashReason

WebViewCrashReason 섹션
export type WebViewCrashReason =
| 'renderProcessGone'
| 'webContentProcessDidTerminate'
| 'periodicRestart'
| 'manualRestart'
| 'simulated';

WebViewCrashAppState

WebViewCrashAppState 섹션
export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';

이 페이지는 플러그인의 src/definitions.ts API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

Getting Started에서 계속 진행하세요

Getting Started에서 계속하기

__CAPGO_KEEP_0__이 __CAPGO_KEEP_1__-webview-crash를 사용하는 경우 Getting Started __CAPGO_KEEP_0__이 __CAPGO_KEEP_1__-webview-crash와 연결하기 capgo이 capacitor-webview-crash를 사용하는 경우 capgo이 capacitor-live-activities를 사용하는 경우 capgo이 capacitor-live-activities와 연결하기 capgo이 capacitor-live-activities를 사용하는 경우 capgo이 capacitor-live-activities의 구현 세부 사항 capgo이 capacitor-video-player를 사용하는 경우 capgo이 capacitor-video-player와 연결하기 capgo이 capacitor-video-player를 사용하는 경우 @capgo/capacitor-비디오 플레이어 @capgo/capacitor-비디오 플레이어 구현 세부 사항.