Skip to content

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.

chore(native): the self-check opens the overlay from a frame, not from boot

esenginef1aa97db85d2
diff --git a/native/host/bindings/SteamBindings.cpp b/native/host/bindings/SteamBindings.cpp
index fe5f8d65f..3718e6b43 100644
--- a/native/host/bindings/SteamBindings.cpp
+++ b/native/host/bindings/SteamBindings.cpp
@@ -46,8 +46,6 @@ JSValue js_steam_init(JSContext* ctx, JSValueConst, int argc, JSValueConst* argv
steam().onOverlay([](bool covered) { deliverSteamOverlay(covered); });
if (const char* self = std::getenv("ESTELLA_STEAM_SELFCHECK"); self && self[0] == '1') {
steam().traceCallbacks(true);
- steam().activateOverlay();
- ESHOST_LOGI("steam: self-check opened the overlay — expecting callback %d", 331);
}
}
if (!ok && !steam().lastError().empty()) {
diff --git a/native/host/steam/SteamApi.cpp b/native/host/steam/SteamApi.cpp
index 30bd24b30..180a54861 100644
--- a/native/host/steam/SteamApi.cpp
+++ b/native/host/steam/SteamApi.cpp
@@ -131,6 +131,10 @@ constexpr std::int32_t kGameOverlayActivated = 331;
/** Its first byte: non-zero while the overlay covers the game. */
constexpr int kOverlayActiveOffset = 0;
+/** Which frame the self-check opens the overlay on — late enough that there is a
+ * window to draw over. */
+constexpr int kSelfCheckPump = 120;
+
/** Steam's error buffer is a fixed 1024 bytes (SteamErrMsg). */
constexpr int kErrMsgSize = 1024;
@@ -327,6 +331,13 @@ void SteamApi::pump() {
if (g_fns.runCallbacks) g_fns.runCallbacks();
return;
}
+ // The self-check opens the overlay from the FRAME, not from boot: Steam
+ // refuses to draw over a window that does not exist yet, and a refusal looks
+ // exactly like a callback that never came.
+ if (traceCallbacks_ && ++pumps_ == kSelfCheckPump) {
+ ESHOST_LOGI("steam: self-check opening the overlay at pump %d", kSelfCheckPump);
+ activateOverlay();
+ }
g_fns.dispatchRunFrame(pipe_);
CallbackMsg msg{};
while (g_fns.dispatchNext(pipe_, &msg)) {
@@ -346,7 +357,12 @@ void SteamApi::pump() {
}
void SteamApi::activateOverlay() {
- if (friends_ && g_fns.activateOverlay) g_fns.activateOverlay(friends_, "Friends");
+ if (!friends_ || !g_fns.activateOverlay) {
+ ESHOST_LOGI("steam: ActivateGameOverlay did not resolve (friends=%p fn=%p)",
+ friends_, reinterpret_cast<void*>(g_fns.activateOverlay));
+ return;
+ }
+ g_fns.activateOverlay(friends_, "Friends");
}
} // namespace eshost
diff --git a/native/host/steam/SteamApi.hpp b/native/host/steam/SteamApi.hpp
index 9c3a66655..62071ddb0 100644
--- a/native/host/steam/SteamApi.hpp
+++ b/native/host/steam/SteamApi.hpp
@@ -106,6 +106,7 @@ class SteamApi {
std::int32_t pipe_ = 0;
std::function<void(bool)> overlay_;
bool traceCallbacks_ = false;
+ int pumps_ = 0;
void* friends_ = nullptr;
std::string error_;
};