Unity - Stop ignoring this subscene bug!

This bug ticket has been closed or ignored without explanation far too many times.

If you are going to force us to have our scripts run in background processes, then turn the **** audio engine on!

Inside a Baker:

var configuration = UnityEngine.AudioSettings.GetConfiguration();
if (configuration.sampleRate == 0)
{
    UnityEngine.AudioSettings.Reset(new AudioConfiguration
    {
        dspBufferSize    = 1024,
        numRealVoices    = 16,
        numVirtualVoices = 256,
        sampleRate       = 48000,
        speakerMode      = AudioSpeakerMode.Stereo
    });
}
configuration            = UnityEngine.AudioSettings.GetConfiguration();
bool speakerModeIsStereo = configuration.speakerMode == AudioSpeakerMode.Stereo;
var  sampleRate          = configuration.sampleRate;
var  bufferSize          = configuration.dspBufferSize;
var  newClip             = UnityEngine.AudioClip.Create("TestClip", 50000, 1, 44100, false);
Debug.Log($"speakersAreStereo: {speakerModeIsStereo}");
Debug.Log($"sampleRate: {sampleRate}");
Debug.Log($"bufferSize: {bufferSize}");
Debug.Log($"new clip ID: {newClip.GetInstanceID()}");
Debug.Log($"new clip name: {newClip.name}");
Debug.Log($"new clip channels: {newClip.channels}");
Debug.Log($"new clip load state: {newClip.loadState}");

8493083--1130066--upload_2022-10-6_3-2-3.png
This stupid bug caused subscene builds to not work for me for the entirety of 2020 and 2021 and not it is completely broken in 2022. I have had bug tickets closed without reason. A bug ticket where I got a response asking for more info (which I gave the next day) and then got ghosted. I’ve mentioned this on the forums about 10 times.

Up until this point, runtime conversion has been my saving grace. Now there’s no workaround.
:rage:
I can’t even name a new audio clip…

Do you mind sharing the bug tickets?

8080 is the last one I made. I haven’t made a new one for Entities 1.0 exp because I got sick and tired of being told “we couldn’t reproduce this”. But if you are actually willing to look into this and skip the whole “let QA process it” step, I can throw something together. But my previous post is basically the reproduction.

I could have sworn I also submitted a bug report for this but looking through emails and now that new bug reports dont have a central page like fogbugz(for us end users at least) maybe I didn’t.

The gist of it is pretty simple, use https://docs.unity3d.com/ScriptReference/AudioClip.GetData.html with a baker(previously conversion), inside of a subscene and there should be errors.

I sort of worked around this by having a scriptable object hold the audio array, using a edit time button to grab every audio clips data to then get converted into blobs for myri during baking but it sure would be nice not to have to do this.

2 Likes

The behavior is very inconsistent for AudioClip.ReadData. Sometimes it works. Sometimes I get errors like this:
8494700--1130483--upload_2022-10-6_13-56-21.png
Which in the Editor log looks like:

[Worker2] Assertion failed on expression: 'length <= m_PCMReadArrayOrigLength'
[Worker2] Received signal SIGSEGV
[Worker2] Obtained 45 stack frames
0x00007ff6187d6135 (Unity) FMOD::SoundI::readData
0x00007ff6187d5b31 (Unity) FMOD::SoundI::read
0x00007ff6187b9e26 (Unity) FMOD::SystemI::createSoundInternal
0x00007ff6187b7510 (Unity) FMOD::SystemI::createSound
0x00007ff6187b1933 (Unity) FMOD::System::createSound
0x00007ff616f02c64 (Unity) LoadFMODSound
0x00007ff616effdeb (Unity) SoundManager::CreateSoundInternal
0x00007ff616ee34bb (Unity) AudioClip::CreateSound
0x00007ff616ee36ca (Unity) AudioClip::CreateUserSound
0x00007ff615cc1b01 (Unity) AudioClip_CUSTOM_CreateUserSound
0x0000020f0920f8be (Mono JIT Code) (wrapper managed-to-native) UnityEngine.AudioClip:CreateUserSound (UnityEngine.AudioClip,string,int,int,int,bool)
0x0000020f0920f4bb (Mono JIT Code) UnityEngine.AudioClip:Create (string,int,int,int,bool,UnityEngine.AudioClip/PCMReaderCallback,UnityEngine.AudioClip/PCMSetPositionCallback)
0x0000020f0920f303 (Mono JIT Code) UnityEngine.AudioClip:Create (string,int,int,int,bool)
0x0000020f0920e893 (Mono JIT Code) [SoundEffectAuthoring.cs:67] Lsss.Authoring.SoundEffectBaker:Bake (Lsss.Authoring.SoundEffectAuthoring)

