@@ -96,6 +96,10 @@ volatile int g_dumpCount = 0;
9696constexpr uint64_t kRedumpCooldownSec = 30 ;
9797volatile uint64_t g_lastDumpMonotonicSec = 0 ;
9898
99+ // Kill threshold multiplier: process is killed after hangSeconds * this when
100+ // no managed heartbeat has EVER been observed (renderer init hung).
101+ constexpr uint64_t kKillThresholdMultiplier = 2 ;
102+
99103// --------------------------------------------------------------------------
100104// Async-signal-safe formatters / I/O.
101105// --------------------------------------------------------------------------
@@ -531,7 +535,7 @@ void* watchdogMain(void* /*arg*/)
531535 // gives the renderer a generous window: the first dump fires at 1×
532536 // threshold for diagnostics, then we wait one more threshold period before
533537 // concluding the hang is unrecoverable.
534- const uint64_t killThresholdSec = (uint64_t )g_hangSeconds * 2 ;
538+ const uint64_t killThresholdSec = (uint64_t )g_hangSeconds * kKillThresholdMultiplier ;
535539
536540 for (;;)
537541 {
@@ -565,17 +569,20 @@ void* watchdogMain(void* /*arg*/)
565569 {
566570 // Write a final diagnostic before killing.
567571 int fd = openLogAppend ();
568- writeStr (fd, " \n =========================================================\n " );
569- writeStr (fd, " === NATIVE WATCHDOG KILL ===\n " );
570- writeStr (fd, " reason = renderer init hang (no heartbeat ever observed after " );
571- writeDec (fd, (long long )age);
572- writeStr (fd, " s)\n " );
573- writeStr (fd, " action = killing process for safe-mode restart (OpenGL fallback)\n " );
574- writeStr (fd, " kill_threshold = " );
575- writeDec (fd, (long long )killThresholdSec);
576- writeStr (fd, " s\n " );
577- writeStr (fd, " === END NATIVE WATCHDOG KILL ===\n\n " );
578- if (fd >= 0 ) close (fd);
572+ if (fd >= 0 )
573+ {
574+ writeStr (fd, " \n =========================================================\n " );
575+ writeStr (fd, " === NATIVE WATCHDOG KILL ===\n " );
576+ writeStr (fd, " reason = renderer init hang (no heartbeat ever observed after " );
577+ writeDec (fd, (long long )age);
578+ writeStr (fd, " s)\n " );
579+ writeStr (fd, " action = killing process for safe-mode restart (OpenGL fallback)\n " );
580+ writeStr (fd, " kill_threshold = " );
581+ writeDec (fd, (long long )killThresholdSec);
582+ writeStr (fd, " s\n " );
583+ writeStr (fd, " === END NATIVE WATCHDOG KILL ===\n\n " );
584+ close (fd);
585+ }
579586
580587 __android_log_write (ANDROID_LOG_ERROR , WATCHDOG_LOG_TAG ,
581588 " NATIVE WATCHDOG KILL — renderer init hung, killing for safe-mode OpenGL restart" );
0 commit comments