Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash regarding xcb on Linux, Java 11+. Also Sound is buggy and doesn't work sometimes. #681

Open
Lachrymogenic opened this issue May 20, 2024 · 19 comments
Labels
Audio Bug Something that shouldn't happen. Compatibility Issue related to application-system compatibility. Help wanted An issue requiring extra attention. Platform/OS Issue related to platform or OS.

Comments

@Lachrymogenic
Copy link

Describe the bug
The game runs with no audio on OpenJDK Java 8, so I upgraded to 11, 17 and 21 and the game kept crashing with the exact same error message, that message being:

[Game Handler] WARN: Game tried to exit display, but no menu is open.
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: ../../src/xcb_io.c:269: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

I am using OpenJDK.
I downloaded an official Java 8 binary from java.com and the game now works completely fine however, in pavucontrol the volume slider for the game is flickering. Heres a video (Java version here is Java(TM) SE Runtime Environment (build 1.8.0_411-b09) ):

strange.webm

I genuinely find this to be so weird, even the recording software is not picking up the sound correctly.

To Reproduce
I have no idea if it is reproducable, it could be an issue with my machine but then again, what am I supposed to do about it? Other java applications like Minecraft work flawlessly on OpenJDK Java 8 and other versions like OpenJDK Java 17. So I'm pretty sure something is wrong with the game itself or it was not meant for anything except Java 8. If that's the case, I have no idea why sound isn't working on Java 8. Here's a video of sound not working on OpenJDK Runtime Environment (build 1.8.0_402-8u402-ga-2ubuntu1~20.04-b06)

simplescreenrecorder-2024-05-20_20.26.22.mp4

Albeit this is a bad example because I didn't play any example audio from a browser or something, so the video just has no audio, but you can see from the pavucontrol that the java stream is not producing any audio.
Expected behavior
No crash. (and for sound to work)

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.6 LTS x86_64
  • Game version: 2.2.0

Additional Comments:
I personally don't know why this happens, even tried building on my own machine and same thing occurs. Sound works but stutters in Java 11+ and crashes with that error.

@Lachrymogenic Lachrymogenic added the Bug Something that shouldn't happen. label May 20, 2024
@Lachrymogenic
Copy link
Author

After closer inspection, you can see that the audio that does work is ALSA, but when it doesn't, it's just "Audio Stream"
For some reason that specific OpenJDK version isn't connecting to ALSA, or perhaps the issue is ALSA?

@Lachrymogenic
Copy link
Author

Lachrymogenic commented May 20, 2024

After playing more on that specific Java version, Java(TM) SE Runtime Environment (build 1.8.0_411-b09), the audio became significantly delayed, I did have a youtube video playing in the background is that makes a difference. But restarting the game multiple times fixes this and goes back to flickering, so audio is extremely inconsistent for some reason.

@Litorom
Copy link
Member

Litorom commented May 20, 2024

@BenCheung0422 @Makkkkus

@Lachrymogenic
Copy link
Author

Unfortunately, Java(TM) SE Runtime Environment (build 1.8.0_411-b09) still causes the xcb crash (same error message btw), but it's very inconsistent, sometimes I can play for more than 10 to 20 minutes and not encounter an issue and sometimes like just now it crashed within 5 minutes. I have no idea if xcb is an issue, but I can't seem to find a solution.

@BenCheung0422
Copy link
Member

After some tests with my Hyper-V Ubuntu 22.04.4 LTS machine, I have several discoveries with it.

