Optimization with shaders on Magic Leap 2

Hello, I'm trying to optimize the Unity scene on Magic Leap. Currently every time an object with a new shader is presented, frames drop. When the scene reloads these frame drops don't occur again. To attempt to fix this, I've tried using Shader.WarmupAllShaders() in the beginning of the application. I've also already tried preloading shaders into the graphic settings. Is there a setting that I can use with Magic leap 2 to bypass this problem? Attached is a screenshot of what the Unity profiler is saying about those dropped frames.

I'm using Magic Leap SDK 0.53.2, and unity version 2022.2.0b4 with Windows 10

Thank you!

1 Like

Hi @anna.shabayev, I have reached out to our engineers and will report back asap with their response. Thanks very much.

1 Like

Unfortunately there is no Magic Leap 2-specific way of solving this in Unity, as Unity uses Vulcan on Magic Leap 2. For native C API developers, ml_graphics api does offer a convenient utility function to cache the opengl shaders (MLGraphicsEnableBlobCacheGL()), but that will not work in this instance.

Since you've already tried the default methods for Vulcan as you described above, are you able to try this on a regular Android device or smartphone to reproduce this issue?

Also, is this happening on every launch or after the first launch of a fresh install?

1 Like

Hi @anna.shabayev, any progress on this? Thanks.

1 Like

Hi, this task has now been put in the backlog, but when I get to it, I'll update on how it runs on a smartphone.

This issue happens on every launch.

Thanks!

1 Like

Hi @anna.shabayev, if you don't mind I'm going to close this out, but please feel free to post on this same topic when you are able to restart the project. Thanks and best of luck.

2 Likes