Multiple issues after upgrading to Unity 2.01.09 from 2.01.08

I recently upgraded to Unity 2.01.09 package and am encountering the following issues:

    1. When building with IL2CPP ON, I get “StaticPluginManager does not exist in the current context” (Plaform.cs line 266). The class is simply missing. Why? I had to comment this line out for now. Whatever that means, I am not using any “static” plugin.
      Screenshot_7


    1. Every time my C# gets recompiled, I have to wait for FMOD to do some obscur reimport work. I have tens of bank files (using AssetBundles Import Type) and it is significantly slowing down my workflow. The only temporary solution I found was so far to comment out “EditorApplication.delayCall += Startup” in EventManager.cs (line 450). I’ve notice this import window happening at random times, when it should definitely not. What is happening here?
      Screenshot_6


    1. When I build and run a Development build, my app doesn’t start because of a missing library called libfmodstudioL. I’ve checked its settings under FMOD\lib\android\arm64-v8a and “Android” is NOT checked. Checking it had no effect either. That problem doesn’t happen with a Prod build. Why is that happening?

All those issues happened after upgrading from 2.01.08. I do need 2.01.09 because it fixes a bug related to the “Build banks to folders mirroring the banks browser hierarchy” option.

Any help on those issues would be much appreciated. Thanks!

Thanks for letting us know about these issues - sorry you’re seeing so many!

This class should be generated by Settings.PreprocessStaticPlugins() when the scripting backend is IL2CPP. I’m not sure why it isn’t being generated in your case - perhaps you’re triggering the build in a way that we don’t handle correctly? Do you trigger the build by clicking Build in the Build Settings window, or some other way?

Is your FMOD Studio project on a different drive from your Unity project? If so, it’s possible that the file timestamps have different resolutions, which could make it seem like the bank assets are always out of date, so FMOD keeps reimporting them.

This library should be enabled by Settings.SelectBinaries(). I’m not sure why that isn’t working - is it possible for you to put a breakpoint in that function and see if it gets called when you build a player?

Thanks for the quick reply @ben_fmod

  1. I use a custom build script calling BuildPipeline.BuildPlayer. Though, I tried again today, uncommenting this section, and it worked. I have no idea what changed. I didn’t even restart Unity :face_with_raised_eyebrow:

  2. My FMOD project is in the root directiory (next to the Assets folder). Not sure why the timestamp would be changing. Could you please give me direction on how to debug that?

  3. Just placed a break point in there, and it seems like SelectBinaries is being called with binaryType=Release even though I’m building with the BuildOptions.Development flag ON. Further up, in OnPreprocessBuild, EditorUserBuildSettings.activeScriptCompilationDefines does not contains "DEVELOPMENT_BUILD". Not sure what would be the reason. That issue remains, I can only run Prod builds at the moment, which is very problematic
    (EDIT: as a workaround, I forced binaryType = Platform.BinaryType.Logging and that made the trick, I can run Dev build again)

Well… it’s back :sweat_smile:

In fact, it happens when I try to build my AssetBundles (via Addressables) with AddressableAssetSettings.BuildPlayerContent(). I should have realized that yesterday, my bad!

Thanks, I have now reproduced this issue. AddressableAssetSettings.BuildPlayerContent() ends up calling PlayerBuildInterface.CompilePlayerScripts(), which unfortunately does not call IPreprocessBuildWithReport.OnPreprocessBuild(), which we rely on to generate the StaticPluginManager class.

I’m still looking into a way to fix this, but as a workaround you could try making Settings.PreprocessBuild() public, and calling it before calling AddressableAssetSettings.BuildPlayerContent():

FMODUnity.Settings.Instance.PreprocessBuild(BuildTarget.StandaloneWindows64, FMODUnity.Platform.BinaryType.Logging);
AddressableAssetSettings.BuildPlayerContent();

