OpenAL Music Crashes on LWJGL3
See original GitHub issueIssue details
Playing music on LWJGL3 crashes sometimes possibly due to synchronization issues.
How to reproduce
Based on my assessment, it’s possible for OpenALMusic.fill(…) to be called from multiple threads causing a buffer exception if 2+ threads manipulate tempBuffer
at the same time. Attached is a player-submitted crash report. An example would be calling play
from a non-render thread while the render-thread updates the audio at the same time.
Proposed solution
Maybe the easiest solution is to simply make the method synchronized:
private synchronized boolean fill (int bufferID) {
...
}
Version of LibGDX and/or relevant dependencies
libGDX 1.9.14 with LWJGL 3.2.3
Stacktrace
java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:362)
at com.badlogic.gdx.backends.lwjgl3.audio.OpenALMusic.fill(OpenALMusic.java:269)
at com.badlogic.gdx.backends.lwjgl3.audio.OpenALMusic.update(OpenALMusic.java:237)
at com.badlogic.gdx.backends.lwjgl3.audio.OpenALLwjgl3Audio.update(OpenALLwjgl3Audio.java:250)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:133)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:117)
Please select the affected platforms
- Android
- iOS
- HTML/GWT
- Desktop with LWJGL3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
audio crash, win 10 :: TheoTown General Discussions
Mp3$Music.read(Mp3.java:91) at com.badlogic.gdx.backends.lwjgl3.audio. ... audio crash, win 10 ... OpenALMusic.update(OpenALMusic.java:238)
Read more >[FIXED] OpenAl crashes while unloading since 2.8.1 - LWJGL Forum
[FIXED] OpenAl crashes while unloading since 2.8.1. ... this total crash only happens like once every 10 times I try to exit a...
Read more >[MC-9974] Initialization of OpenAL fails sometimes - Jira
Occasionally when resources are loaded, OpenAL fails to start and there is no sound. Generally it works fine, but very rarely it fails....
Read more >Game crashes on disasters or even small fire... - TheoTown
Just bought on steam and game keeps crashing when something gets destroyed, there's I would say there's slight chance of crash when tile...
Read more >Newest 'openal' Questions - Page 3 - Stack Overflow
I am tasked to finding why this app stops the Music Player on my ipod. ... OpenAL application crashes/hangs when I pass non-nullptr...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@noblemaster ah yeah, you’re right about the loading case (or any other cases where GLThread is busy). I’d be happy to have music update/fill in a separated thread. +1 for that change.
Pull Request is here: https://github.com/libgdx/libgdx/pull/6452