Runtime bug caused by inconsistent name capitalization from strings bank

Hi

Using FMOD and Unity and after encountering a runtime bug on some platforms with case sensitive file systems (like iOS), I investigated and found a bug that causes strings to be imported with inconsistent capitalization.

This seemingly can occur for any string retrieved from the master strings bank.
When ressources like events and banks are retrieved though their path at runtime, this can cause them to not be found.

The bug occurs when multiple strings start the same but with different capitalization.

I investigated the StringHelper.ThreadSafeEncoding.stringFromNative method in fmod.cs but it seams the bug resides on the native side.
Or maybe the master strings bank file itself is generated with the malformed strings, but I don’t know how to check for that since the file is in a binary format.

My educated guess is that a string buffer isn’t probably invalidated when a new string starts like the string in the buffer but with a different case.

I made a minimal bug reproduction project in which I could reproduce the issue for the event names but not for the bank names. But in our project with a lot of banks and events it happens on both.

Here are some captures from this bug reproduction project showing the capitalization discrepancies :


I hope this helps.
Thanks in advance for your consideration.

2 Likes

Hi,

Thank you for the details and images.

The case inconsistencies are expected due to FMOD using a case insensitive radix tree. More information can be read here: Event ends up with incorrect casing of starting letter - #2 by mathew.

What are the issues you’re experiencing on iOS?

Thank you for your quick answer.

In our project we encountered a problem with a bank that would not load on iOS with a ERR_FILE_NOTFOUND error. The same bank would load fine on other platforms (not entirely sure if OSX had the issue or not)

After investigating, I found out that the capitalization of the bank file and the capitalization of the name of the bank in its path were different.

This was caused by the fact that the bank had first been imported into the Unity project with a certain name and was later renamed in FMOD Studio with the same name but a different capitalization.

For technical reasons we use a modified version of the Unity integration plugin and the bank files are always copied into the Unity project.
After the bank was renamed in FMOD Studio and re-imported into the Unity project, the file on disk didn’t reflect the capitalization change (because of case insensitive file systems and/or Git not handling capitalization changes).

To prevent this error from happening again I decided to add a check on import to ensure that name capitalization match between file names and bank paths.
This is when I realized other banks had the issue.

Since the capitalization of resource paths is not always kept by design, I’d have to check if this loading error behavior can be reproduced with the unmodified integration plugin.

After some testing, I managed to reproduce the problem on iOS with the unmodified integration plugin in my minimal bug reproduction project.

If the capitalization of the bank name doesn’t match the capitalization of the corresponding file name, the bank won’t load with a ERR_FILE_NOTFOUND error.

1 Like

Thank you for the details and your investigation.

Could I please get the reproduction project uploaded to your profile to test on my side?

Just to confirm, is the import Bank Import -> Source Type Single Platform Build?

I uploaded it on my profile under the name “FMOD_MasterBankStrings-GetStringInfo-Case_Bug.zip”

Because I couldn’t reproduce the capitalization issue on the bank names in that project, it’s not that simple to reproduce the loading issue at runtime.

I somehow stumbled upon it quickly last time but it was more difficult to reproduce once I had cleaned up the project a bit and tried to find a way to reproduce it consistently.

In the uploaded project, everything is OK in the Unity project but the XCode project retains a different capitalization of the bank file names because Unity doesn’t check for that when it overwrites existing build files.

This can happen organically if banks are renamed in FMOD Studio and rebuilt from scratch (otherwise filenames in the FMOD Studio build folder retain the previous capitalization).
The integration plugin correctly updates the capitalization of file names in the StreamingAssets folder when the Unity project is built, but Unity doesn’t always forward these modifications when it updates the XCode files.

In this configuration the system fails to load the bank.

I think that creating this situation is way easier if the capitalization of a bank’s name isn’t kept on import (which is what I witnessed in our project where we retrieve bank paths from the strings bank on import, which the unmodified integration plugin might not do).

I tried with Source Type as “Multiple Platform Build” and “FMOD Studio Project” and managed to reproduce the issue with both. I didn’t test “Single Platform Build”.

Thank you for all the detail and the reproduction project.

I was able to reproduce the issue with the built XCode project. However, trying to rebuild the Unity proj I could not get it to happen again.

My steps were:

  1. Build the Unity proj
  2. Change the bank capitalization in FMOD studio
  3. Rebuild the Unity project with the Append option

The bank is loaded without issue. Are these the same steps you are using? I am not seeing the StreamingAssets banks changing with the new capitalization.

Are there any steps I am missing?