Forum rules - please read before posting.

Memory problem with huge number of audio clips loaded

Hi PersistentEngine prefab contains RuntimeLanguages component, which calls TransferFromManager method, which get reference to AdvGame.GetReferences ().speechManager, which contains 1600 Lines (of text) with 3 CustomTranslationAudioClips per Line, so in total it’s 1600 * 3 = 4800 audioclips at present time for project(and can be more after adding new languages). But all these audio clips being loaded at first start and produce big memory footprint. How can i manage loading audio clips per scene, not for all game, for more optimized resource control and better scene loading perfomance? Because current optionnot suitable, especially for mobile devices. Thanks

Comments

  • edited October 2018
    What are your AC and Unity version numbers, and are you actually testing on a mobile or just in the Editor?

    Are you manually assigning your speech audio files in the Speech Manager, or relying on naming convention to pull them automatically from a Resources folder?

    Let's also see the footprint you're talking about, screens of your Profiler window.
  • AC - 1.65.0
    Unity - 2018.2.14f1
    Speech audio clips were assigned manual and using AutoAssignCustomAudio.cs - https://pastebin.com/p8hJDqwq (it’s modified script from http://adventure-creator.wikia.com/wiki/Auto-assign_custom_speech_audio) and not stored in Resources folder.
    Screenshot with SpeechManager - http://take.ms/eoIcm
    Screenshot with part of memory footprint with deleted one language and some audios for testing purposes - http://take.ms/PMlal
  • Again though, are you testing in builds or the Editor?

    The audio files themselves are large even by themselves.  Have you tried the various import settings, e.g. the Load Type?

    It may be that auto-assigning them is better in your case.  In my own test with 2000+ audio files, starting the game was considerably faster when relying on the Resources folder method.

    I've updated the the wiki script to go both ways: i.e. also be able to rename/move manually-set audio to an appropriate Resources location.

  • edited October 2018
    Now we are testing standalone version. Mobile will be soon.
    I'm trying to say that we are aiming not on how to speed up game loading (I'm talking about our current task, in overall it's important too) but to reduce memory consumption. All these Import setting etc. can do nothing with it. So we thought, that it could be great, that AC will load Speech for current level only (and maybe Global speech like Inventory events) from level's own folder and even for the language set for this moment. That could reduce memory usage a lot
  • edited October 2018
    I need to know what you're working with.  Show your typical import settings - setting the Load type to Compressed In Memory should be your first step, regardless of whether or not anything further can be done.
  • Now Load type is set to Streaming. http://joxi.ru/v29OZ7ph3n1gJr Different sounds might have different Load type. We are working with such approach: https://blog.theknightsofunity.com/wrong-import-settings-killing-unity-game-part-2/ We really want AC to be the perfect tool for adventure games. But admit, it's not really efficient to store second language, like Russian (which English-speaking player won't use at all) in memory. Instead of that developer can use it to have additional animations or textures.
  • edited November 2018
    As a (very simple for now) test, paste the following into SpeechLine.cs:

    public SpeechLine (SpeechLine _speechLine, int language)
    {
        isPlayer = _speechLine.isPlayer;
        lineID = _speechLine.lineID;
        scene = _speechLine.scene;
        owner = _speechLine.owner;
        text = _speechLine.text;
        description = _speechLine.description;
        textType = _speechLine.textType;
        translationText = _speechLine.translationText;
        customAudioClip = (language == 0) ? _speechLine.customAudioClip : null;
        customLipsyncFile = (language == 0) ? _speechLine.customLipsyncFile : null;
        customTranslationAudioClips = null;
        customTranslationLipsyncFiles = null;
        tagID = _speechLine.tagID;

        #if UNITY_EDITOR
        orderID = _speechLine.orderID;
        orderPrefix = _speechLine.orderPrefix;
        #endif
    }

    Then, open RuntimeLanguages and replace line 67:

    speechLinesDictionary.Add (speechLine.lineID, speechLine);

    With:

    speechLinesDictionary.Add (speechLine.lineID, new SpeechLine (speechLine, 0));

    That will prevent non-original language audio from being loaded - does that work for you?  (Provided you've the original language selected at runtime)
  • Will give it a try. Thank you.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.