# RuntimeManager.LoadBank fail

**URL:** <https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119>\
**Category:** Unity\
**Tags:** unity\
**Created:** [April 15, 2023, 10:03am UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119 "2023-04-15T10:03:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![guku001](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@guku001](https://qa.fmod.com/u/guku001)\
**Post date:** [April 15, 2023, 10:03am UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/1 "2023-04-15T10:03:34Z")

</div>

in unity 2021.3.16f1

BankLoadException: [FMOD] Could not load bank ‘J:/FMODProject/Genesis/Build/Desktop/SFX.bank’ : ERR\_INVALID\_HANDLE : An invalid object handle was used.

```auto
int maxchannels = 128;
RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>("Assets/Res/Sound/Fmod/SFX.bytes", out var outAREx);
RuntimeManager.LoadBank(bankAsset);

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9a7bfbf16fd650e91d9318d2fbb95b082b32e7b0.png)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [April 18, 2023, 2:57am UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/2 "2023-04-18T02:57:32Z")

</div>

Hi,

What version of FMOD are you using? I will link to our documentation on the subject under [Unity Integration | User Guide - Asset Bundles and Addressables](https://fmod.com/docs/2.02/unity/user-guide.html#using-assetbundles).

This indicates that there might be an issue with the `TextAsset` you are passing into the `LoadBank()` function.  
Could you try the following code:

> **Load Bank Assets**
>
> ```auto
> void Awake()
> {
> var assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "banks"));
> if (assetBundle == null)
> {
> Debug.LogError("Failed to load AssetBundle!");
> return;
> }
> 
> foreach (var name in assetBundle.GetAllAssetNames())
> {
> FMODUnity.RuntimeManager.LoadBank(assetBundle.LoadAsset<TextAsset>(name));
> }
> 
> Debug.Log("Succesfully loaded assetBundle");
> 
> assetBundle.Unload(false);
> }
> 
> ```

Using that make sure the banks `.bytes` file is marked as so:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8e9415a29c9650c14af7ed139a2046cfff7799a5.png)  
Hope this helps!

---

<div class="post-metadata">

**Author:** ![guku001](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@guku001](https://qa.fmod.com/u/guku001)\
**Post date:** [June 6, 2023, 3:06pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/4 "2023-06-06T15:06:41Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/dcbe773bd61ff488f860ade04ebaeb5ba015a00b.png)

```auto
int maxchannels = 128;
 RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>(Common.RES_ROOT_PATH + "Sound/Fmod/SFX.bytes", out var outAREx); //bankAsset.text is bank stub:SFX
RuntimeManager.LoadBank(bankAsset);

```

I feel something wrong

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 6, 2023, 11:51pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/5 "2023-06-06T23:51:22Z")

</div>

Hi,

Could you elaborate on the issue? Are you still getting the same error as the original post?

> [@guku001](#):
>
> BankLoadException: [FMOD] Could not load bank ‘J:/FMODProject/Genesis/Build/Desktop/SFX.bank’ : ERR\_INVALID\_HANDLE : An invalid object handle was used.

---

<div class="post-metadata">

**Author:** ![guku001](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@guku001](https://qa.fmod.com/u/guku001)\
**Post date:** [June 11, 2023, 12:36pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/7 "2023-06-11T12:36:07Z")

</div>

I still getting the same error as the original post  
help

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 13, 2023, 11:00pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/8 "2023-06-13T23:00:01Z")

</div>

In the documentation I linked in the previous post:

> [@Connor\_FMOD](#):
>
> I will link to our documentation on the subject under [Unity Integration | User Guide - Asset Bundles and Addressables](https://fmod.com/docs/2.02/unity/user-guide.html#using-assetbundles).

It has information about the bank stubs, in summary: “At build time, each asset is filled with the actual bank data for the build platform, so it can be included in the build. When the build finishes, each asset is reset to stub data.”

The stub will get filled with data at build time thus causing the difference in size when viewed in the asset browser.

Would it be possible to see the full script you are using to load in the bank stubs?

---

<div class="post-metadata">

**Author:** ![guku001](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@guku001](https://qa.fmod.com/u/guku001)\
**Post date:** [June 14, 2023, 6:02pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/9 "2023-06-14T18:02:59Z")

</div>

I use Yooasset to package to generate bundle files

I found that the following code is not called, why?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/b/b6970368a600c3042c5d9f3258a8b073a8a22b65.png)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 15, 2023, 4:43am UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/10 "2023-06-15T04:43:21Z")

</div>

Hi,

> [@guku001](#):
>
> I found that the following code is not called, why?

This is an initializer function and is called by the class when building the project.

Apologies, I missed this before:

```auto
int maxchannels = 128;
RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); 
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>(Common.RES_ROOT_PATH + "Sound/Fmod/SFX.bytes", out var outAREx); //bankAsset.text is bank stub:SFX
RuntimeManager.LoadBank(bankAsset);

```

A couple of things to change here:

1. Could you please elaborate on why you are initializing an FMOD system here? There should already be one created by the integration.
2. The line `RuntimeManager.LoadBank(bankAsset);` may be trying to load the `TextAsset` before it is ready. I would suggest creating a coroutine using `while(RuntimeManager.AnyBankLoading()) yield return;` to make sure that all banks have loaded before trying to continue.

Again, could I suggest trying to use the code I provided above:

> [@Connor\_FMOD](#):
>
> Load Bank Assets
> 
> ```auto
> void Awake()
> {
> var assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "banks"));
> if (assetBundle == null)
> {
> Debug.LogError("Failed to load AssetBundle!");
> return;
> }
> 
> foreach (var name in assetBundle.GetAllAssetNames())
> {
> FMODUnity.RuntimeManager.LoadBank(assetBundle.LoadAsset<TextAsset>(name));
> }
> 
> Debug.Log("Succesfully loaded assetBundle");
> 
> assetBundle.Unload(false);
> }
> 
> ```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![guku001](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@guku001](https://qa.fmod.com/u/guku001)\
**Post date:** [June 17, 2023, 5:40pm UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/12 "2023-06-17T17:40:38Z")

</div>

Thanks for your reply, I will check my code and don’t initialize manually anymore.

But before that, there is already a problem with generating the Bundle package, and I need to find a way to solve the problem of generating the Bundle package.

Because the function registered by Fmod has not been called, I manually call CopyToStreamingAssets and UpdateBankStubAssets, but the size of the generated bundle file is still wrong

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f56cc08bd97481c45dd39e7b0701826c856c7f9b.png)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 20, 2023, 12:11am UTC](https://qa.fmod.com/t/runtimemanager-loadbank-fail/20119/13 "2023-06-20T00:11:11Z")

</div>

Hi,

Would it be possible to get a stripped-out Unity project and the FMOD Studio project [uploaded to your profile](https://fmod.com/profile#uploads)? You will need to [register a project](https://fmod.com/profile#projects) with us to do so. This will allow me to test the issue on my side where I can step through the code.
