0
Answered

AssetBundles on AOT Platforms

mimminito 2 years ago updated 2 years ago 5

Hi,

I have been playing around with bolt and so far its been great. Thanks for the work on this, much needed update for the visual scripting scene in Unity.

When building for mobile (Android and iOS) we have switched to using Asset Bundles in some of our projects to keep the initial build size down. 

I have read on here that AOT pre build does not work for Asset Bundles, so I assume this means the following:

  • Anything included in the project since the last AOT Pre-Build and app build will work with asset bundles.
  • Anything added "after" the last app release (new scripts or plugins) will not work within newly created asset bundles without us doing an AOT Pre-Build + app build update?

Is this correct? I am struggling to search on the community, it only shows the last 5 results (unless there is a way to show more?) so apologies if this has been covered before.

Thanks, Adam

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by mimminito 2 years ago

Hmmm

good question.

When i added something to the project i make a AOT prebuilld before i build.
Its save and it doesn't take too lang.

Maybe an an auto AOT prebuild function could be handy.

Did you made a test-project for AOT AssetBundles?

I'm trying since one month the get my AssetBundles to load in a WebGL project but no success so far.

Answered

Hi Adam!

Your assumptions are correct. AOT pre-build generates "fake" scripts that pretend to be calling the methods and properties you use in your graphs. This keeps the Unity IL2CPP compiler from stripping them and making them unavailable at runtime. To do so, it scans:

  • Every macro
  • Every prefab for machine with embeds
  • Every scene for objects with machines with embeds

Any graph that was available during the (pre-)build of your core app will still be available in asset bundles. However, graphs that were not will not have the stub scripts generated, and will likely throw errors if ran from AOT bundles. 

This is the same limitation as Unity, really: asset bundles cannot include new scripts. And for the same reason, too: these scripts can't be compiled just-in-time (JIT) on some platforms, namely iOS.

Thanks Lazlo, helpful to know. Will there ever be a workaround for the platform limitations in your opinion?

I don't think that will ever happen, because any solution would require JIT compilation on AOT platforms, which is not only often technically not possible, but also sometimes forbidden by the provider's terms (on iOS for instance).

Sure, thanks again for the help.