Skip to content

Fix circular dependency between BatchHandler and the renderer index - #7373

Open
pavle-goloskokovic wants to merge 1 commit into
phaserjs:masterfrom
pavle-goloskokovic:v4/render-node-cycle
Open

Fix circular dependency between BatchHandler and the renderer index#7373
pavle-goloskokovic wants to merge 1 commit into
phaserjs:masterfrom
pavle-goloskokovic:v4/render-node-cycle

Conversation

@pavle-goloskokovic

Copy link
Copy Markdown
Contributor

This PR

  • Fixes a bug

Describe the changes below:

BatchHandler requires the whole renderer index just to read two event names from Renderer.Events. Since the renderer index also (indirectly) requires the render nodes, this is a circular dependency, and whether it breaks depends on which side loads first.

The existing builds happen to load the renderer index first, so they are fine. A custom build that loads core/Game first reaches BatchHandler through RenderNodeManager before the index. BatchHandler then pulls in the index, which loads BatchHandlerQuad, which extends a BatchHandler that is still an empty object. The game fails at startup with "TypeError: Object prototype may only be an Object or null: undefined".

Fix: require renderer/events directly, as WebGLRenderer, WebGLPipeline and RenderTarget already do. No behaviour change for the existing builds.

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.

1 participant