oculus-samples / Unity-StarterSamples

This repository brings multiple samples that can help you explore features and bring them into your project.
Other
142 stars 40 forks source link

Meta Core SDK adds over a second to entering play mode and recompile time #19

Open WikkidEdd opened 2 months ago

WikkidEdd commented 2 months ago

Fast iteration is a key part of using Unity. Entering play mode and recompile times can play a big part in slowing iteration cycles.

We recently spent some time profiling our project iteration time using Editor Iteration Profiler. Upon doing so we found that there are a number of classes in the Meta Core SDK that is using the [InitializeOnLoad] attribute. This gets called every time the assembly gets reloaded.

The worst offender is the GuideProcessor which alone adds over a second when entering play mode and allocates over 120mb of memory!

image

This GuideProcessor only seems to be used by the Guide Window, but it runs even if you don't have that windows open

image

It would be great if this could optimized. There doesn't seem to be any need for that code to be run apart from when the guide window is open.

While this is the worst example, there are other usages [InitializeOnLoad] where if they were all cleaned up could save considerable time during iteration.