stride3d / stride3d/stride

The type initializer for 'Stride.Audio.AudioEngine' threw an exception. (Could not locate or load native library libstrideaudio)

Open
#3,099 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Github

Version: https://github.com/stride3d/stride/commit/f16ec522a5430f67672e7a23b9da42bb19de55cd

Platform(s): Windows

Describe the bug
When working with projects that are upgraded from 4.2.0.X, this exception is thrown upon debugging the project. This is an regression since this is not reproductible in v4.3.0.2507.

To Reproduce

  1. Clone and run https://github.com/MsEpsilon/TR.Stride/tree/master

Expected behavior
No crash.

Screenshots

Log and callstacks
What is shown in the debug terminal:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Stride.Audio.AudioEngine' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Stride.Audio.AudioLayer' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Stride.Audio.NativeInvoke' threw an exception.
 ---> System.DllNotFoundException: Could not locate or load native library libstrideaudio
   at Stride.Core.NativeLibraryHelper.PreloadLibrary(String libraryName, Type ownerType) in D:\Dev\stride\sources\core\Stride.Core\Native\NativeLibraryHelper.cs:line 188
   at Stride.Audio.NativeInvoke.PreLoad() in D:\Dev\stride\sources\engine\Stride.Audio\NativeInvoke.cs:line 18
   at Stride.Audio.NativeInvoke..cctor() in D:\Dev\stride\sources\engine\Stride.Audio\NativeInvoke.cs:line 23
   --- End of inner exception stack trace ---
   at Stride.Audio.NativeInvoke.PreLoad() in D:\Dev\stride\sources\engine\Stride.Audio\NativeInvoke.cs:line 17
   at Stride.Audio.AudioLayer..cctor() in D:\Dev\stride\sources\engine\Stride.Audio\Native\AudioLayer.cs:line 37
   --- End of inner exception stack trace ---
   at Stride.Audio.AudioLayer.Init()
   at Stride.Audio.AudioLayer.Init()
   at Stride.Audio.AudioEngine..cctor() in D:\Dev\stride\sources\engine\Stride.Audio\AudioEngine.cs:line 27
   --- End of inner exception stack trace ---
   at Stride.Audio.AudioEngine..ctor(AudioDevice device, UInt32 sampleRate) in D:\Dev\stride\sources\engine\Stride.Audio\AudioEngine.cs:line 63
   at Stride.Audio.AudioEngineFactory.NewAudioEngine(AudioDevice device, DeviceFlags deviceFlags) in D:\Dev\stride\sources\engine\Stride.Audio\AudioEngineFactory.cs:line 18
   at Stride.Audio.AudioSystem.Initialize() in D:\Dev\stride\sources\engine\Stride.Engine\Audio\AudioSystem.cs:line 58
   at Stride.Games.GameSystemCollection.GameSystems_ItemAdded(Object sender, TrackingCollectionChangedEventArgs e)
   at Stride.Games.GameSystemCollection.GameSystems_CollectionChanged(Object sender, TrackingCollectionChangedEventArgs e)
   at Stride.Core.Collections.TrackingCollection`1.InsertItem(Int32 index, T item) in D:\Dev\stride\sources\core\Stride.Core\Collections\TrackingCollection.cs:line 40
   at Stride.Core.Collections.FastCollection`1.Add(T item) in D:\Dev\stride\sources\core\Stride.Core\Collections\FastCollection.cs:line 108
   at Stride.Engine.Game.Initialize() in D:\Dev\stride\sources\engine\Stride.Engine\Engine\Game.cs:line 390
   at Stride.Games.GameBase.InitializeBeforeRun()
   at Stride.Games.GamePlatform.OnInitCallback()
   at Stride.Games.GameWindowWinforms.Run()
   at Stride.Games.GamePlatform.Run(GameContext gameContext)
   at Stride.Games.GameBase.Run(GameContext gameContext)

Debugger breaks with this exception.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Stride.Engine
  StackTrace:
   at Stride.Audio.AudioSystem.Destroy()
   at Stride.Core.DisposeBase.Stride.Core.IReferencable.Release() in D:\Dev\stride\sources\core\Stride.Core\DisposeBase.cs:line 82

Additional context
This doesn't seem to happen with newly created projects?

Workaround
Full rebuild (clean+rebuild).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the upgraded project linked in the issue, then inspect Stride.Core/Native/NativeLibraryHelper.cs and Stride.Audio/NativeInvoke.cs, following the stack through AudioLayer.cs and AudioSystem.cs. Compare behavior with v4.3.0.2507 and verify that upgraded projects load libstrideaudio without the initializer or cleanup exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.