I don’t always get this crash, but it happens very frequently. Only in PIE windows though, standalone works fine. I have been getting these crashes since 4.8.0.
I also noticed that the “Play in Editor → Enable Sound” setting doesn’t do anything. I am still getting sound even while playing in the editor viewport.
It would be great to figure out a workaround at least until this is fixed, because it’s driving me nuts.
I’m trying to reproduce this crash on my end and have a few questions. How are you setting up the call to PlaySoundAtLocation()? Is this being called from an actor or from pawn? Can you share the code you’re using so I can make sure I’m following the same setup steps.
Additionally, do you have the callstack and log files from the crash as well? If you could post these files it will give us more information on what is failing.
The PlaySoundAtLocation() is called from the Shoot() function in the actor (Weapon) which is attached to a pawn (User). The Shoot() function is called when the player executes the “Shoot” action which is setup in the SetupPlayerInputComponent().
It’s worth mentioning that the assertion is also triggered when the blueprint equivalent is used. (The sounds in those cases are setup in practically the same way)
And since the game doesn’t really crash, but rather is prevented from continuing. I just copied the log from the \Saved\Logs folder and the Call Stack directly from Visual Studio. Instead of using the copied call stack from the UE crash reporter.
Hi. I get this constantly. I believe the sfx being played is through unomodified shootergame code for explosions class. it’s very detrimental as it’s nearly 100% and keeps hot reload from being useful at all.
I also have a project based on ShooterGame, could it be related to the issue?
Another sound related issue I noticed is that sound preview in the content browser stops working frequently. Also, the sounds that crash the game (played through PlaySoundAtLocation) are often delayed at the beginning of the game, whereas map environment sounds (which don’t appear to crash the editor) start playing immediately.
My project was initially based on the C++ 2D platformer example. But all code that’s in the game currently is all written from scratch. So there are at this stage no traces from the platformer example in the game. I’d guess that there’s no connection to the crash and that you both have it based on ShooterGame is only a coincidence.
IfI wrap all calls to PlaySoundAtLocation() with a check for GetMainAudioDevice(), sounds remain silent for a few seconds but then crash at the same spot in the code.
Yeah, that won’t solve anything. If I have understood correctly, when someone plays a sound it get’s queued and then at the next world-tick all sounds from the queue gets initialized and played. And since the game gets halted in the sound initialization stage; even if you only play a sound when the main audio device is present, the audio device still won’t be during initialization.
In the editor I then set MySound to the default gunfire available in the project. When I played in the editor I heard the sound as expected. I then changed the code to add a new variable to the class and compiled to trigger a hot reload. Playing in the editor again the sound was still playing and I did not crash. Can you try this on your end and let me know if you crash or let me know if there’s something I’m doing differently from your setup.
Yeah I have tried to reproduce this bug in the First Person Shooter template as well now, but so far I haven’t managed to do so outside of the main project.
Some facts about the project that causes the crash:
1-4 Player Local Multiplayer
Uses C++ Derived Blueprints
Uses USoundCue instead of USoundBase
I dunno if these are any major factors that can cause the crash but it might help.
If you want to, I can give you temporary -only access to the repository on bitbucket so that you’re able to investigate a real crash case.
I did some further debugging and found that it’s the final comparison:
return Generations[Index] == Generation;
on line 157 in AudioDeviceManager.cpp which in turn is called from
if (!IsValidAudioDeviceHandle(Handle))
{
return nullptr;
}
on line 240 in AudioDeviceManager.cpp that causes the GetMainAudioDevice() function call to fail.
In the IsValidAudioDeviceHandle() function the handle that is passed have the value “0” and the Generations array content can be seen in the following image:
I was unable to check the returned value from GetGeneration(Handle).
Using bitbucket would work if that’s best for you. Another option would be to upload the project to dropbox and then send me a private message on the forums with a link to download the project from.
I think that it would be easiest on my part to just give you access to the repository.I sent you a private message on the forums with a request for your bitbucket username.
I was not able to produce the crash in your project either. I downloaded the project and played the Space level. After adding a float to your projectile.cpp file to trigger a hot reload I played the Space level again and did not crash when firing.
That’s really strange, I consistently get this crash whenever I change some code and hot-compile. I assume that this was PIE and not played in a standalone game since we debunked that case earlier? And what solution configuration did you use, I use DebugGame Editor but I dunno if it really matter.
Originally I was using Development Editor however I tried preforming the hot reload after switching my configuration to DebugGame Editor and still did not crash. Do you crash if you PIE multiple times without preforming a hot reload? Additionally, if you update the project to 4.8.2 do you still receive the same crash?
I can PIE as many times as I want but as soon I perform a hot-compile the game crashes on the first play of sound.
I’m currently updating the editor to 4.8.2 but from what I’ve in the patch notes, there shouldn’t be anything that solves this particular issue, but I’ll return with an answer as soon I’ve tested it.
Tested it now with the new 4.8.2 update and I still crash. I tried wrapping the first PlaySoundAtLocation call from when I shoot in a check (as Zenity previously did) like so
if ( GEngine->GetMainAudioDevice() )
and the sound didn’t play, so already in the first tick function the sound device don’t return a valid audio device handle.
Then the game crashes as soon as the fired projectile is destroyed, but that’s fully expected as that’s also is a PlaySoundAtLocation() call.