NullEngine not added to EngineStore Instances Array

When creating a new NullEngine instance, it isn’t getting added to the EngineStore.Instances array, so there is no global reference to the NullEngine.

Here’s a playground example: Babylon.js Playground

Looking through the code, it looks like the Engine class returns immediately if the canvas is null (which the NullEngine does). I see two possible solutions:

  1. The Engine.Instances.push(this) code gets moved to above the if canvas check. However, I’m unsure if that would be problematic in the case where an Engine is created specifically with a null Canvas, as the new Engine instance would be unusable and probably shouldn’t be added to the Instances array.

  2. The Engine.Instances.push(this) is added to the NullEngine constructor. Probably the best solution in this case imo.

Assuming this is a bug, I don’t mind making a PR and fixing it, however, I’m unsure where to begin (I’ve never contributed to an open source project before lol).

Hey and welcome!!
Thanks a lot for the report

I’m currently preparing a nightly so I will do the change;)

Thanks a lot

1 Like