Short delay before tilemap is rendered on map

So I've been digging around recently to figure out what's going on with that issue that the tilemap doesn't render for a few frames when a tileset is loaded for the first time during a session. It can be reproduced very easily. Just start up a clean project and put a parallax on the current map. For a few frames the parallax will be displayed before the actual map.

Now, I've tracked this down to TextureManager.updateTexture() inside of pixi.js where I noticed that tilesets are actually created as render textures (evidently inside TileRenderer.initBounds() as well). The really weird thing about all of this is that if I put a custom sleep method inside Scene_Map.update(), the number of frames the tilemap isn't visible doesn't actually change. Here's the simple custom sleep method just for reference (and it doesn't really count ms properly, but what can you do):

Code:
function _sleep(miliseconds)
{
    var currentTime = new Date().getTime();
    while (currentTime + miliseconds >= new Date().getTime())
    {
    }
}

If it was some issue with async texture loading or some sort of async upload of texture data to the GPU, it would be dependent on time, not on the number of frames. It seems to be about 20 for the specific test map I was using, but using a simple map can be much lower, like 5 or so frames. But it's relatively consistent whether a sleep is used or not.

Does anybody know why this would be happening? If I remove the _hackSubImage() calls inside TileRenderer.bindTextures(), it doesn't really change anything. I would assume that moving data from CPU to GPU in such a manner technically could cause this issue, but this would yet again be time-based and not frame-based. I tried messing with the default resolution of the render textures of 2048, but it didn't change anything either. The probably weirdest thing of all is that character sprites aren't rendered during that time either. It's as if the entire tilemap node and all of its children are just skipped. I couldn't find anything that would cause this inside of pixi-tilemap.js. RectTileLayer.renderWebGL() goes through just fine and gl.drawArrays() / gl.drawElements is called normally. The only thing I can think of that would cause this weird behavior is the fact that tileset textures are created as render targets.

Does anybody know why something like this could happen? And why are render textures used in the first place? And most importantly: is there a decent way to fix this / create a workaround?
Moved to: JavaScript/Plugin Support
Gosh, I’m having this exact issue in current project. Preloading plugins don’t fix it either.

I see a blip of the parallax before the map loads.
If you want your _sleep function to count ms properly, you can use:
https://developer.mozilla.org/en-US/docs/Web/API/Window/performance

Original thread: https://forums.rpgmakerweb.com/threads/short-delay-before-tilemap-is-rendered-on-map.108636/