Skip to content

Fix global plugin mappings in HEADLESS mode - #7374

Open
bagel786 wants to merge 1 commit into
phaserjs:masterfrom
bagel786:fix/headless-global-plugin-mapping
Open

bagel786 wants to merge 1 commit into
phaserjs:masterfrom
bagel786:fix/headless-global-plugin-mapping

Conversation

@bagel786

Copy link
Copy Markdown

This PR

  • Fixes a bug

Install global plugins immediately during HEADLESS startup so configured mappings are available when scenes boot. Add regression coverage for scene injection.

Tests:

  • npx vitest run tests/plugins/PluginManager.test.js
  • npx vitest run tests/plugins

Fixes #7348


Continues #7357 — the fork repo backing that PR was accidentally deleted from this account, and GitHub blocks reopening a PR whose submitting repository was deleted (a restore request is being filed with GitHub Support). This PR resumes the identical work from the same commit (fe96f3e500842982ce4d056c86e3d04b414da4f4); review discussion continues on the original PR.

Copilot AI lite review requested due to automatic review settings September 11, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Defer HEADLESS plugin activation until Game initialization is complete.

Pull request overview

Fixes global plugin mappings in HEADLESS mode so configured plugins are available before scenes boot.

Changes:

  • Installs configured global plugins during HEADLESS startup.
  • Adds regression coverage for mapped plugin injection.
File summaries
File Summary
tests/plugins/PluginManager.test.js Adds HEADLESS mapping regression coverage.
src/plugins/PluginManager.js Adjusts HEADLESS plugin installation timing; activation may occur before Game state is initialized.
Review details

Suppressed comments (1)

src/plugins/PluginManager.js:455

  • HEADLESS PluginManager instances are constructed before Game assigns this.plugins (src/core/Game.js:280), and the constructor calls boot() immediately (src/plugins/PluginManager.js:117-120). With this condition, a mapped config plugin is instantiated and its init/start run inside that constructor, so this.game.plugins (and later Game fields such as noReturn) are still unset. This makes HEADLESS plugin startup observably earlier than Canvas/WebGL and can break valid plugins that access public Game state; defer HEADLESS activation until after Game construction, or separate cache registration from activation while still making mappings available before Scene Systems boot.
        if (!this.game.isBooted && this.game.config.renderType !== CONST.HEADLESS)
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global plugins not mapped on scene when render type is Phaser.HEADLESS

2 participants