And sometimes I get hard crashes like this:

[Worker2] FMOD was unable to select requested output: 4: "Cannot call this command after System::init. " (32)
[Worker2] FMOD was unable to select requested output: 4: "Cannot call this command after System::init. " (32)
[Worker2] FMOD was unable to select requested output: 2: "Cannot call this command after System::init. " (32)
[Worker2] Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction
Cancelling DisplayDialog because it was run from a thread that is not the main thread: Fatal Error! [Worker2] Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction


Aborting batchmode due to fatal error:
Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction
UnityEngine.AudioClip:GetData (single[],int)
Latios.Myri.Authoring.Systems.AudioClipSmartBlobberSystem:ReadClip (UnityEngine.AudioClip,Unity.Collections.LowLevel.Unsafe.UnsafeList`1<single>&) (at Packages/com.latios.latios-framework/MyriAudio/Authoring/AudioClipSmartBlobberSystem.cs:222)
Latios.Myri.Authoring.Systems.AudioClipSmartBlobberSystem:OnUpdate () (at Packages/com.latios.latios-framework/MyriAudio/Authoring/AudioClipSmartBlobberSystem.cs:121)
Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:670)
Unity.Entities.ComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:628)
Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:670)
Unity.Entities.ComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:628)
Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
Unity.Entities.BakingUtility:PostprocessBake (Unity.Entities.World,Unity.Entities.BakingSettings,Unity.Entities.BakingSystem) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities.Hybrid/Baking/BakingUtility.cs:102)
Unity.Entities.BakingUtility:BakeScene (Unity.Entities.World,UnityEngine.SceneManagement.Scene,Unity.Entities.BakingSettings,bool,Unity.Entities.IncrementalBakingChangeTracker) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities.Hybrid/Baking/BakingUtility.cs:78)
Unity.Scenes.Editor.EditorEntityScenes:BakeAndWriteEntityScene (UnityEngine.SceneManagement.Scene,Unity.Entities.BakingSettings,System.Collections.Generic.List`1<Unity.Scenes.ReferencedUnityObjects>,Unity.Scenes.Editor.WriteEntitySceneSettings) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Scenes.Editor/EditorEntityScenes.cs:73)
Unity.Scenes.Editor.SubSceneImporter:ImportBaking (UnityEditor.AssetImporters.AssetImportContext,UnityEngine.SceneManagement.Scene,Unity.Scenes.SceneWithBuildConfigurationGUIDs,Unity.Entities.Build.DotsPlayerSettings,Unity.Build.BuildConfiguration,UnityEngine.GameObject) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Scenes.Editor/SubSceneImporter.cs:150)
Unity.Scenes.Editor.SubSceneImporter:OnImportAsset (UnityEditor.AssetImporters.AssetImportContext) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Scenes.Editor/SubSceneImporter.cs:250)
UnityEditor.AssetImporters.ScriptedImporter:GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext)


Crash!!!

========== OUTPUTTING STACK TRACE ==================

