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:
shakespeare.diy 2026-06-18 21:41:32 +07:00
parent dc66ac993f
commit 8c25110f44

View file

@ -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 />