I have parallelShaderCompile disabled in an application, but this results in meshes causing the application to stutter when they first come into the camera view. Is it possible to avoid this, e.g. by manually calling some sort of “preload” function in advance?
Demo here, where the camera animation will stutter when it first brings the model into view.
The stutter is reduced from what it was previously (~5-6 frame loss), but there is still a consistent 1 frame loss right before the object comes on screen. I created a screen capture, and the frame drop can be noticed at frame 151, where the same frame is repeated twice. It’s such a quick drop that the FPS counter and the performance monitor don’t show any major issue.
Can you try setting alwaysSelectAsActiveMesh to true on all the loaded meshes ?
This is more of a “passive” solution, as assigning alwaysSelectAsActiveMesh doesn’t immediately trigger the lag, it queues it up for later in the rendering process. Contrast this with the mesh.render hack I mentioned above, which occurs instantly. So it does seem to make the lag not happen later on, but I would prefer if it could be invoked immediately.
Additionally, the side effect of disabling frustum clipping test is probably not desirable in the general use case.
Is it happening only in the playground ?
Same thing happens on a local test webpage I set up using the same code.
Ok so the last step is doing a perf capture in Edge or Chrome during the loading so we could spot the delay and see where it is hanging as I can unfortunately not repro locally as well would be great if you can try this ?
Are you seeing a stutter when capturing the profile? Looking at the screenshots in your profile, it doesn’t seem to stutter. I also don’t see the stutter when capturing on my machine. I can only repro when not profiling.
I was able to resolve my loading issues by tracing all calls to ThinEngine._compileRawShader to see what functions were incurring shader compilation, and then preloading materials by manually calling Mesh.isReady. Various mesh and material properties sometimes had to be adjusted to get the desired shader variant to compile.