MyXAudio2 Crashing to desktop

Shane Stixrud shared this bug 6 months ago
Investigating

The following is more likely to occur the more audio that is going on at a given time. Easy to reproduce during large ship battles.

2020-03-21 08:21:28.769 - Thread: 1 -> Exception occured: ParallelTasks.TaskException: An exception(s) was thrown while executing a task.

at ParallelTasks.WorkItem.ThrowExceptionsInternal(Int32 runId)

at ParallelTasks.Task.WaitOrExecute(Boolean blocking)

at Sandbox.MySandboxGame.Update()

at Sandbox.Engine.Platform.Game.UpdateInternal()

at Sandbox.Engine.Platform.Game.RunSingleFrame()

at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass11_0.<Run>b__0()

at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)

at Sandbox.Engine.Platform.Game.RunLoop()

at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)

at SpaceEngineers.MyProgram.Main(String[] args)

Task exception, inner exception 0:

System.NullReferenceException: Object reference not set to an instance of an object.

at VRage.Audio.MyXAudio2.Update3DCuePosition(IMy3DSoundEmitter source)

at VRage.Audio.MyXAudio2.Update3DCuesState(Boolean updatePosition)

at VRage.Audio.MyXAudio2.Update(Int32 stepSizeInMS, Vector3 listenerPosition, Vector3 listenerUp, Vector3 listenerFront, Vector3 listenerVelocity)

at Sandbox.MySandboxGame.UpdateSound()

at ParallelTasks.DelegateWork.DoWork(WorkData workData)

at ParallelTasks.WorkItem.DoWork(Int32 expectedID)

Comments (3)

photo
1

No need for large scale ship battles, crashes my game everytime i try to fire a single turret with the exact same exeption in the crash log... Please fix, makes WC unusable for me.

photo
1

Hopefully hot-fixed in v194.081. Please let us know if it helps. If not, provide more info about this problem.

photo
1

Unfortunately it is not fixed in the recent hotfix. From my experience on Xocliw's stream. The crash appears to happen more frequently as the world is up.

photo
photo
2

The following code reproduces the issue. It seems to be MUCH easier to trigger the issue by calling sounds in Draw() (which I know is not ideal). However, I also see it happen in BeforeSimulation, just much more rare and seems to depend on normal game play load / situations that are more difficult to reproduce reliably. My guess is it is easy to reproduce in Draw() because this is around the same time Keen kicks off the audio thread.


[MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation | MyUpdateOrder.AfterSimulation | MyUpdateOrder.Simulation, int.MaxValue - 1)]

public class Session : MySessionComponentBase

{

internal readonly MySoundPair Sound = new MySoundPair();


internal readonly MyEntity3DSoundEmitter SoundEmitter = new MyEntity3DSoundEmitter(null, true, 1f);

internal Random Rnd = new Random(123);

internal string[] Sounds = {"WepShipGatlingShot", "ArcWepLrgWarheadExpl", "ArcWepExplSmall"};


public override void Draw()

{

Sound.Init(Sounds[Rnd.Next(0, 3)], false);

SoundEmitter.PlaySound(Sound, Rnd.Next(0, 1) == 1);

}

}