Long freeze when loading level from asset bundle in Application.Integrate Assets in Background

I’m experimenting with asset bundles and have it now working so that I can load a level from an asset bundle with this code:

IEnumerator PreloadLevel (string levelUrl){
    WWW www = WWW.LoadFromCacheOrDownload (levelUrl, versionId);
    yield return www;
    if (www.error != null) {
        Debug.Log ("WWW error: " + www.error);
    var ab = www.assetBundle;

I then load the level with Application.Loadlevel. However, Unity freezes for about 5 seconds before the level is loaded. The profiler shows that this happens in Application.Integrate Assets in Background.

Am I missing something here and is there a way I can eliminate this delay?

There seems to be some discrepancy in the Unity docs regarding Asynchronous level loading. For instance, on the page for Application.LoadLevelAsync, it states:

“This allows you to load new levels while still playing the current one, show a progress bar or create a completely streaming world where you constantly load and unload different parts of the world based on the player position, without any hiccups in game play.”

However, the docs then acknowledge that asynchronous loading can have an impact on game performance, or else the Application.backgroundLoadingProperty wouldn’t exist.

So as far as I can tell, asynchronous loading will probably always have some impact on game performance.

The only thing you can try is changing the value for Application.backgroundLoadingPriority. Do this with the following code:

Application.backgroundLoadingPriority = ThreadPriority.Low;

More information can be found here