React native update dynamic texture error occurring

I am facing an issue sometimes but not always, so my guess is might happen due to these scenarios:

  1. creating multiple dynamic texture
  2. using dynamic texture for drawing 2d shapes, using drawImage, using fillText on its context.
  3. by the user interaction i am clearing the dynamic texture and recreate multiple dynamic textures as mentioned in the above points. And all these functionalities happen continuously according to user interaction.

Sometimes I am getting the issue null is not an object evaluating this._getEngine().updateDynamicTexture()

Can anyone kindly explain why this issue is occurring and how to overcome this error?

Thank you.

cc @BabylonNative

By looking at some code, it seems that _engine (returned by _getEngine()) might be null if the texture is created with a scene but it would be retrieved anyway by the scene.

So, I’m not sure how _engine can be null.
is tile.js a part of your code?
If so, can you put a console.log to check for the texture scene and _engine?

This issue is also occurring for native navigation. I have two pages one is simple app onboarding and from that page i am using stack navigation to navigate to the page containing from the onboarding page. What I am trying to achieve is that when the user presses exit button they go back to the previous onboarding page. Navigation is working fine as it is going back to the previous page and then this error is showing. I am also using engine.dispose() before the going back action is being called.

this is my engine page:

this is my exit button functionality:

const handleExitPress = () => {

engine.dispose disposes all the resources. basically, that’ what is performed when app is closed. you should not do that unless you know exactly what you are doing.

Even if i am not using engine.dispose() and just calling the navigation function the same issue is occurring. Is there any workaround which you can suggest ?

I suggest to make a minimal repro so we can fix this issue asap. without a repro, we won’t be able to fix it.

1 Like

I’ve open a Github issue to not lose track of it : Dynamic texture lifecycle · Issue #1205 · BabylonJS/BabylonNative · GitHub


Hey, hope you are doing well.
Is there any progress on this ?

Sorry, no progress in this issue so far.