Skip to content

시작하기

설치

설치란
터미널 창
bun add @capgo/capacitor-webview-crash
bunx cap sync

수입

수입란
import { 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();
});
const pending = await WebViewCrash.getPendingCrashInfo();
// Note: the listener callback may have already cleared the pending marker.
if (pending.value) {
console.log('Pending crash marker', pending.value);
}

API 개요

API 개요

저장된 네이티브 충돌 마커를 반환하거나, null nothing이 pending일 때.

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

충돌 마커를 지우고 recovery 처리가 끝난 후.

await WebViewCrash.clearPendingCrashInfo();

QA 및 로컬 디버깅을 위해 실제 WebView를 충돌시키지 않고 recovery 경로를 연습할 수 있는 가짜 충돌 마커를 생성합니다.

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

플랫폼 참고사항

플랫폼 참고 사항
  • Android는 onRenderProcessGone, 포함하여 didCrashrendererPriorityAtExit 플랫폼이 제공할 때
  • iOS는 webViewWebContentProcessDidTerminate 및 현재 애플리케이션 상태를 제공할 때
  • 웹에서는 실제 렌더러 충돌을 감지하지 않습니다. 웹 구현은 로컬 스토리지만 사용하여 동작을 시뮬레이션합니다.
export interface PendingCrashInfoResult {
/**
* Stored crash metadata, or `null` when no marker is pending.
*/
value: WebViewCrashInfo | null;
}
export interface WebViewCrashInfo {
/**
* Platform that detected and stored the crash marker.
*/
platform: WebViewCrashPlatform;
/**
* Unix timestamp in milliseconds for when the crash marker was written.
*/
timestamp: number;
/**
* ISO-8601 version of `timestamp`.
*/
timestampISO: string;
/**
* Platform-specific reason for the crash marker.
*/
reason: WebViewCrashReason;
/**
* Last known WebView URL when the crash 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

웹뷰 충돌 플랫폼 섹션
export type WebViewCrashPlatform = 'android' | 'ios' | 'web';

WebViewCrashReason

웹뷰 충돌 이유 섹션
export type WebViewCrashReason = 'renderProcessGone' | 'webContentProcessDidTerminate' | 'simulated';
export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';

실질적 출처

실질적 출처 섹션

이 페이지는 플러그인의 src/definitions.tsAPI이 업스트림에서 변경될 때 다시 동기화할 수 있습니다.