Could you put a breakpoint on EventManager.cs line 623, and compare sourceInfo with targetInfo? That may shed some light on the issue.

    if (!targetInfo.Exists ||
        sourceInfo.Length != targetInfo.Length ||
        sourceInfo.LastWriteTime != targetInfo.LastWriteTime)
    {
        if (targetInfo.Exists) // <------------------------------ Breakpoint here
        {
            targetInfo.IsReadOnly = false;
        }

This sounds like the issue reported in this thread. Can you try the solution suggested there?

Thanks again for your support @ben_fmod

These workarounds will definitely help waiting for 2.01.10

I put a breakpoint there but it doesn’t trigger when code recompiles (even though I see banks being reimported):

Let me know if you wish me to try anything else. Or I’d be happy to jump on a call if you want to dig further (I’m based in France).

Thanks for the additional info. I’m still trying to figure out what could be causing the reimport, and that helps to narrow it down. Unfortunately I’m going to be on leave next week, but I should be able to get back to you the week after that.

Sounds good. Waiting for your feedback then.

I’d like to make a suggestion as well: it’d be great if you guys could revert any platform dependent change post-build to avoid version control mess.

This is what Plastic looks like after I built in Development mode (files were previously versioned for Prod).

FYI, issue (1) regarding the StaticPluginManager also exists with v2.02.00 of the Unity integration.

Hello, very bad english ahead : we are also having issues after upgrading our Unity version to 2020.3.4 and our Fmod version to 2.01.09, i’ve tried to add
“FMODUnity.Settings.Instance.PreprocessBuild(BuildTarget.StandaloneWindows64, FMODUnity.Platform.BinaryType.Logging)”;
just before
“AddressableAssetSettings.BuildPlayerContent()”

It didn’t fix the problem, i’m also not sure if it is the same issue because what i can observe is that we seem to have no issue with a default build but whenever i’m trying to automate our build process through our build scripts we have errors at runtime not during the build process.

Our console indicates : fmodstudioL not found, when we build through our automated build process

FMODUnity.SystemNotInitializedException: [FMOD] Initialization failed —> System.DllNotFoundException: fmodstudioL
at (wrapper managed-to-native) FMOD.Memory.FMOD5_Memory_GetStats(int&,int&,bool)
at FMOD.Memory.GetStats (System.Int32& currentalloced, System.Int32& maxalloced, System.Boolean blocking) [0x00001] in *\Assets\Plugins\FMOD\src\Runtime\wrapper\fmod.cs:890

So we found a work around before building addressable

create a script in runtime folder of fmod with this inside
// This file was generated by FMOD for Unity from the Static Plugins list in the FMOD settings.

using System;
using System.Runtime.InteropServices;

namespace FMODUnity
{
class StaticPluginManager
{
[DllImport(FMOD.VERSION.dll)]
private static extern FMOD.RESULT FMOD5_System_RegisterDSP(IntPtr system, IntPtr description, IntPtr handle);

    public static void Register(FMOD.System coreSystem, Action<FMOD.RESULT, string> reportResult)
    {
    }
}

}

Build adressables
Then very important : you have to delete it before building the game…
At least you can continue working on your project

Any progress on a permanent fix would be much appreciated

Any updates ?

We now have a fix for the StaticPluginManager issue. It will be in the 2.01.10 release, which should be released in the next couple of weeks.

In the meantime, you should be able to work around it by adding a using System.Reflection; line to the top of Platform.cs, and replacing Platform.LoadStaticPlugins() with this code:

        // Loads static FMOD plugins for this platform.
        public virtual void LoadStaticPlugins(FMOD.System coreSystem, Action<FMOD.RESULT, string> reportResult)
        {
            if (StaticPlugins.Count > 0)
            {
#if !UNITY_EDITOR && ENABLE_IL2CPP
                // We use reflection here to avoid compile errors if the plugin registration code doesn't exist.
                // It should be generated by Settings.PreprocessStaticPlugins(), which is called from
                // IPreprocessBuildWithReport.OnPreprocessBuild(). However, some compilation scenarios
                // (such as AddressableAssetSettings.BuildPlayerContent()) don't call OnPreprocessBuild(),
                // so we can't generate the plugin registration code.

                string className = string.Format("FMODUnity.{0}", RegisterStaticPluginsClassName);
                Type type = Type.GetType(className);

                if (type == null)
                {
                    Debug.LogWarningFormat(
                        "FMOD: {0} static plugins specified, but the {1} class was not found.",
                        StaticPlugins.Count, className);
                    return;
                }

                MethodInfo method = type.GetMethod(RegisterStaticPluginsFunctionName,
                    BindingFlags.Public | BindingFlags.Static);

                if (method == null)
                {
                    Debug.LogWarningFormat(
                        "FMOD: {0} static plugins specified, but the {1}.{2} method was not found.",
                        StaticPlugins.Count, className, RegisterStaticPluginsFunctionName);
                    return;
                }

                method.Invoke(null, new object[] { coreSystem, reportResult });
#else
                Debug.LogWarningFormat(
                    "FMOD: {0} static plugins specified, but static plugins are only supported on the IL2CPP scripting backend",
                    StaticPlugins.Count);
#endif
            }
        }

This sounds like the issue reported in this thread. Can you try the solution suggested there?

1 Like

Thanks, that’s a good idea - I’ve added it to our issue tracker.

Thanks, can you try commenting out the call to RemoveEmptyFMODFolders() from EventManager.CopyToStreamingAssets() (line 663)?

Thank you so much gonna checkout those on Monday

Thanks, I’ll try this on Monday too and get back to you asap

@ben_fmod I confirm commenting out RemoveEmptyFMODFolders() (on line 646) fixed the issue! Banks reimport don’t anymore happen on every code change.

Thank you! We should have a fix for this issue in the 2.01.11 release.

If you have time, would you be able to try the proposed fix? It still needs to go through QA, but all you need to do is uncomment the call to RemoveEmptyFMODFolders() and delete the AssetDatabase.ImportAsset(assetPath) line from EventManager.AssetHasLabel():

        private static bool AssetHasLabel(string assetPath, string label)
        {
            AssetDatabase.ImportAsset(assetPath); // <--- Delete this line
            UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath);
            string[] labels = AssetDatabase.GetLabels(asset);

            return labels.Contains(label);
        }