Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

App takes a long time to load with Play Asset Delivery

Discussion in 'Android' started by Anastasia-Devana, Nov 29, 2020.

  1. Anastasia-Devana

    Anastasia-Devana

    Joined:
    Aug 18, 2013
    Posts:
    20
    I have a 2-scene app (Intro and Main). The app was over 150mb, so I used Google Play Asset Delivery method to put the entire Main scene into an Asset Bundle and then pack into an install-time Play Asset Delivery package.

    So the Intro scene loads the Unity Asset Bundle from the Play Asset Bundle, and then loads the Main scene from that.

    So now that the app is published on the Google Play store, it looks like every time I open the app it takes a significant time to load the Main scene.

    When I was testing locally with just APKs, it was much faster. And also my iOS build that's not broken up also loads much faster.

    I was hoping that the install-time bundles would be much more transparent than that, but right now it's not a great user experience.

    I haven't timed it yet, but it feels like at least 20 seconds to load?

    Does anyone know if this is expected behavior, or if there are ways to improve this? ... @natetrost maybe?
     
  2. natetrost

    natetrost

    Joined:
    Aug 21, 2020
    Posts:
    8
    Do you know how long each step is taking? I'm curious if the source of the delay is in the loading of the asset bundle from the asset pack, or in the actual scene load.

    Install-time asset packs are embedded in the app bundle structure, rather than being discrete files. Although under the hood the asset bundle load still happens via AssetBundle.LoadFromFileAsync (using an offset provided by AssetLocation).

    When you build the asset bundle, is it using BuildAssetBundleOptions.UncompressedAssetBundle? I'm wondering if there is any performance difference with or without asset bundle compression turned on.
     
  3. perchangpete

    perchangpete

    Joined:
    Oct 14, 2016
    Posts:
    13
    I came up against a similar issue while trying to integrate Play Asset Delivery into Addressables. My initial load time on Android increased from 15s-20s to around 5 minutes. This is probably an extreme situation and most projects would see a smaller hit. In my case i load and cache all of my gameplay assets in the inital load so am probably loading a few hundred assets (although none are probably larger than a few kB). The key point was that those assets were inside a unity asset bundle (the bundle is around 90MB) and it seems that the unity asset bundle was being compressed as a result of being inside the android bundle (aab) - it is the android bundle compression settings (not the unity bundle compression) that appear to be the issue. I think that this has resulted in each file load needing a bundle decompress step that otherwise would not have been needed.

    My solution was to embed the google bundle and play delivery packages in my project so that they could be edited and then alter BundletoolHelper.cs in the bundle package:

    private static readonly string[] UnityUncompressedGlob =
    {"assets/**/*.unity3d", "assets/**/*.ress", "assets/**/*.resource", "assets/**/*.obb", "**.bundle"};

    I added in the **.bundle entry.

    This fixed the issue for bundles that are inside the core game (not in downloadable asset packs afaik) but I assume that i will get a similar problem with bundles that are inside packs as I've had to strip the .bundle extensions from my asset pack bundles to get around some file name validation in the play delivery package. I plan to add a step to add the paths of asset pack bundles to the don't compress list inside BundleToolHelper.MakeConfig.

    I figured this out by unzipping and comparing the contents of two aabs - one built using the standard unity system and one built with the play delivery system. The BundleConfig.pb files were very different - it seems that the default unity build (2020.1.14f1) adds a lot of noCompress file extensions that the play delivery package build does not - I assume that people might come up against similar problems with files other than unity bundles and adding the file extension to UnityUncompressedGlob may also fix those issues.
     
  4. kXbira

    kXbira

    Joined:
    Apr 11, 2021
    Posts:
    6
    Hey, I am working on something similar. I am trying to use PAD to load a scene, can you share the script for that? Would be a huge help, thanks
     
  5. pp_dd

    pp_dd

    Joined:
    Feb 7, 2019
    Posts:
    52
    I am also trying to put all scenes except the splash screen and main menu into an asset bundle and set up asset delivery to load it on install time. But those scenes are never loaded at all. It reduces the size of the first installation, but then all level-scenes are missing after installation on a android device…
     
  6. growsolutionsapp

    growsolutionsapp

    Joined:
    May 12, 2021
    Posts:
    16
    PlayAssetBundleRequest bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync("scene");

    AssetBundle assetBundle;
    AssetDeliveryStatus status = bundleRequest.Status;

    switch (status)
    {
    case AssetDeliveryStatus.Pending:
    Debug.Log("Araj : Asset delivery status pending.");
    yield return null;
    break;
    case AssetDeliveryStatus.Retrieving:
    Debug.Log("Araj :Asset delivery status retrieving.");
    yield return null;
    break;
    case AssetDeliveryStatus.Available:

    case AssetDeliveryStatus.Loading:
    Debug.Log("Araj :Asset delivery status loading.");
    yield return null;
    break;
    case AssetDeliveryStatus.Loaded:
    assetBundle = bundleRequest.AssetBundle;
    scene = new string[assetBundle.GetAllScenePaths().Length];
    scene = assetBundle.GetAllScenePaths();
    //scene.Add(assetBundle.GetAllScenePaths());
    Debug.Log("Araj :Asset delivery status loaded.");
    break;
    case AssetDeliveryStatus.Failed:
    Debug.Log("Araj :Asset delivery status failed.");
    break;
    case AssetDeliveryStatus.WaitingForWifi:
    Debug.Log("Araj :Asset delivery status waiting wi fi.");
    break;
    default:
    break;
    }

    This is my code For asset bundle download at Install Time but always return Asset delivery status loading.
     
  7. MattWhiting

    MattWhiting

    Joined:
    Jan 11, 2016
    Posts:
    79
    I have found that
    PlayAssetDelivery.RetrieveAssetBundleAsync(bundleName);
    is taking around 1 minute in the "Loading" phase (as in AFTER it has been downloaded from google play).
    When I replace those with
    AssetBundle.LoadFromFileAsync(...);
    I get similar speeds under default compression. However, changing to ChunkBasedCompression fixed the issue.
    Sadly, once I put the bundles back into PlayAssetDelivery, it STILL takes about 1 minute to Load.

    Did you ever get anywhere with this?