Phase A/B: fix the game loop and trim the asset payload
Phase A (the hard blocker): the engine now plays a real table live in the browser via a real per-frame game loop, not just a static render. Two real, previously-unknown upstream bugs found and fixed along the way: - RenderDevice::WaitForVSync() unconditionally spawned a real std::thread every frame, even on __STANDALONE__ builds - a hard crash under Emscripten's single-threaded runtime (0003). - The desktop game loop is a blocking native while loop with manual uSleep throttling, incompatible with a single-threaded WASM main thread. Adds Player::EmscriptenStepFrame() (one frame, no internal loop) driven by emscripten_set_main_loop, plus new JS-callable lifecycle entry points (vpinball_wasm_start/stop/dispose in the new src/core/EmscriptenBridge.cpp) that bypass the desktop main()/WinMain() chain entirely, since that chain assumes the process runs exactly one table to completion then exits (0004). Verified end-to-end in Chrome: real .vpx load, real shader compilation, real physics/script engine init, a real running frame loop (observed advancing), and a clean stop() -> ~Player() teardown mid-session with no crash or hang. Phase B: trims the preloaded asset payload from ~51MB to ~11MB by excluding editor-only bundled example tables and a Monaco code editor never used by the player runtime, and adds real link-time optimization (-O2 --closure 1) and --use-preload-cache for repeat visits.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 1fcf242..f9338b2 100644
|
||||
index 1fcf242..bc8f7ff 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -50,6 +50,7 @@ set(_vpx_valid_combos
|
||||
@@ -10,7 +10,7 @@ index 1fcf242..f9338b2 100644
|
||||
DX9-windows)
|
||||
if(NOT "${RENDERER}-${PLATFORM}" IN_LIST _vpx_valid_combos)
|
||||
string(REPLACE ";" "\n " _vpx_available "${_vpx_valid_combos}")
|
||||
@@ -784,6 +785,123 @@ elseif(PLATFORM STREQUAL "linux")
|
||||
@@ -784,6 +785,124 @@ elseif(PLATFORM STREQUAL "linux")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -41,6 +41,7 @@ index 1fcf242..f9338b2 100644
|
||||
+
|
||||
+ add_executable(vpinball
|
||||
+ ${VPX_STANDALONE_SOURCES}
|
||||
+ ${CMAKE_SOURCE_DIR}/src/core/EmscriptenBridge.cpp
|
||||
+ )
|
||||
+
|
||||
+ target_include_directories(vpinball PUBLIC
|
||||
@@ -134,7 +135,7 @@ index 1fcf242..f9338b2 100644
|
||||
# iOS and Android libvpinball build
|
||||
|
||||
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator" OR PLATFORM STREQUAL "android")
|
||||
@@ -957,4 +1075,9 @@ elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator" OR PLATFORM
|
||||
@@ -957,4 +1076,9 @@ elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator" OR PLATFORM
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user