Unity Iteration Time Improvements

Oculus Developer Blog
|
Posted by Leonard Tsai and Joe Kirchoff
|
April 28, 2020
|
Share

Developer iteration time is one of the top pain points we hear from Oculus developers. Compared to PC, iteration time on Quest (change -> build -> test loop) can be noticeably longer. We recently released three improvements that significantly decrease Unity iteration time on Quest.

OVR Build APK and Run

The first tool is OVR Build APK and Run, and it can reduce build and deploy time by 10-50% when building an APK. This method utilizes the gradle cache when building your APK. It works just like a normal Unity Build and Run but caches files so that they don’t need to be completely rebuilt again. The final resulting APK produced by the tool will be identical to a Unity build. OVR Build APK and Run is located under the Oculus menu as shown in the screenshot below.

OVR Quick Scene Preview

The second tool is OVR Quick Scene Preview, and it uses Unity’s Asset Bundle system to reduce deployment time. The tool will divide your project and scene into multiple asset bundles and upload them to your device. Then, when you make changes to your scene, the tool will update the changed bundles on your device.

How It Works
The bulk of time spent while iterating comes from having to build, package, and deploy the APK, and for larger projects, this can be time consuming. OVR Quick Scene Preview works by initially building a stripped down APK that contains your project’s code along with an asset bundle loader script. Your project is then divided up by asset type and scenes into individual asset bundles and deployed to an external folder on the device. If you make a change to an asset, only that asset’s corresponding bundle will have to be built and deployed to the device, saving a lot of time.

Results
We worked with the teams creating Beat Saber, Dead and Buried II, and SUPERHOT VR to test OVR Quick Scene Preview in their projects. We also applied these optimizations to the Viking Village sample from the Unity Asset Store. All the projects we tested showed significant improvements in iteration time.

From the table above, you can see that iteration time was reduced by over 80% for each of the projects we tested. We measured the time it takes to make a couple of asset changes as well as scene changes in a project and saw significant reductions in iteration time with OVR Quick Scene Preview.

Shader Stripping

Unity applications running on Oculus Quest by default only load Tier2 shaders; this means that any Tier1 or Tier3 shaders being built are unused by the application and don’t need to be processed or compiled.

How It Works
IPreprocessShaders was added to Unity as of 2018.2, which allows a derived editor class to implement OnProcessShader. Once implemented, OnProcessShader is called whenever a build is started for each shader group, allowing for custom code to modify the list of shaders that will be processed. In this case when Skip Unneeded Shaders is enabled, all Tier1 and Tier3 shaders are removed from the build if Oculus Go or Oculus Quest are selected as the Target Oculus Platform.

Results
Iterating on asset changes still requires processing shaders even if they are already built and up to date. The following timings were measured using the Viking Village sample and are for builds where all shaders have already been built.

For OVR Quick Scene Preview (Build and Deploy), we saw a 31% reduction in iteration time. The improvements for OVR Build APK and Run (Unity Build Player) were even better, resulting in an 54% reduction in iteration time.

We’re continually working to improve the developer experience on Quest, and we’re certainly excited about the results we’ve seen so far. Iteration time is an area we’re invested in, and we believe these three optimizations can greatly reduce developer iteration times. Share your own stories of how you've reduced your iteration time in the comments.

FAQs

When should I use OVR Build APK and Run as opposed to OVR Quick Scene Preview?

OVR Quick Scene Preview is for fast iteration on scenes and assets and does not build an APK that is representative of your final project. As you are developing your project, OVR Quick Scene Preview is useful for reducing iteration time. When close to shipping or when wanting to see a closer representation of what your final project will look and run like, use OVR Build APK and Run. Both OVR Build APK and Run and OVR Quick Scene Preview build in development mode and should not be used to create a final shippable bundle.

I already use asset bundles in my project. Will OVR Quick Scene Preview affect my asset bundles?

No, OVR Quick Scene Preview builds its own asset bundle tags dynamically and does not affect your project’s existing bundle tags.

Where can I go to get more details on how to use these tools?

Unity Build Tools

Shader Stripping Documentation