Skip to content

Fix for null TypeError in dynamicTexture #16491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025

Conversation

kircher1
Copy link
Contributor

It's possible that when rapidly disposing a dynamicTexture, a delayed callback gets ran on the disposed instance, resulting in a TypeError exception caused by accessing a null instance. The specific case that was causing this issue was when Tools.SetImmediate is used to pend some future work to update the dynamic texture, and by the time this delayed callback was running, the dynamicTexture had already been disposed.

The fix here is to early out of the update function if this._texture is already null. This simply avoids dereferencing a null engine when calling _getEngine().updateDynamicTexture(this._texture, ...). In any case, updateDynamicTexture itself already early outs when the texture parameter is null, so it should not change that behavior.

@sebavan sebavan enabled auto-merge (squash) April 15, 2025 00:53
@bjsplat
Copy link
Collaborator

bjsplat commented Apr 15, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 15, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 15, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Apr 15, 2025

@sebavan sebavan merged commit 3694f3c into BabylonJS:master Apr 15, 2025
17 checks passed
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.

3 participants