gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
334 stars 70 forks source link

some interesting bugs #17

Closed CANA-Dan closed 2 years ago

CANA-Dan commented 2 years ago

i have three bugs for you.

i should preface by saying im using an ogg file for all this

so the first is a small one (but may be easy to fix). the audio will pop at the start when its played. basically just that. it doesnt matter the play time. its also not that loud.

the second is; on the first play of the audio, if i play the audio from any other value than 0, the editor will crash. if i play the audio (from 0) then stop or pause the audio, the audio will not play again. the editor wont crash, just nothing will happen.

Assertion failed: InWave->GetPrecacheState() == ESoundWavePrecacheState::Done [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/AudioMixer/Private/AudioMixerBuffer.cpp] [Line: 359]

UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]
UE4Editor_AudioMixer!Audio::FMixerBuffer::CreateRealTimeBuffer() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:359]
UE4Editor_AudioMixer!Audio::FMixerBuffer::Init() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:279]
UE4Editor_AudioMixer!Audio::FMixerSource::PrepareForInitialization() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerSource.cpp:707]
UE4Editor_Engine!FAudioDevice::StartSources() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4086]
UE4Editor_Engine!FAudioDevice::Update() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4379]
UE4Editor_Engine!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),0> >::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:709]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:601]
UE4Editor_Engine!FAudioThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioThread.cpp:203]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

this is my setup for that. image

the third is; if i compress the audio, the editor will sometimes crash (about 50/50) without me using the sound wav (ie, crash upon finishing compression). for all the tests iv left quality at 100. changing this doesnt seem to do anything, so iv left it where it is

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000001cbbad40000

UE4Editor_RuntimeAudioImporter!VorbisTranscoder::Encode() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\AudioAnalysisTools\Source\RuntimeAudioImporter\Private\Transcoders\VorbisTranscoder.cpp:133]
UE4Editor_RuntimeAudioImporter!<lambda_98de2f37158bb32cb37169b01d7e2e50>::operator()() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\AudioAnalysisTools\Source\RuntimeAudioImporter\Private\RuntimeAudioImporterLibrary.cpp:262]
UE4Editor_Core!TGraphTask<FAsyncGraphTask>::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasks() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1065]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:888]
UE4Editor_Core!FTaskThreadAnyThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:965]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

if the editor doesnt crash upon loading, then it will crash upon trying to play. this used to be not the case, but im guessing an update change something and its causing havoc. even then, it previously would only work under certain conditions (i think compression buffer and fill PCM Buffer would work, but raw wave would not? cant remember. its been about a month)

here are some recent crashes. see if any of them tell you whats going on. heres my blueprint setup

image

just filling the compression buffer and nothing else

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000001fc9cf00000

UE4Editor_RuntimeAudioImporter!VorbisTranscoder::Encode() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\AudioAnalysisTools\Source\RuntimeAudioImporter\Private\Transcoders\VorbisTranscoder.cpp:133]
UE4Editor_RuntimeAudioImporter!<lambda_98de2f37158bb32cb37169b01d7e2e50>::operator()() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\AudioAnalysisTools\Source\RuntimeAudioImporter\Private\RuntimeAudioImporterLibrary.cpp:262]
UE4Editor_Core!TGraphTask<FAsyncGraphTask>::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasks() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1065]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:888]
UE4Editor_Core!FTaskThreadAnyThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:965]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

just filling the PCM buffer and nothing else

Assertion failed: InWave->GetPrecacheState() == ESoundWavePrecacheState::Done [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/AudioMixer/Private/AudioMixerBuffer.cpp] [Line: 359]

UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]
UE4Editor_AudioMixer!Audio::FMixerBuffer::CreateRealTimeBuffer() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:359]
UE4Editor_AudioMixer!Audio::FMixerBuffer::Init() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:279]
UE4Editor_AudioMixer!Audio::FMixerSource::PrepareForInitialization() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerSource.cpp:707]
UE4Editor_Engine!FAudioDevice::StartSources() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4086]
UE4Editor_Engine!FAudioDevice::Update() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4379]
UE4Editor_Engine!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),0> >::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:709]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:601]
UE4Editor_Engine!FAudioThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioThread.cpp:203]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

filling the RAWWAV Buffer and nothing else

