시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-webview-crash`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/webview-crash/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치 섹션 제목Capgo의 AI-assisted 설치를 사용하여 플러그인을 설치할 수 있습니다. AI 도구에 Capgo 기능을 추가하려면 다음 명령어를 사용하세요.
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins다음 명령어를 사용하여 플러그인을 설치하세요.
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-webview-crash` plugin in my project.복사
npm install @capgo/capacitor-webview-crashnpx cap syncimport { WebViewCrash } from '@capgo/capacitor-webview-crash';권장 복구 흐름
권장 복구 흐름 섹션 제목앱 시작 시에 가능한 한 빨리 리스너를 첨부하여 사용자가 계속 탐색하기 전에 복구된 런타임이 반응할 수 있도록 하세요.
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 런타임이 충돌하거나 로드되지 않았을 때도 native 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', then Android recreates the host activity and iOS rebuilds the Capacitor bridge view so a new WKWebView , 그리고 Android는 호스트 액티비티를 다시 생성하고 iOS는 code 브릿지 뷰를 다시 빌드하여 새로운
__CAPGO_KEEP_0__에서 생성된 restartCron 사용할 수 있는 간격 또는 cron 스케줄을 선택하세요. *supports restartCron , 목록, 범위 및 단계. restartIntervalMs 두 가지 스케줄을 동시에 구성하지 마십시오: native 초기화는 0가 설정되어且
보다 큰 경우 fatal config 오류를 발생시킵니다. 재시작은 JavaScript 런타임을 새로 생성하므로, 강력한 스케줄을 사용하기 전에 queued 이벤트, 저장되지 않은 양식 상태 및 현재 네비게이션 상태를.persist하세요.
수동 native 재시작Call restartWebView() JavaScript 런타임이 네이티브 WebView를 미리 교체하기 위해 결정할 때, 예를 들어 메모리 집약적인 워크플로우 후 또는 장시간 비대면 세션에 들어가기 전에:
await WebViewCrash.restartWebView();__CAPGO_KEEP_0__의 pending marker를 작성하고 reason: 'manualRestart', 현재 호출을 해제하고 native code에게 새로운 WebView를 생성하도록 요청합니다. Android는 호스트 액티비티를 다시 생성하고 iOS는 Capacitor bridge view를 다시 빌드하여 새로운 WKWebView 생성되도록 합니다. 현재 페이지를 다시 로드하는 대신.
API 개요
API 개요getPendingCrashInfo
__CAPGO_KEEP_0__ 개요Section titled “__CAPGO_KEEP_0__ overview” null Section titled “getPendingCrashInfo”
const pending = await WebViewCrash.getPendingCrashInfo();if (pending.value) { console.log(pending.value.platform, pending.value.reason);}clearPendingCrashInfo
clearPendingCrashInfo 섹션recovery 처리가 완료되면 저장된 마커를 삭제합니다.
await WebViewCrash.clearPendingCrashInfo();simulateCrashRecovery
simulateCrashRecovery 섹션QA 및 로컬 디버깅을 위해 실제 WebView가 충돌하지 않고 회복 경로를 연습할 수 있도록 가짜 충돌 마커를 생성합니다.
const simulated = await WebViewCrash.simulateCrashRecovery();console.log(simulated.value);restartWebView
restartWebView 섹션수동으로 WebView를 재시작하는 마커를 저장하고 native code에게 새로운 WebView를 생성하도록 요청합니다.
await WebViewCrash.restartWebView();- 클립보드에 복사
onRenderProcessGone및didCrashiOS 플랫폼이 제공할 때 제공됩니다.rendererPriorityAtExitiOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다. - iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.
webViewWebContentProcessDidTerminateiOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다. - Manual and scheduled restarts create a fresh WebView. Android recreates the host activity; iOS rebuilds the Capacitor bridge view.
- iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.
reason: 'periodicRestart'iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.reason: 'manualRestart'. - iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.
iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.
iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.PendingCrashInfoResult
iOS는 앱이 종료될 때 앱의 현재 상태를 포함하여 앱의 메타데이터를 저장합니다.export interface PendingCrashInfoResult { /** * Stored crash or restart metadata, or `null` when no marker is pending. */ value: WebViewCrashInfo | null;}WebViewCrashPluginConfig
__CAPGO_KEEP_1__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_1__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
__CAPGO_KEEP_1__export type WebViewCrashPlatform = 'android' | 'ios' | 'web';WebViewCrashReason
__CAPGO_KEEP_1__export type WebViewCrashReason = | 'renderProcessGone' | 'webContentProcessDidTerminate' | 'periodicRestart' | 'manualRestart' | 'simulated';WebViewCrashAppState
__CAPGO_KEEP_1__export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';__CAPGO_KEEP_1__
Source Of Truth이 페이지는 플러그인의 src/definitions.ts. 업스트림의 공공 API이 변경되었을 때 다시 싱크를 실행하세요.
Getting Started
Getting Startednative 미디어 및 인터페이스 동작을 계획하고 있는 경우 Getting Started native 미디어 및 인터페이스 동작을 계획하고 있는 경우 Using @capgo/capacitor-webview-crash for the native capability in Using @capgo/capacitor-webview-crash, Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities implementation 세부 사항을 위한 @capgo/capacitor-live-activities Using @capgo/capacitor-video-player native 기능을 위한 @capgo/capacitor-video-player @capgo/capacitor-video-player implementation 세부 사항을 위한 @capgo/capacitor-video-player