Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Unity - Stop ignoring this subscene bug!

Discussion in 'Entity Component System' started by DreamingImLatios, Oct 6, 2022.

  1. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    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:
    Code (CSharp):
    1. var configuration = UnityEngine.AudioSettings.GetConfiguration();
    2. if (configuration.sampleRate == 0)
    3. {
    4.     UnityEngine.AudioSettings.Reset(new AudioConfiguration
    5.     {
    6.         dspBufferSize    = 1024,
    7.         numRealVoices    = 16,
    8.         numVirtualVoices = 256,
    9.         sampleRate       = 48000,
    10.         speakerMode      = AudioSpeakerMode.Stereo
    11.     });
    12. }
    13. configuration            = UnityEngine.AudioSettings.GetConfiguration();
    14. bool speakerModeIsStereo = configuration.speakerMode == AudioSpeakerMode.Stereo;
    15. var  sampleRate          = configuration.sampleRate;
    16. var  bufferSize          = configuration.dspBufferSize;
    17. var  newClip             = UnityEngine.AudioClip.Create("TestClip", 50000, 1, 44100, false);
    18. Debug.Log($"speakersAreStereo: {speakerModeIsStereo}");
    19. Debug.Log($"sampleRate: {sampleRate}");
    20. Debug.Log($"bufferSize: {bufferSize}");
    21. Debug.Log($"new clip ID: {newClip.GetInstanceID()}");
    22. Debug.Log($"new clip name: {newClip.name}");
    23. Debug.Log($"new clip channels: {newClip.channels}");
    24. Debug.Log($"new clip load state: {newClip.loadState}");
    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.
    :mad:
    I can't even name a new audio clip...
     
  2. topher_r

    topher_r

    Unity Technologies

    Joined:
    Jun 14, 2019
    Posts:
    36
    Do you mind sharing the bug tickets?
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    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.
     
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    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.
     
    DaxodeUnity and DreamingImLatios like this.
  5. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    The behavior is very inconsistent for AudioClip.ReadData. Sometimes it works. Sometimes I get errors like this:
    upload_2022-10-6_13-56-21.png
    Which in the Editor log looks like:
    Code (CSharp):
    1. [Worker2] Assertion failed on expression: 'length <= m_PCMReadArrayOrigLength'
    2. [Worker2] Received signal SIGSEGV
    3. [Worker2] Obtained 45 stack frames
    4. 0x00007ff6187d6135 (Unity) FMOD::SoundI::readData
    5. 0x00007ff6187d5b31 (Unity) FMOD::SoundI::read
    6. 0x00007ff6187b9e26 (Unity) FMOD::SystemI::createSoundInternal
    7. 0x00007ff6187b7510 (Unity) FMOD::SystemI::createSound
    8. 0x00007ff6187b1933 (Unity) FMOD::System::createSound
    9. 0x00007ff616f02c64 (Unity) LoadFMODSound
    10. 0x00007ff616effdeb (Unity) SoundManager::CreateSoundInternal
    11. 0x00007ff616ee34bb (Unity) AudioClip::CreateSound
    12. 0x00007ff616ee36ca (Unity) AudioClip::CreateUserSound
    13. 0x00007ff615cc1b01 (Unity) AudioClip_CUSTOM_CreateUserSound
    14. 0x0000020f0920f8be (Mono JIT Code) (wrapper managed-to-native) UnityEngine.AudioClip:CreateUserSound (UnityEngine.AudioClip,string,int,int,int,bool)
    15. 0x0000020f0920f4bb (Mono JIT Code) UnityEngine.AudioClip:Create (string,int,int,int,bool,UnityEngine.AudioClip/PCMReaderCallback,UnityEngine.AudioClip/PCMSetPositionCallback)
    16. 0x0000020f0920f303 (Mono JIT Code) UnityEngine.AudioClip:Create (string,int,int,int,bool)
    17. 0x0000020f0920e893 (Mono JIT Code) [SoundEffectAuthoring.cs:67] Lsss.Authoring.SoundEffectBaker:Bake (Lsss.Authoring.SoundEffectAuthoring)
    And sometimes I get hard crashes like this:
    Code (CSharp):
    1. [Worker2] FMOD was unable to select requested output: 4: "Cannot call this command after System::init. " (32)
    2. [Worker2] FMOD was unable to select requested output: 4: "Cannot call this command after System::init. " (32)
    3. [Worker2] FMOD was unable to select requested output: 2: "Cannot call this command after System::init. " (32)
    4. [Worker2] Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction
    5. 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
    6.  
    7.  
    8. Aborting batchmode due to fatal error:
    9. Unable to initalize any audio device (even FMOD nosound device), please check your audio drivers and/or hardware for malfunction
    10. UnityEngine.AudioClip:GetData (single[],int)
    11. 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)
    12. Latios.Myri.Authoring.Systems.AudioClipSmartBlobberSystem:OnUpdate () (at Packages/com.latios.latios-framework/MyriAudio/Authoring/AudioClipSmartBlobberSystem.cs:121)
    13. Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
    14. Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:670)
    15. Unity.Entities.ComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:628)
    16. Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
    17. Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:670)
    18. Unity.Entities.ComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:628)
    19. Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
    20. 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)
    21. 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)
    22. 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)
    23. 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)
    24. 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)
    25. UnityEditor.AssetImporters.ScriptedImporter:GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext)
    26.  
    27.  
    28. Crash!!!
    29.  
    30. ========== OUTPUTTING STACK TRACE ==================
    31.  
    32. 0x00007FFCFD784FD9 (KERNELBASE) RaiseException
    33. 0x00007FF617A9E80E (Unity) LaunchBugReporter
    34. 0x00007FF617461EA4 (Unity) EditorMonoConsole::LogToConsoleImplementation
    35. 0x00007FF617462753 (Unity) EditorMonoConsole::LogToConsoleImplementation
    36. 0x00007FF61811CFCF (Unity) DebugStringToFilePostprocessedStacktrace
    37. 0x00007FF61811C72D (Unity) DebugStringToFile
    38. 0x00007FF617D7F9B9 (Unity) OnDemandScheduler::OnLogToConsoleEntry
    39. 0x00007FF617E620DA (Unity) ImportWorkerManager::OnMessageReceived
    40. 0x00007FF617E62BEC (Unity) WorkerManagerASIO::OnMessageReceived
    41. 0x00007FF617E6AF7D (Unity) MessageReader::ReadMessage
    42. 0x00007FF617E6AD64 (Unity) MessageReader::Read
    43. 0x00007FF617E6C52B (Unity) TcpMessagingSession::OnReceiveCompleted
    44. 0x00007FF617E31567 (Unity) asio::asio_handler_invoke<asio::detail::binder2<<lambda_7bb410c7c74bfc0040fa015a32e4550e>,std::error_code,unsigned __int64> >
    45. 0x00007FF617E33EEA (Unity) asio::detail::executor_function::complete<asio::detail::binder2<<lambda_7bb410c7c74bfc0040fa015a32e4550e>,std::error_code,unsigned __int64>,std::allocator<void> >
    46. 0x00007FF617E295C1 (Unity) asio::io_context::basic_executor_type<std::allocator<void>,4>::execute<asio::detail::executor_function>
    47. 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> >
    48. 0x00007FF617E42F75 (Unity) asio::detail::win_iocp_socket_recv_op<asio::mutable_buffers_1,<lambda_7bb410c7c74bfc0040fa015a32e4550e>,asio::any_io_executor>::do_complete
    49. 0x00007FF617E2D46E (Unity) asio::detail::win_iocp_io_context::do_one
    50. 0x00007FF617E2F0D4 (Unity) asio::detail::win_iocp_io_context::run
    51. 0x00007FF617E3F91C (Unity) IOService::Run
    52. 0x00007FF617E408CB (Unity) IOService::Impl::ThreadFunction
    53. 0x00007FF61681D017 (Unity) Thread::RunThreadWrapper
    54. 0x00007FFCFE847034 (KERNEL32) BaseThreadInitThunk
    55. 0x00007FFCFFD62651 (ntdll) RtlUserThreadStart
    56.  
    57. ========== END OF STACKTRACE ===========
    Also, now I am getting these every second, even after a restart of Unity:
    upload_2022-10-6_14-43-7.png

    Edit: New Report 18952
     
    Last edited: Oct 7, 2022
  6. topher_r

    topher_r

    Unity Technologies

    Joined:
    Jun 14, 2019
    Posts:
    36
    This is a little suspect. Have you tried this on a different machine?
     
  7. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    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.
     
    Occuros likes this.
  8. ShadLady

    ShadLady

    Joined:
    Mar 19, 2019
    Posts:
    8
    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.
     
  9. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983