Assertion failed: InWave->GetPrecacheState() == ESoundWavePrecacheState::Done [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/AudioMixer/Private/AudioMixerBuffer.cpp] [Line: 359]

UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]
UE4Editor_AudioMixer!Audio::FMixerBuffer::CreateRealTimeBuffer() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:359]
UE4Editor_AudioMixer!Audio::FMixerBuffer::Init() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerBuffer.cpp:279]
UE4Editor_AudioMixer!Audio::FMixerSource::PrepareForInitialization() [D:\Build\++UE4\Sync\Engine\Source\Runtime\AudioMixer\Private\AudioMixerSource.cpp:707]
UE4Editor_Engine!FAudioDevice::StartSources() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4086]
UE4Editor_Engine!FAudioDevice::Update() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioDevice.cpp:4379]
UE4Editor_Engine!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),0> >::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:709]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:601]
UE4Editor_Engine!FAudioThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\AudioThread.cpp:203]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]
gtreshchev commented 2 years ago

If you want to play the imported sound wave not from the beginning (> 0 seconds), then you need to use the "Rewind Sound Wave" function. More about this here.

As for the slight crackling sound at the beginning, this is due to the Vorbis decoding inside stb_vorbis. I'm not sure exactly what the problem is, but trimming the audio data at the beginning after manual decoding would not be the right solution. I will need to take a closer look at the decoding process to say something more specific, added this to the list of tasks.

Audio data compression works fine for me, tested different audio files (including OGG Vorbis) on Windows, Linux and Android multiple times. I have an assumption that your crash was due to memory allocation through a standard allocation in one place, and was cleaned up by the engine in another place. If so, then it should be fixed.

As for the last bug (InWave->GetPrecacheState() == ESoundWavePrecacheState::Done), it should be fixed as well.

Thanks for reporting this! Let me know if everything works for you.

CANA-Dan commented 2 years ago

what the heck..... im incredibly confused. i was using this plugin but i didnt have it installed? what?

im legitimately super confused. was it because i was using the audio analysis plugin? and the other weird thing is that i was getting all the functionality (other than the previously mentioned bugs).

as for the other stuff; the rewind playback time node is working a treat (may be a good idea to rename that to set playback time as it can do more than just rewind. it was confusing to parse what it did before i implemented it and messed around with it) in addition, after reading through the docs, the Get Playback Time node is INCREDIBLY useful. i was using tick to get my song time before and that was quite inaccurate. after about a minute of playback i would get around 100ms out of sync, so this is incredibly nice to have.

as for the audio compression issue im still getting crashing, but also i possibly havent gotten the update over unreal engine yet so i cant say for sure. if this github is more up to date, i can grab off of here if youd like. it could also be that my system isnt liking something about the compression. ill shut down my system and come back tomorrow morning. that clearing of memory may fix it. it will also allow updates from unreal to arrive to server at my location if they havent already.

Edit; one quick question, if i wanted to load multiple audio files at the same time, would i be able to simply use a for loop? or would that cause issues with threading? or is this all on the main thread and not off loaded to a secondary thread?

gtreshchev commented 2 years ago

Can you describe your crash in more detail? I can't reproduce it, tested on Windows, Android and Linux.

As far as loading audio files in a loop, there shouldn't be any problem with that.

CANA-Dan commented 2 years ago

did a bunch of testing. heres my results the further down you go, the later into the night it was and the longer unreal engine had been on. no real pattern to suggest a garbage collection issue, but still work noting. at quality 1, with PCMBuffer (vorbis), 10 successful runs, 1 crashes at quality 50, with PCMBuffer (vorbis), 10 successful runs, 1 crashes at quality 100, with PCMBuffer (vorbis), 10 successful runs, 2 crashes

at quality 100, with PCM Buffer and Raw Wave Buffer (vorbis), 4 successful runs, 12 crashes at quality 99, with PCM Buffer and Raw Wave Buffer (vorbis), 5 successful runs, 12 crashes at quality 50, with PCM Buffer and Raw Wave Buffer (vorbis), 7 successful runs, 12 crashes at quality 20, with PCM Buffer and Raw Wave Buffer (vorbis), 4 successful runs, 12 crashes at quality 0, with PCM Buffer and Raw Wave Buffer (vorbis), 2 successful runs, 12 crashes

