godothub/godot-minigame / skills
godot-wechat-minigame-adapter
UnverifiedApply the bundled self-contained Godot WeChat Mini Game adapter kit to an official Godot checkout. Use when the user wants to port official Godot to WeChat Mini Game, refresh a nearby 4.6-based port, or inspect the shipped patch/source bundle for WXMEMFS, `wx.request`, audio cleanup, display/input, WXGLX dual-path rendering, `.wasm.br`, and `wx.exitMiniProgram`. This skill is version-locked to the bundled upstream base and must not be described as a generic “Godot 4.x” patch dump.
patches/fixes/4.7-webgl-context/001-context-swap-control.patch
View on GitHubdiff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp
index a78c257698..6226fe20af 100644
--- a/platform/web/display_server_web.cpp
+++ b/platform/web/display_server_web.cpp
@@ -1141,8 +1141,12 @@ DisplayServerWeb::DisplayServerWeb(const String &p_rendering_driver, DisplayServ
attributes.majorVersion = 2;
#ifdef WECHAT_GLX_EXPERIMENTAL
wx_glx_enabled = godot_js_display_is_wx_glx_enabled() == 1;
+ // GLX builds omit OFFSCREEN_FRAMEBUFFER, so neither runtime mode can
+ // request Emscripten explicit swaps. The WebGL path presents via the JS wrapper.
+ attributes.explicitSwapControl = false;
+#else
+ attributes.explicitSwapControl = true;
#endif
- attributes.explicitSwapControl = !wx_glx_enabled;
webgl_ctx = emscripten_webgl_create_context(canvas_id, &attributes);
webgl2_inited = webgl_ctx && emscripten_webgl_make_context_current(webgl_ctx) == EMSCRIPTEN_RESULT_SUCCESS;
diff --git a/platform/web/js/tests/test_godot_process_commit_frame.js b/platform/web/js/tests/test_godot_process_commit_frame.js
index 13c2714745..96b81893d7 100644
--- a/platform/web/js/tests/test_godot_process_commit_frame.js
+++ b/platform/web/js/tests/test_godot_process_commit_frame.js
@@ -44,6 +44,15 @@ vm.runInContext(`${processed}result=wasmImports.a();`, context);
assert.strictEqual(context.result, 17);
assert.deepStrictEqual(Array.from(context.calls), ["original", "flush", "commit"]);
+// GLX-capable builds use implicit swaps even in standard WebGL mode.
+// Emscripten returns INVALID_TARGET there; WeChat still needs presentation.
+const implicitGlue = generatedGlue.replace("return 17", "return -3");
+const implicitContext = {};
+vm.createContext(implicitContext);
+vm.runInContext(`${processFixture(implicitGlue)}result=wasmImports.a();`, implicitContext);
+assert.strictEqual(implicitContext.result, -3);
+assert.deepStrictEqual(Array.from(implicitContext.calls), ["original", "flush", "commit"]);
+
const withoutCommitImport = processFixture("var existing=function(){};var wasmImports={a:existing};");
assert(!withoutCommitImport.includes("_emscripten_webgl_commit_frame"), "must not invent a missing frame import");
diff --git a/platform/web/js/tests/test_wechat_webgl_context_attributes.js b/platform/web/js/tests/test_wechat_webgl_context_attributes.js
new file mode 100644
index 0000000000..f9214a6322
--- /dev/null
+++ b/platform/web/js/tests/test_wechat_webgl_context_attributes.js
@@ -0,0 +1,42 @@
+"use strict";
+
+const assert = require("assert");
+const fs = require("fs");
+const path = require("path");
+const vm = require("vm");
+
+const source = fs.readFileSync(path.resolve(__dirname, "../../display_server_web.cpp"), "utf8");
+const start = source.indexOf("attributes.majorVersion = 2;");
+const end = source.indexOf("EMSCRIPTEN_RESULT_SUCCESS;", start);
+assert(start >= 0 && end > start, "context initialization block must exist");
+// Execute the actual attribute assignments under both compile-time branches.
+const initialization = source.slice(start, end + "EMSCRIPTEN_RESULT_SUCCESS;".length)
+ .replace(/&attributes\b/g, "attributes")
+ .replace(/^#ifdef WECHAT_GLX_EXPERIMENTAL$/gm, "if (compiledGLX) {")
+ .replace(/^#else$/gm, "} else {")
+ .replace(/^#endif$/gm, "}");
+
+for (const [compiledGLX, runtimeGLX] of [[true, false], [true, true], [false, false]]) {
+ let creates = 0;
+ const context = {
+ compiledGLX,
+ attributes: {},
+ wx_glx_enabled: false,
+ canvas_id: "canvas",
+ EMSCRIPTEN_RESULT_SUCCESS: 0,
+ godot_js_display_is_wx_glx_enabled: () => Number(runtimeGLX),
+ emscripten_webgl_create_context: (_canvas, attributes) => {
+ creates++;
+ // Emscripten rejects explicit swaps when the build has no offscreen support.
+ return compiledGLX && attributes.explicitSwapControl ? 0 : 1;
+ },
+ emscripten_webgl_make_context_current: (handle) => handle === 1 ? 0 : -3,
+ };
+ vm.runInNewContext(initialization, context);
+ assert.strictEqual(creates, 1);
+ assert.strictEqual(context.webgl2_inited, true, `context failed: build GLX=${compiledGLX}, runtime GLX=${runtimeGLX}`);
+ assert.strictEqual(context.wx_glx_enabled, runtimeGLX);
+ assert.strictEqual(context.attributes.explicitSwapControl, !compiledGLX);
+}
+
+console.log("WeChat WebGL context attribute tests passed");
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |