A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(native): a loop that skips frames says which of the two it is
yhhf7d60921bf6a
diff --git a/native/host/Host.cpp b/native/host/Host.cppindex 0bca5b6b2..0408510da 100644--- a/native/host/Host.cpp+++ b/native/host/Host.cpp@@ -273,8 +273,21 @@ bool boot(Platform& platform) {}void frame() {- if (!booted() || !host().surfaceReady) return;+ if (!booted()) return;HostState& h = host();+ // Skipping is normal (the screen is off, the window is going away) and being+ // stuck in it is not, and the two look the same from outside: no frames.+ if (!h.surfaceReady) {+ if (!h.surfaceSkipReported) {+ h.surfaceSkipReported = true;+ ESHOST_LOGI("no surface bound — skipping frames until one is");+ }+ return;+ }+ if (h.surfaceSkipReported) {+ h.surfaceSkipReported = false;+ ESHOST_LOGI("surface bound again — drawing resumes");+ }// A window can change size without being recreated: a rotation, an insets// change (the system bars leaving on the frame after launch), a layout ondiff --git a/native/host/Runtime.hpp b/native/host/Runtime.hppindex 888873516..0e22bcf20 100644--- a/native/host/Runtime.hpp+++ b/native/host/Runtime.hpp@@ -76,6 +76,9 @@ struct HostState {esengine::f32 w = 0, h = 0;bool ready = false; ///< engine + JS booted oncebool surfaceReady = false; ///< a live window surface is bound (false while screen off)+ /// Whether the skipping above has been reported. A loop that runs and draws+ /// nothing reads exactly like a hung one, so each stretch of it says so once.+ bool surfaceSkipReported = false;/// The host asked its event loop to stop. Only a capture run sets it (Shot.hpp);/// a platform whose OS owns the app's lifetime is free to ignore it.bool quitRequested = false;