at quality 63, with PCM Buffer and Raw Wave Buffer (vorbis), 4 successful runs, 12 crashes at quality 64, with PCM Buffer and Raw Wave Buffer (vorbis), 3 successful runs, 12 crashes at quality 1, with PCM Buffer and Raw Wave Buffer (vorbis), 5 successful runs, 12 crashes

at quality 100, with PCMBuffer (vorbis), 10 successful runs, 3 crashes

at quality 100, with PCM Buffer and Raw Wave Buffer (Opus), 6 successful runs, 12 crashes

at quality 100, with PCMBuffer (ADPCM), 10 successful runs, 1 crashes

thats about as much poking as im going to do into seeing if quality affected anything. there seems to be some pattern of sorts, but not fully sure. overall about a 30% success rate on actually getting it to not crash when its done compressing if im filling both the PCM and Wav Buffer. i could do the Compressed Buffer as well, but iv had alot less success with that buffer overall. the raw wave buffer seems to be the least likely to crash, which is nice because thats the buffer type i need for my project lol.

two other things that may be linked to this (unsure, but they are other things to be aware of i guess) the first is this white column. its the base frequencies for the song iv loaded, and obviously its not supposed to be there. its so low pitched that most people wont be able to hear it and most headphones wont be able to play it. it might be why you get that ticking when you pause or play an audio file though. this is using the built in unreal engine Calculate Frequency Spectrum node, so there could be issues on that side, but i dont get these issues if i import the same audio file manually. i do get an issue if the file isnt lossless however (third image) but none of those weird lines are audible

the second thing is that the compression quality doesnt seem to do anything. the fourth and fifth images below can show that pretty easily.

the white column from audio loaded in by your plugin (at quality 100) image

the same audio file loaded in manually image

the weirdness with non lossless audio and unreal engine. image

at 100 quality image

at 1 quality image

after looking through this, im unsure what to test as it all seems quite random. if you have any ideas for me to try, i can give them a go.

as an aside, my program did crash from a garbage collection error. im pretty sure its for the VaRest plugin, but ill provide it here anyways.

the garbage collection crash report

Assertion failed: !IsGarbageCollecting() [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2332] Unable to create new object: VaRestJsonObject /Engine/Transient.GameEngine_0:VaRestSubsystem_0.None. Creating UObjects while Collecting Garbage is not allowed!

UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:461]
UE4Editor_CoreUObject!<lambda_8e14ca358e2340345ef44b260c149034>::operator()() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2331]
UE4Editor_CoreUObject!StaticAllocateObject() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2331]
UE4Editor_CoreUObject!StaticConstructObject_Internal() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:3189]
UE4Editor_VaRest!UVaRestSubsystem::StaticConstructVaRestJsonObject() [D:\build\++Portal\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\VaRest\Source\VaRest\Private\VaRestSubsystem.cpp:100]
UE4Editor_VaRest!UVaRestSubsystem::execStaticConstructVaRestJsonObject() [D:\build\++Portal\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\VaRest\Intermediate\Build\Win64\UE4Editor\Inc\VaRest\VaRestSubsystem.gen.cpp:222]
UE4Editor_CoreUObject!UObject::execCallMathFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:930]
UE4Editor_CoreUObject!UObject::execLetObj() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2691]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1067]
UE4Editor_CoreUObject!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:898]
UE4Editor_CoreUObject!ProcessLocalFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1128]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1067]
UE4Editor_CoreUObject!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:898]
UE4Editor_CoreUObject!ProcessLocalFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1128]
UE4Editor_CoreUObject!ProcessLocalScriptFunction() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1067]
UE4Editor_CoreUObject!UObject::ProcessInternal() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1155]
UE4Editor_CoreUObject!UFunction::Invoke() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5588]
UE4Editor_CoreUObject!UObject::ProcessEvent() [D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1992]
UE4Editor_BPThreads!FBaseThread::Run() [D:\Build\++Portal+Promotion\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\BPThreads\Source\BPThreads\Private\BaseThread.cpp:56]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]

the crash report from the tests above. all the crash reports were the same.

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000015af9410000

