openvibers/source.openvibe.games Commits

Crash-safe client JS logging + menu override

CO Copilot committed 2 Jul 2026 · 8129b3366a · 3 files, +31 −7

- OVC_log/warn/error now also append each line to game/openvibe.games/
  ovjs_client.log via filesystem Open/Write/Close (flush per line). Msg()
  ->console.log is buffered under Proton, losing the lines right before a
  crash; this flushed file is the reliable end-to-end client JS log and
  pinpoints the exact crashing operation. Log is truncated fresh each init.
- ovjs_core: log readFile result + eval begin/done per file, so the flushed
  log shows whether a specific file's read or eval is what dies.
- Menu override: re-enable ov_menu_auto_open so the custom HTML menu covers
  the stock HL2 main menu (which freezes). It only joins on user click.

Changes

ddiff --git a/game/openvibe.games/cfg/openvibe_proton_stability.cfg b/game/openvibe.games/cfg/openvibe_proton_stability.cfg
iindex 95892c2..b0cb923 100644
---- a/game/openvibe.games/cfg/openvibe_proton_stability.cfg
++++ b/game/openvibe.games/cfg/openvibe_proton_stability.cfg
@@@ -22,7 +22,7 @@ snd_mute_losefocus 0
mat_dxlevel 90
r_3dsky 0
--// Don't auto-open the HTML menu on startup: it was auto-navigating to
--// openvibe://join?mode=hub, firing an ov_join to a (often-down) hub server and
--// showing "Connection failed" over the world. Open it manually with ov_menu.
--ov_menu_auto_open 0
++// Auto-open the custom HTML menu so it covers the stock HL2 main menu (which
++// freezes) — this is the menu override. The menu only joins a server on an
++// explicit user click, so it won't auto-connect on its own.
++ov_menu_auto_open 1
ddiff --git a/sdk/openvibe/client/hl2mp/openvibe_js_client.cpp b/sdk/openvibe/client/hl2mp/openvibe_js_client.cpp
iindex 0160c46..b36c16f 100644
---- a/sdk/openvibe/client/hl2mp/openvibe_js_client.cpp
++++ b/sdk/openvibe/client/hl2mp/openvibe_js_client.cpp
@@@ -34,9 +34,28 @@ static bool OVC_IsSafeModPath( const char *p )
return true;
}
--static void OVC_log( const char *m ) { Msg( "[OV JS/client] %s\n", m ); }
--static void OVC_warn( const char *m ) { Warning( "[OV JS/client] %s\n", m ); }
--static void OVC_error( const char *m ){ Warning( "[OV JS/client ERROR] %s\n", m ); }
++// Crash-safe logger: Msg() -> console.log is buffered under Proton, so lines
++// right before a crash are lost. Also append each line to a MOD file that we
++// flush (Open/Write/Close) every call, guaranteeing the last line before any
++// crash is on disk. This is the reliable end-to-end client JS log.
++static void OVC_LogLine( const char *tag, const char *m )
++{
++ Msg( "[OV JS/client]%s %s\n", tag, m );
++ if ( filesystem )
++ {
++ FileHandle_t f = filesystem->Open( "ovjs_client.log", "a", "MOD" );
++ if ( f )
++ {
++ char line[8192];
++ int n = Q_snprintf( line, sizeof( line ), "[OV JS/client]%s %s\n", tag, m );
++ if ( n > 0 ) filesystem->Write( line, n, f );
++ filesystem->Close( f ); // close each line = flush to disk
++ }
++ }
++}
++static void OVC_log( const char *m ) { OVC_LogLine( "", m ); }
++static void OVC_warn( const char *m ) { OVC_LogLine( " WARN", m ); }
++static void OVC_error( const char *m ){ OVC_LogLine( " ERROR", m ); }
static char *OVC_readFile( const char *path )
{
@@@ -154,6 +173,8 @@ void OpenVibeJS_Client_Init()
Msg( "[OV JS/client] disabled by ov_client_js_enabled=0\n" );
return;
}
++ // Fresh crash-safe log each init.
++ if ( filesystem ) { FileHandle_t f = filesystem->Open( "ovjs_client.log", "w", "MOD" ); if ( f ) filesystem->Close( f ); }
g_pClientCore = ovjs_create( &g_ClientHost, 0 /*client*/, ov_client_mode.GetString() );
if ( g_pClientCore )
{
ddiff --git a/sdk/openvibe/shared/ovjs_core.c b/sdk/openvibe/shared/ovjs_core.c
iindex 5e224e5..d684d60 100644
---- a/sdk/openvibe/shared/ovjs_core.c
++++ b/sdk/openvibe/shared/ovjs_core.c
@@@ -219,6 +219,7 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
if (!c->host || !c->host->readFile) return 0;
if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: loading %s", path); c->host->log(b); }
char *code = c->host->readFile(path);
++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: readFile %s -> %s", path, code ? "ok" : "NULL"); c->host->log(b); }
if (!code) {
if (c->host->warn) {
char buf[512];
@@@ -227,7 +228,9 @@ static int OVJS_LoadFile(OVJSCore *c, const char *path)
}
return 0;
}
++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval begin %s", path); c->host->log(b); }
int ok = ovjs_eval(c, code, path);
++ if (c->host->log) { char b[256]; snprintf(b, sizeof(b), "core: eval done %s ok=%d", path, ok); c->host->log(b); }
OVJS_HostFree(c->host, code);
return ok;
}