Graphics loading as black squares (from second thread)

I am working on tackling an issue in which HaxeFlixel hitches when a graphic is loaded. I have determined that the issue occurs when the graphic is first loaded into VRAM; the solution I am working on involves using Context3D.createTexture() and texture.uploadFromBitmapData(bitmap) to upload the texture on demand.

Additionally, by calling this code asynchronously on HTML5 and from a thread on desktop (I’m using haxe-concurrent's Thread Pool) should allow the game to render during this process, thus minimizing or eliminating any freezes at all during loading.

However, I am experiencing an issue with this, where calling uploadFromBitmapData from a separate thread causes the resulting image to render as a black square, and I have not been able to resolve the issue or determine a root cause; I suspect it may have something to do with OpenGL.

I’ve been working to try to create a minimal reproduction of this issue, but if anyone has knowledge in this area I would greatly appreciate the help.

I experienced black textures when trying to load images bigger than 4096x4096, that is the declared limit for WebGL, I don’t know if OpenGL has the same limitation.

I think still use 2048*2048 is goods. many device is not support.