While working with WebGL on Windows 10 using Three.js, I noticed that initializing a large (4096 x 4096) texture causes the main thread of Chrome to stall for a significant amount of time. Surprisingly, the profiler doesn't show any activity during this period.
For instance, when profiling a 4096 x 4096 texture, you can see a "plateau" just before 1500ms which corresponds to a call to texImage2D
in Three.js and WebGL. Subsequently, there are two calls to requestAnimationFrame
followed by an unexplained gap.
What could be causing this delay? Could it be related to some underlying WebGL code in Chrome that is not captured by the profiler? Why does the initial call to texImage2D
take 90 ms, while the subsequent blank spot occurs? One would expect all the GPU texture loading work to be completed within that duration.
Here is a link where you can observe the behavior firsthand.