Parallel environment generation #2870
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This may have been a problem for a while but I just noticed it when I was doing performance checks for another PR: The environment was getting generated completely before the GLB model was fetched. This is bad because fetching is generally the long-pole to getting our render up and is completely async compared to all the JS we run. Therefore we definitely want to start our fetch before any long, blocking JS functions. Generating the environment is one such long, blocking call. I've fixed it here in a slightly hacky way, but it's simple and non-dangerous.
To aid in debug, I also made a refactor I've been meaning to do for some time, which is to centralize our calls to ModelScene.isDirty into functions, so that it's easy to put console logs in to see what triggers rendering. I also discovered
console.trace()
which is awesome, because with one line I can see exactly what caused every re-render.