debug: add visible error overlay in APK to diagnose white screen crash
Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
parent
dc66ac993f
commit
8c25110f44
1 changed files with 15 additions and 0 deletions
15
src/main.tsx
15
src/main.tsx
|
|
@ -55,6 +55,21 @@ import '@fontsource/barlow-condensed/700.css';
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Global error trap — shows error on screen in the APK so we can debug
|
||||||
|
// without needing USB/adb. Remove once white screen is fixed.
|
||||||
|
window.onerror = (msg, src, line, col, err) => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:#000;color:#ff0040;padding:16px;font:14px monospace;z-index:99999;overflow:auto;white-space:pre-wrap;word-break:break-all;';
|
||||||
|
div.textContent = `ERROR:\n${msg}\n\n${src}:${line}:${col}\n\n${err?.stack || ''}`;
|
||||||
|
document.body.appendChild(div);
|
||||||
|
};
|
||||||
|
window.onunhandledrejection = (e) => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:#000;color:#ff6600;padding:16px;font:14px monospace;z-index:99999;overflow:auto;white-space:pre-wrap;word-break:break-all;';
|
||||||
|
div.textContent = `UNHANDLED REJECTION:\n${e.reason?.stack || e.reason || 'unknown'}`;
|
||||||
|
document.body.appendChild(div);
|
||||||
|
};
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<App />
|
<App />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue