From 03fba161c3c87d232772553155d79b8ea231f468 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Thu, 27 Aug 2026 13:33:29 +0330 Subject: [PATCH] debug log --- src/app/layout.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 4685c35..7d5f4f4 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -331,6 +331,29 @@ export default async function RootLayout({ return false; }; } + + // 7. Deep Lifecycle & Focus Debug Instrumentation + function logLifecycle(name, detail) { + try { + var bodyBg = window.getComputedStyle ? window.getComputedStyle(document.body).backgroundColor : 'unknown'; + var htmlBg = window.getComputedStyle ? window.getComputedStyle(document.documentElement).backgroundColor : 'unknown'; + var msg = '[WEB_DEEP_LIFECYCLE] [' + Date.now() + '] Event: ' + name + ' | visibility: ' + document.visibilityState + ' | hasFocus: ' + document.hasFocus() + ' | bodyBg: ' + bodyBg + ' | htmlBg: ' + htmlBg + (detail ? ' | ' + JSON.stringify(detail) : ''); + console.log(msg); + if (window.HabibApp && window.HabibApp.postMessage) { + window.HabibApp.postMessage(JSON.stringify({ action: 'debug_log', message: msg })); + } + } catch (e) {} + } + + ['visibilitychange', 'focus', 'blur', 'pageshow', 'pagehide', 'freeze', 'resume'].forEach(function(evt) { + window.addEventListener(evt, function(e) { + logLifecycle(evt, { type: e.type, persisted: e.persisted }); + }, true); + }); + + document.addEventListener('visibilitychange', function() { + logLifecycle('document.visibilitychange', { visibilityState: document.visibilityState }); + }); })(); `, }}