VCRUNTIME140
UE4Editor_RuntimeAudioImporter!WAVTranscoder::Encode() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\RuntimeAudioImporter\Source\RuntimeAudioImporter\Private\Transcoders\WAVTranscoder.cpp:131]
UE4Editor_RuntimeAudioImporter!<lambda_c14287c21e937073c88b138f6a34fb14>::operator()() [D:\build\U5M-Marketplace\Sync\LocalBuilds\PluginTemp\HostProject\Plugins\RuntimeAudioImporter\Source\RuntimeAudioImporter\Private\RuntimeAudioImporterLibrary.cpp:239]
UE4Editor_Core!TGraphTask<FAsyncGraphTask>::ExecuteTask() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:886]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasks() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1065]
UE4Editor_Core!FTaskThreadAnyThread::ProcessTasksUntilQuit() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:888]
UE4Editor_Core!FTaskThreadAnyThread::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:965]
UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86]
gtreshchev commented 2 years ago

It's not clear to me why you get different crash results in PCM Buffer and Raw Wave Buffer depending on the quality, if the quality only affects the compressed buffer.

I tried to get at least one crash, used different formats, but couldn't reproduce. Can you describe the whole process, how exactly do you do it?

My last commits were to improve low-level memory operations. They are primarily there to make sure there are no memory leaks. Altough I don't think this will help with your crash.

CANA-Dan commented 2 years ago