This also occurs even before the change to the audio system in 2.2.0 (2.2.0-dev7 by #544). With 1.8.0_402, game menu freezes after a play of audio; with 11.0.22, 17.0.10 or 21.0.2, significant delays can be noticed with audio.

With 2.2.0, 1.8 gives no sound, and delays can still be noticed with the other 3 JRE versions.

However, I cannot notice the flicks in PAVU Control and the crash messages of xcb.

@BenCheung0422
Copy link
Member

Furthermore, about the audio stream names:

Before the change to the audio system mentioned, there are 10 streams all named "Java: Audio Clip", exactly as the number of audio files in game, as intended.

After the change, 1.8 does indeed gives a single "Java: Audio Stream" audio stream and other versions give a "ALSA plug-in [java]: ALSA Playback" stream. I apologize that I missed the information that you have also tested with Oracle JRE 8, and it can indeed play audio with delays (seemingly with smaller delays), but I still cannot notice of the "flicks" of stream. It seems like OpenJDK JRE 8 is not linking with ALSA.

In conclusion, I am not sure whether this issue is reported or occurred only during some specific circumstances. And maybe tests in other Linux may be conducted. I will try to debug with using Ubuntu if possible.

@Lachrymogenic
Copy link
Author

Lachrymogenic commented May 22, 2024

Seems to work on my Steam Deck just fine, using SteamOS Holo 3.5.19 with Openlogic OpenJDK Java 8 JRE 8u352-b08-linux-64. Maybe that's because Steam Deck uses pipewire and not pulseaudio? Seems to connect to ALSA just fine. The exact same build of Java on my Ubuntu PC causes the ALSA flickering in pavucontrol.

@BenCheung0422
Copy link
Member

If that is the case that there are some issues with PulseAudio, we might have to check with it.

@BenCheung0422
Copy link
Member

Can you try the solution mentioned here (stackoverflow)?

@Lachrymogenic
Copy link
Author

I have tried this and audio is now playing on my stock OpenJDK 8 but pavucontrol still flickers for some reason.
The audio plays but it's a little jittery, maybe I can show you a video.

minicraft-test.mp4

The jitteryness is only noticeable when watching playback of a video, otherwise it's only partially noticeable
My stock OpenJDK 8 version is OpenJDK Runtime Environment (build 1.8.0_402-8u402-ga-2ubuntu1~20.04-b06)
Reverting sound.properties back to normal gives no sound, so I'm guessing it's an issue with PulseAudio.

@BenCheung0422
Copy link
Member

BenCheung0422 commented May 25, 2024

It looks like there are some compatibility issues between PulseAudio and Java, and indeed OpenJDK 8 PulseAudio API/IcedTea is broken. The unstable connection between PulseAudio and Java may be caused by certain configurations, but more tests shall still be conducted.

@BenCheung0422
Copy link
Member

My test with OpenJDK 11

2024-05-25.14-50-58.mp4

@BenCheung0422
Copy link
Member

My suggestion is to use PipeWire over PulseAudio. PipeWire is a newer package than PulseAudio, and the compatibility should be better.

@BenCheung0422
Copy link
Member

Another way is to reset the sound configurations to the default settings:

rm -f ~/.config/pulse/*
sudo killall pulseaudio
# daemon(s) will restart imediately

More Info: https://askubuntu.com/a/1259763

And you may try to spot out the problematic configs by reverting it to be the ones before resetting.

@Lachrymogenic
Copy link
Author

Lachrymogenic commented May 26, 2024

My suggestion is to use PipeWire over PulseAudio. PipeWire is a newer package than PulseAudio, and the compatibility should be better.

I'm not doing that, I've tried setting it up and it's just a pain, especially on Ubuntu it seems.
There's no reason why other Java applications can be perfect with audio with PulseAudio, but this one cannot?
For example, Minecraft works perfectly fine with PulseAudio on my system, so why should Minicraft have issues?

I do get that they're not the same or whatever, but I'm just wondering if a new sound system could solve this issue, as it shouldn't be up to the user to make changes to their system to have a game work as intended, the program should work on all systems and be compatible with not only pipewire but pulse too. Essentially, literally everything else works fine with Pulse so why should I have to switch just to play Minicraft, that just doesn't make any sense to me.

This is a bug and I don't agree with the idea that the user changing their sound system from Pulse to Pipewire is the solution.
I'll just deal with the flickering sound for now, because it is better than nothing.

@BenCheung0422
Copy link
Member

The sound system we are currently using heavily relies on native Java sound libraries while Mincraft's LWJGL is using OpenAL for audio. I doubt that the Java native libraries have some problems tackling with audio on some Linux distributions.

@BenCheung0422
Copy link
Member

However, more than that, my 22.04 Ubuntu VM test (no custom settings) with PulseAudio does not come with flickering issue. I also guess that Java audio may not be compatible with certain configurations.

@Lachrymogenic
Copy link
Author

However, more than that, my 22.04 Ubuntu VM test (no custom settings) with PulseAudio does not come with flickering issue. I also guess that Java audio may not be compatible with certain configurations.

What OpenJDK versions do you have on the VM and what is in the sound.properties file?
Is it just stock or normal?

@BenCheung0422
Copy link
Member

BenCheung0422 commented May 26, 2024

The following is the setups and with the similar results with my tests:

  • OpenJDK Runtime Environment (build 1.8.0_402-8u402-ga-2ubuntu1~22.04-b06) with modified sound.properties (mentioned above)
  • OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1) with default sound.properties (empty)
  • OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-122.04.1) with default sound.properties (empty)
  • OpenJDK Runtime Environment (build 21.0.2+13-Ubuntu-122.04.1) with default sound.properties (empty)

They however sometimes come with significant audio latencies.

@BenCheung0422 BenCheung0422 added Visual/Audio Help wanted An issue requiring extra attention. Audio Compatibility Issue related to application-system compatibility. Platform/OS Issue related to platform or OS. and removed Visual/Audio labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audio Bug Something that shouldn't happen. Compatibility Issue related to application-system compatibility. Help wanted An issue requiring extra attention. Platform/OS Issue related to platform or OS.
Projects
None yet
Development

No branches or pull requests

3 participants