I have created 2 canvas. One in the main thread where all the animation is happening and the other one is offScreenCanvas in web-worker. I am passing my textures to web-worker to pre-load them on GPU using initTexture() to avoid lag in the main thread. I wanted to ask if main thread canvas use the same pre-loaded textures or load them separately on render call?
You can use
OffscreenCanvas to render the entire scene in a worker in order to avoid framedrops because of processing overhead in the main thread. The following example demonstrates this feature:
However, it is not possible to upload textures to the GPU in one thread and perform the actual rendering in another one. Using two canvas elements does not work either since you will produce 2 WebGL rendering contexts. And you can’t share WebGL resources (like textures, shader programs or buffers) across contexts.