HTML5: document host-set Module opt-outs (defold/defold#12396 follow-up)#635
Open
birdingman0626 wants to merge 1 commit into
Open
HTML5: document host-set Module opt-outs (defold/defold#12396 follow-up)#635birdingman0626 wants to merge 1 commit into
birdingman0626 wants to merge 1 commit into
Conversation
dmloader.js now respects six host-set properties on the global Module object when they're declared before <script src="dmloader.js"> loads (defold/defold#12396). Document the full surface — pthread, WebGL2, context attrs, extension filter, button strip, context-loss recovery — in the HTML5 manual under a new "Host-set Module properties" subsection, between Engine arguments and Query arguments. Includes the example shape, the per-property reference table, and the two important notes (let-vs-var binding, strict sentinel checks).
14 tasks
paweljarosz
reviewed
Jun 2, 2026
| ``` | ||
|
|
||
|
|
||
| ### Host-set Module properties |
Contributor
There was a problem hiding this comment.
Suggested change
| ### Host-set Module properties | |
| ### Advanced HTML5 embedding: Host-set Module properties |
paweljarosz
reviewed
Jun 2, 2026
|
|
||
|
|
||
| ### Host-set Module properties | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| These options are intended for advanced HTML5 embedding scenarios, such as WebView wrappers or custom host pages. Most games should not need them. | |
paweljarosz
reviewed
Jun 2, 2026
| | `webGLExtensionFilter` | `(name) => boolean` | Strip names from `getSupportedExtensions` / `getExtension`. Returning `true` for a name removes it. Useful when the driver falsely advertises compressed-texture / float-texture / depth-texture extensions then rejects the actual upload. | | ||
| | `showButtonStrip` | `=== false` | Hide the engine_template footer (`.buttons-background`). [project setting]`html5.show_fullscreen_button = 0` + `html5.show_made_with_defold = 0` suppresses the inner anchors but leaves a 42 px white bar behind; this opt-out finishes the job for hosts that want a true-fullscreen canvas. | | ||
| | `autoReloadOnWebGLContextRestore` | `=== true` | Attach `webglcontextlost` / `webglcontextrestored` listeners to the canvas. `preventDefault()` on lost asks the browser to restore; on restored, `location.reload()` so the engine boots cleanly. The player lands on the title screen and resumes from autosave. | | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| ::: important | |
| Some of these options patch browser prototypes and may affect other WebGL canvases on the same page. Use them only on controlled host pages dedicated to the Defold game. | |
| ::: | |
paweljarosz
reviewed
Jun 2, 2026
| | `webGLContextAttributes` | `Object` | Merged (`Object.assign`) into the attrs argument of the WebGL context creation. Notably useful for forcing `preserveDrawingBuffer:true` when the host compositor is flaky and `eglSwapBuffers` may fail between renders. | | ||
| | `webGLExtensionFilter` | `(name) => boolean` | Strip names from `getSupportedExtensions` / `getExtension`. Returning `true` for a name removes it. Useful when the driver falsely advertises compressed-texture / float-texture / depth-texture extensions then rejects the actual upload. | | ||
| | `showButtonStrip` | `=== false` | Hide the engine_template footer (`.buttons-background`). [project setting]`html5.show_fullscreen_button = 0` + `html5.show_made_with_defold = 0` suppresses the inner anchors but leaves a 42 px white bar behind; this opt-out finishes the job for hosts that want a true-fullscreen canvas. | | ||
| | `autoReloadOnWebGLContextRestore` | `=== true` | Attach `webglcontextlost` / `webglcontextrestored` listeners to the canvas. `preventDefault()` on lost asks the browser to restore; on restored, `location.reload()` so the engine boots cleanly. The player lands on the title screen and resumes from autosave. | |
Contributor
There was a problem hiding this comment.
Suggested change
| | `autoReloadOnWebGLContextRestore` | `=== true` | Attach `webglcontextlost` / `webglcontextrestored` listeners to the canvas. `preventDefault()` on lost asks the browser to restore; on restored, `location.reload()` so the engine boots cleanly. The player lands on the title screen and resumes from autosave. | | |
| | `autoReloadOnWebGLContextRestore` | `=== true` | Attach `webglcontextlost` / `webglcontextrestored` listeners to the canvas. `preventDefault()` on lost asks the browser to restore; on restored, `location.reload()` so the engine boots cleanly. On restore, the page is reloaded so the engine can initialise a fresh WebGL context. Any game state that should survive the reload must be persisted by the game.| |
paweljarosz
reviewed
Jun 2, 2026
| ::: | ||
|
|
||
| ::: important | ||
| The checks are strict — only the literal sentinel triggers the opt-out (`=== false` for the booleans, `=== true` for `autoReloadOnWebGLContextRestore`, a `function` typeof for the filter, a truthy object for the attrs). Truthy/falsy values like `0`, `null`, `""`, or `undefined` are ignored. |
Contributor
There was a problem hiding this comment.
Suggested change
| The checks are strict — only the literal sentinel triggers the opt-out (`=== false` for the booleans, `=== true` for `autoReloadOnWebGLContextRestore`, a `function` typeof for the filter, a truthy object for the attrs). Truthy/falsy values like `0`, `null`, `""`, or `undefined` are ignored. | |
| The checks are strict — only the literal sentinel triggers the opt-out (`=== false` for the booleans, `=== true` for `autoReloadOnWebGLContextRestore`, a `function` typeof for the filter, a truthy object for the attrs). Must be a plain object. Other truthy/falsy values like `0`, `null`, `""`, or `undefined` are unsupported, ignored, and should not be used. |
paweljarosz
reviewed
Jun 2, 2026
| isWebGL2Supported: false, | ||
| webGLContextAttributes: { preserveDrawingBuffer: true }, | ||
| webGLExtensionFilter: function (name) { | ||
| return name.toLowerCase().includes("compressed_texture"); |
Contributor
There was a problem hiding this comment.
Suggested change
| return name.toLowerCase().includes("compressed_texture"); | |
| return typeof name === "string" && name.toLowerCase().includes("compressed_texture"); |
paweljarosz
reviewed
Jun 2, 2026
| | `isWebGL2Supported` | `=== false` | Downgrade `getContext('webgl2')` to `'webgl'`. Useful when the embedded GLES driver advertises WebGL2 but trips inside the engine's VAO / instancing init. | | ||
| | `webGLContextAttributes` | `Object` | Merged (`Object.assign`) into the attrs argument of the WebGL context creation. Notably useful for forcing `preserveDrawingBuffer:true` when the host compositor is flaky and `eglSwapBuffers` may fail between renders. | | ||
| | `webGLExtensionFilter` | `(name) => boolean` | Strip names from `getSupportedExtensions` / `getExtension`. Returning `true` for a name removes it. Useful when the driver falsely advertises compressed-texture / float-texture / depth-texture extensions then rejects the actual upload. | | ||
| | `showButtonStrip` | `=== false` | Hide the engine_template footer (`.buttons-background`). [project setting]`html5.show_fullscreen_button = 0` + `html5.show_made_with_defold = 0` suppresses the inner anchors but leaves a 42 px white bar behind; this opt-out finishes the job for hosts that want a true-fullscreen canvas. | |
Contributor
There was a problem hiding this comment.
Suggested change
| | `showButtonStrip` | `=== false` | Hide the engine_template footer (`.buttons-background`). [project setting]`html5.show_fullscreen_button = 0` + `html5.show_made_with_defold = 0` suppresses the inner anchors but leaves a 42 px white bar behind; this opt-out finishes the job for hosts that want a true-fullscreen canvas. | | |
| | `showButtonStrip` | `=== false` | Hide the engine_template footer (`.buttons-background`). This can be used in addition to the existing html5.show_fullscreen_button and html5.show_made_with_defold project settings - `html5.show_fullscreen_button = 0` + `html5.show_made_with_defold = 0` suppresses the inner anchors but leaves a 42 px white bar behind; this opt-out finishes the job for hosts that want a true-fullscreen canvas. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up documentation for defold/defold#12396, which expands
dmloader.jsto respect six host-set properties on the globalModuleobject:Module.isWASMPthreadSupportedModule.isWebGL2SupportedModule.webGLContextAttributesModule.webGLExtensionFilterModule.showButtonStripModule.autoReloadOnWebGLContextRestoreEach is captured before the loader's own
var Module = {...}redefinition and applied in an IIFE that runs at the same site. Default behaviour is byte-identical when nothing is pre-set.This PR adds a new "Host-set Module properties" subsection to
docs/en/manuals/html5.md, placed between the existing "Engine arguments" and "Query arguments in the URL" subsections under "Passing arguments to an HTML5 game". The new content includes:var Module = { ... };block before the<script src=\"dmloader.js\">tag).letvsvarbinding gotcha (top-levellet Moduleis invisible to the loader'svar Module), and the strict sentinel-value semantics (=== false/=== true/functiontypeof, no coercion).Should land after defold/defold#12396 merges, since this references behaviour the engine doesn't have yet. Adjustable to whatever the final API surface looks like if the engine PR shrinks during review.
PR checklist