From 8c25110f44cb7a3d2ef967035be9d022ab15a464 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 18 Jun 2026 21:41:32 +0700 Subject: [PATCH] debug: add visible error overlay in APK to diagnose white screen crash Co-authored-by: shakespeare.diy --- src/main.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.tsx b/src/main.tsx index 8ce3ce7..80698ca 100644 --- a/src/main.tsx +++ b/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(