BabylonNative
BabylonNative copied to clipboard
Race condition possible in LoadTextureFromImage from NativeEngine.cpp
https://github.com/BabylonJS/BabylonNative/blob/6bb77028369d7c91df0372448a6062ea37293b2b/Plugins/NativeEngine/Source/NativeEngine.cpp#L301-L317
The problem is that if Start/FinishRenderingCurrentFrame is being called on the graphics thread, then bgfx::frame can cause releaseFn to be called before this loop is done with image. One possible somewhat hacky solution is to save the image->m_numMips in a local variable to prevent usage of image as it is only possible for the releaseFn to be called on the last mip.
Also, the possibility of a memory leak if the last mipmap update goes wrong is a bit scary.