ill try to make a new actor and start from scratch and see if i still get the crash. there might be a conflict with another plugin possibly? im not fully sure as the crash will happen without any other blueprints running in that actor (well, there will be other blueprints, but they will be disconnected from the the rest of the nodes.

as for what im doing, im not doing anything actually. thats what confuses me. basically, i load in the audio (that works fine. no crashes there) then i compress it. without doing anything (ie, without even setting a variable with the compressed audio), it will crash, and have a good chance of crashing too as youve seen. my blueprints setup looks like what i have in the original image.

also, now that i know that quality only affects the compressed buffer, ill see if i can find a pattern in that. i dont think quality really affected anything when PCM and Raw buffer were selected and i was more just seeing patterns in nothing. i still provided it as part of the bug report as you might have been able to see some kind of pattern that i could not.

ill do all this tomorrow tho. i was digging holes all day and im completely burnt out.

gtreshchev commented 2 years ago

Thanks for all the information. I doubt that the problem is in conflict with another plugin.

I would be very happy if you could provide steps on how to reproduce your crash, or send a test project. Or at least provide examples of audio files that cause the crash.

CANA-Dan commented 2 years ago

i may not be able to respond for the next few days. im doing some land scaping (as an odd job) over the next 2-3 days and im completely wiped out when i get home.

in a few days ill see if i can recreate this issue on a fresh project, and if i can, ill send it your way. ill also give diffrent formats a go. i was using an ogg file for all of this, so it could be that wav or flac will work better.

CANA-Dan commented 2 years ago

im back with good news!!!!

whatever you did in your recent update fixed the issue im pretty sure.

i did get a crash, but that may have been because i was reloading (wiping and retrying the compression) at a high rate.

here it is anyways. may be a bug on your side that youd want to know about: Assertion failed: !IsGarbageCollecting() [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2332] Unable to create new object: ImportedSoundWave /Script/RuntimeAudioImporter.ImportedSoundWave.None. Creating UObjects while Collecting Garbage is not allowed!

edit; out of the 10 tries, not a single one crashed, and that was with vorbis (which crashed reliably) and with every compression buffer selected and at 100% quality

CANA-Dan commented 2 years ago

i dont actually think that above bug is caused by your code. i think its an issue on my side

as an asside i think i found something else; flac loading doesnt work.

gtreshchev commented 2 years ago

I'm glad that improved memory management has fixed your issues. It is possible that earlier some memory pointers were mistakenly freed, but now they definitely should not be.

It looks like some improvements in memory management have affected Flac decoding. Should be fixed. As for that bug related to object creation and garbage collection, it seems to be due to one of the sound waves being created on a different thread than the game thread and at the time of the garbage collection. Should also be fixed.

CANA-Dan commented 2 years ago

if the thread thing is whats causing the garbage collection, then its likely a thing on my side. i have a multi threading plugin and im using it to generate a spectrogram. as its directly using the audio, i could see it causing issues with your plugin

gtreshchev commented 2 years ago

This is not due to the thread, but just a coincidence that the creation of the object occurs exactly at the moment when garbage is collected in the main thread. However, this should be fixed by now.

CANA-Dan commented 2 years ago

alright cool!

CANA-Dan commented 2 years ago

this is a totally separate thing, but i intend to work on a C++ function with a friend of mine that allows someone to calculate FFT off the main thread. if you want, once we are done i can send it to you for you to add to your plugin. in theory, it should just plop into your plugin because im going to be using a variable that contains a compressed file from your plugin.

for this, anything i should know before hand? additionally, do you know how to better automate multi threading? you seem to do doing that with loading, having it on a secondary thread comfortably, but also loopable. i would want all the fft calculation to be completely off the main thread at all times, and use as many threads as it needs to (ie, 16 if it wants for example. it is a very heavy operation after all), but from what i know id need to make a separate function for each thread i want to run, which isnt very optimal.

CANA-Dan commented 2 years ago

you do have a node that already sorta does this, but my code would allow someone to calculate a sing at an arbitrary time value, and faster than real time.

gtreshchev commented 2 years ago

As for multithreading, it depends on what you are looking for. You can create a separate thread pool if your tasks are heavy enough to afford creating threads. Or you can use the so-called AsyncTask, which work on threads already created by the engine. You can also use FRunnable, but they are usually used for very heavy tasks.

Runtime Audio Importer works with AsyncTask because it has tasks of the same type that are quite difficult to parallelize on different threads.

If you need a multi-threaded loop, I can advise using "ParallelFor" (Async/ParallelFor.h). I used it for analysis here.

By the way, AudioAnalysisTools works outside the main thread and it does not have such strong calculations, so its work should not affect the game thread.

CANA-Dan commented 2 years ago

alright cool!! ill take a look at thread pools then. it sounds like its the right thing for my use case. i would basically be calculating each spectrogram section as a chunk (that way procedural mesh wouldn't have as large a mesh to generate, and you could hide any chunks outside of the view distance), offset by the index provided by a for loop counter. chunkIndex = loopCounter + totalThreads, where each thread would get ID'ed by loopCounter. every time the thread was done, totalThreads would be added on top, this way cleanly offsetting the data. each chunk could comfortably calculate at the same time that way without any conflicts. i know that sounds like alot of processing power going to spectrogram calculation, but even unreal engines spectrogram calculation struggles to get equal to real time, let alone faster than it if i were to calculate at max quality. two threads allocated to spectrogram calculation would be able to go faster than real time however, so im ideally aiming for that for this process (so 3 total threads if you include your main thread. most people have atleast a 4C/4T CPU now days, but i will be adding a way for the code to know not to go over the amount of cores your computer has)

because i cant have the procedural mesh on anything other than the main thread i need some way to let the main thread quickly know that a thread is done so the procedural mesh can be created. is there anything like an event listener like in javascript in unreal engine?

CANA-Dan commented 2 years ago

unless FRunnable is basically what im looking for. reading the unreal docs didnt give me much info on it

CANA-Dan commented 2 years ago

im having a small issue with building my project. i need to build it so i can create a C++ file so i can make that spectrogram code.

looking for an answer online, it seems to be that i have a duplicate file somewhere, but im not sure where and i dont want to accidently delete something i shouldn't. as someone more experienced, do you recognize this issue? it seems to be specifically with your plugins.

image

gtreshchev commented 2 years ago

Oh, I have recently answered it here.

In short, if you are using the Audio Analysis Tools from the Marketplace, you do not need to install the Runtime Audio Importer separately, as it is already built in.

CANA-Dan commented 2 years ago

ahh i see. thank you!

also, may i leave this chat open for questions i may have? i suspect ill have a couple. hopefully not too many tho. i dont want to barrage you with questions lol

gtreshchev commented 2 years ago

Sure. But if possible, it’s better to ask questions in the Telegram chat, and leave GitHub Issues for bugs.

CANA-Dan commented 2 years ago

telegram? i dont have it and getting an account is a bit awkward. i dont currently have a working cellphone plan because i lost my job when covid started, and i need a cell phone number that i can send a text to for account activation. do you have discord at all?

if all else fails tho, i guess i could borrow someone elses phone if it comes to that

gtreshchev commented 2 years ago

I have Discord, but there is no chat and I rarely go there. No problem, then you can write to gtreshchev@gmail.com for questions and here for bugs if you want.

CANA-Dan commented 2 years ago

alright cool! i shall do so if needed