0x00007FFCFD784FD9 (KERNELBASE) RaiseException
0x00007FF617A9E80E (Unity) LaunchBugReporter
0x00007FF617461EA4 (Unity) EditorMonoConsole::LogToConsoleImplementation
0x00007FF617462753 (Unity) EditorMonoConsole::LogToConsoleImplementation
0x00007FF61811CFCF (Unity) DebugStringToFilePostprocessedStacktrace
0x00007FF61811C72D (Unity) DebugStringToFile
0x00007FF617D7F9B9 (Unity) OnDemandScheduler::OnLogToConsoleEntry
0x00007FF617E620DA (Unity) ImportWorkerManager::OnMessageReceived
0x00007FF617E62BEC (Unity) WorkerManagerASIO::OnMessageReceived
0x00007FF617E6AF7D (Unity) MessageReader::ReadMessage
0x00007FF617E6AD64 (Unity) MessageReader::Read
0x00007FF617E6C52B (Unity) TcpMessagingSession::OnReceiveCompleted
0x00007FF617E31567 (Unity) asio::asio_handler_invoke<asio::detail::binder2<<lambda_7bb410c7c74bfc0040fa015a32e4550e>,std::error_code,unsigned __int64> >
0x00007FF617E33EEA (Unity) asio::detail::executor_function::complete<asio::detail::binder2<<lambda_7bb410c7c74bfc0040fa015a32e4550e>,std::error_code,unsigned __int64>,std::allocator<void> >
0x00007FF617E295C1 (Unity) asio::io_context::basic_executor_type<std::allocator<void>,4>::execute<asio::detail::executor_function>
0x00007FF617E35323 (Unity) asio::detail::handler_work_base<asio::any_io_executor,void,asio::io_context,asio::executor,void>::dispatch<asio::detail::binder2<<lambda_7bb410c7c74bfc0040fa015a32e4550e>,std::error_code,unsigned __int64>,<lambda_7bb410c7c74bfc0040fa015a32e4550e> >
0x00007FF617E42F75 (Unity) asio::detail::win_iocp_socket_recv_op<asio::mutable_buffers_1,<lambda_7bb410c7c74bfc0040fa015a32e4550e>,asio::any_io_executor>::do_complete
0x00007FF617E2D46E (Unity) asio::detail::win_iocp_io_context::do_one
0x00007FF617E2F0D4 (Unity) asio::detail::win_iocp_io_context::run
0x00007FF617E3F91C (Unity) IOService::Run
0x00007FF617E408CB (Unity) IOService::Impl::ThreadFunction
0x00007FF61681D017 (Unity) Thread::RunThreadWrapper
0x00007FFCFE847034 (KERNEL32) BaseThreadInitThunk
0x00007FFCFFD62651 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Also, now I am getting these every second, even after a restart of Unity:
8494700--1130504--upload_2022-10-6_14-43-7.png

Edit: New Report 18952

This is a little suspect. Have you tried this on a different machine?

  1. It never happens in the main Editor on the main thread, regardless of how many editor instances I have open. It only happens on worker processes.
  2. It happens on some machines, but not others. I haven’t figured out any rhyme or reason yet. This is used in a package I put out on GitHub, and others have brought complaints to me about the issue (in those cases, those were builds for the few people who weren’t using runtime conversion). Once I release a version of the package compatible with 2022.2, I will have more data points to share.
  3. The clip create issue happens 100% of the time on my main machine. I have one report that it didn’t happen on a different machine. I have a backup laptop, but it will probably be a couple weeks until I can test on that.
  4. The GetData issue happens in ~10% of bakes. When it doesn’t happen, I am successfully creating the blob asset and feeding it to my custom audio solution built on DSPGraph. That’s all working flawlessly.
  5. No other application on my system has ever had issues with audio. And audio in the main editors and in running builds have worked 100% correctly every time.
  6. That error message looks like a catch-all error message, and the error messages above it suggest FMOD isn’t being initialized correctly. I don’t have source access, so I can’t really investigate the issue further. But based on past experiences, this sort of behavior where it works 100% on some machines and only a fraction of the time on others, where the times it fails it complains about initialization order, that’s almost exclusively a race condition.

Anyways, I worked around the clip create issue. In that particular use case, I can completely bypass AudioClips and just build the blob assets from the raw procedurally-generated data. I have a project that exclusively does things that way and it is now 100% stable. This isn’t the common case though, so I would really like to see this issue resolved. If there are any tests specific to this machine that I can try (besides reinstall the OS, because I’ve already done that), let me know!

And lastly, I’ve been seeing more and more reports of other UnityEngine systems fail in workers. Text, Navigation, 2D, ect. It seems it isn’t just audio that has initialization issues in the workers. Audio just happens to be the issue I’ve personally encountered and can reproduce fairly consistently.

1 Like

Same crash reproduced both in Unity 2021.3.12f1+Entities 0.51 and Unity 2022.3.10f1+Entities 1.0.16 using LatiosFramwork, when baking AudioClip.

Related thread for enhanced visibility: AudioClip.GetData() crashes in the Editor

1 Like