내용으로 건너뛰기

웹뷰 크래시 __CAPGO_KEEP_0__ 저장소

GitHub

설치

설치

AI 도움을 받아 플러그인을 설치할 수 있습니다. 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.

만약 Manual Setup을 선호한다면, 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
npm install @capgo/capacitor-webview-crash
npx 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();
});
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 자바스크립트 런타임이 충돌하거나 로드되지 않은 경우도 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 일정 시간에 재시작을 사용하세요. 예를 들어, 장치의 지역 시간대에서 매일 03:00에 재시작을 사용하세요. 0 3 * * * 일정 시간에 재시작을 사용하세요. 일정 시간에 재시작을 사용하면, Android는 호스트 액티비티를 다시 생성하고 iOS는 __CAPGO_KEEP_0__ 브릿지 뷰를 다시 빌드하여 새로운 reason: 'periodicRestart'Capacitor WKWebView native code으로 생성됩니다.

제품이 견딜 수 있는 간격 또는 cron 스케줄을 선택하세요. restartCron 지원합니다. *, 목록, 범위, 단계입니다. 둘 다 구성하지 마세요: native 초기화는 치명적인 구성 오류를 발생시킬 것입니다. restartCron is set and restartIntervalMs native __CAPGO_KEEP_0__이 0보다 큽니다. Aggressive 스케줄을 사용할 때는 강제로 재시작하여 JavaScript 런타임을 새로 생성하므로, 큐드 이벤트, 저장되지 않은 양식 상태, 현재 탐색 상태를 미리 저장하세요.

수동 native 재시작

수동 native 재시작

Call restartWebView() 현재 JavaScript 런타임이 native WebView를 수동으로 교체할 때, 예를 들어 메모리 집중적인 워크플로우 또는 장시간 비대면 세션 전:

await WebViewCrash.restartWebView();

메서드는 대기 중인 마커를 기록하고 reason: 'manualRestart', 현재 호출을 해결한 다음 네이티브 code에게 새로운 WebView를 생성하라고 요청합니다. Android는 호스트 액티비티를 재생성하고 iOS는 Capacitor 브리지를 다시 빌드하여 새로운 WKWebView 대신 현재 페이지를 다시 로드하는 대신

API 개요

API 개요

getPendingCrashInfo

제목

getPendingCrashInfo null 제목

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

clearPendingCrashInfo

nothing이 대기 중일 때

클립보드 복사하기

await WebViewCrash.clearPendingCrashInfo();

simulateCrashRecovery

simulateCrashRecovery

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

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

restartWebView

restartWebView

수동으로 WebView를 재시작하고 native code에게 새로운 WebView를 생성하도록 요청합니다.

await WebViewCrash.restartWebView();

플랫폼 참고사항

Android는
  • , 포함 onRenderProcessGone및 didCrash and rendererPriorityAtExit platform provides them
  • iOS는 webViewWebContentProcessDidTerminate 와
  • Android는 호스트 액티비티를 재생성하고 iOS는 Capacitor 브릿지 뷰를 다시 빌드합니다.
  • 또한 현재 애플리케이션 상태가 있을 때 사용할 수 있습니다. reason: 'periodicRestart'수동 및 예약된 재시작은 새 WebView를 만듭니다. Android는 호스트 활동을 다시 생성하고 iOS는 __CAPGO_KEEP_0__ 브릿지 뷰를 다시 빌드합니다. reason: 'manualRestart'.
  • 예약된 재시작은

를 사용합니다. 수동 재시작은

를 사용합니다.
export interface PendingCrashInfoResult {
/**
* Stored crash or restart metadata, or `null` when no marker is pending.
*/
value: WebViewCrashInfo | null;
}

WebViewCrashPluginConfig

웹뷰 크래시 플러그인 설정
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

웹뷰 크래시 정보
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

웹뷰 크래시 플랫폼
export type WebViewCrashPlatform = 'android' | 'ios' | 'web';

WebViewCrashReason

웹뷰 크래시 이유
export type WebViewCrashReason =
| 'renderProcessGone'
| 'webContentProcessDidTerminate'
| 'periodicRestart'
| 'manualRestart'
| 'simulated';
export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';

실제 원천

실제 원천

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

이러한 기능을 사용하는 경우 시작하기 자연적인 미디어 및 인터페이스 동작을 계획하려면 @capgo/capacitor-웹뷰-크래시 Using @capgo/capacitor-webview-crash @capgo/capacitor-live-activities Using @capgo/capacitor-live-activities @capgo/capacitor-라이브-액티비티 Using @capgo/capacitor-video-player @capgo/capacitor-webview-crash Capgo에서 사용하는 @capgo/capacitor-video-player의 원시 기능을 위해 @capgo/capacitor-video-player Capgo에서 사용하는 @capgo/capacitor-video-player의 구현 세부 정보를 위해