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

[SDL3] jack audio driver throws assertion #8344

Closed
madebr opened this issue Oct 3, 2023 · 13 comments
Closed

[SDL3] jack audio driver throws assertion #8344

madebr opened this issue Oct 3, 2023 · 13 comments
Assignees
Milestone

Comments

@madebr
Copy link
Contributor

madebr commented Oct 3, 2023

testaudio asserts when started with jack audio driver

reproducer

Start testaudio with:

SDL_AUDIO_DRIVER=jack test/testaudio

Then create a logical device for some output

actual result

WARN: 

Assertion failure at jackProcessPlaybackCallback (/home/maarten/programming/SDL/src/audio/jack/SDL_jackaudio.c:147), triggered 1 time:
  'nframes == ((SDL_AudioDevice *)arg)->sample_frames'

desired result

audio plays, no assertion

@icculus icculus self-assigned this Oct 3, 2023
@icculus icculus added this to the 3.2.0 milestone Oct 3, 2023
@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

This doesn't trigger for me, but I suspect the problem is this code...

// !!! FIXME: implement and register these!
// typedef int(* JackSampleRateCallback)(jack_nframes_t nframes, void *arg)
// typedef int(* JackBufferSizeCallback)(jack_nframes_t nframes, void *arg)

...which we need to check to find out that JACK decided we need a different sample rate or buffer size.

@madebr
Copy link
Contributor Author

madebr commented Oct 16, 2023

This reproduces on Fedora 38.
Fedora uses jack on top of pipewire (PipeWire JACK implementation libraries).

The jack library also deadlocks when running testautomation in a loop, but that's another issue.

@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

When you get a chance, can you see if the thing I just pushed fixes it for you?

@madebr
Copy link
Contributor Author

madebr commented Oct 16, 2023

I get this segfault now when creating a logical device, probably not connected to the jack issue:

#0  0x0000000000405998 in DrawOneThing (renderer=0x59f150, thing=0x1249f90)
    at /home/maarten/projects/SDL/test/testaudio.c:362
#1  0x0000000000405e06 in DrawThings (renderer=0x59f150) at /home/maarten/projects/SDL/test/testaudio.c:414
#2  0x0000000000405e77 in Draw () at /home/maarten/projects/SDL/test/testaudio.c:425
#3  0x00000000004085c8 in Loop () at /home/maarten/projects/SDL/test/testaudio.c:1201
#4  0x000000000040877b in main (argc=1, argv=0x7fffffffdcb8) at /home/maarten/projects/SDL/test/testaudio.c:1270

About jack, I can worsen its behavior by running a few testautomation iterations before running testaudio.
e.g.

test/testautomation --filter audio --iterations 20
SDL_AUDIO_DRIVER=jack test/testaudio

@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

I get this segfault now when creating a logical device, probably not connected to the jack issue:

On this line...?

        SDL_assert(thing->texture != NULL);

@madebr
Copy link
Contributor Author

madebr commented Oct 16, 2023

Yes. I was testing on current main. Sorry if I wasn't clear on this.

icculus added a commit that referenced this issue Oct 16, 2023
This happens to work because our current textures are all 128x128, but in
theory one shouldn't hit this case anyhow...right?!

Reference Issue #8344.
@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

I just pushed a fix that should bypass that crash, although I'm not sure how we got into a state where that would crash in the first place. :/

@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

Also, I'm going to bump up from Ubuntu 22.10 to 23.04 and see if I get a more recent PipeWire install out of it.

Although the temptation to nuke everything and move to Fedora is growing daily. :)

@madebr
Copy link
Contributor Author

madebr commented Oct 16, 2023

There's something really wrong with jack (in testaudio).
testaudio now always segfaults as soon as I create a logical device. It segfault in locations not related to audio such as inside libwayland-client, libdecor, mesa, ... and some times it deadlocks.

The testaudio works as usual for other audio drivers, though there is heavy stuttering with the pipewire audio driver.

When running testaudiostreamdynamicresample, the following segfault happens with the pulse audio driver at startup:

#0  __GI___pthread_mutex_unlock_usercnt (mutex=0xbda749debda749de, decr=1) at pthread_mutex_unlock.c:51
#1  0x00007ffff7dd8710 in SDL_UnlockMutex_REAL (mutex=0xbda749debda749de)
    at /home/maarten/projects/SDL/src/thread/pthread/SDL_sysmutex.c:168
#2  0x00007ffff7c3a411 in SDL_GetAudioStreamData_REAL (stream=0x121f280, voidbuf=0x121b8c0, len=16384)
    at /home/maarten/projects/SDL/src/audio/SDL_audiocvt.c:1104
#3  0x00007ffff7c30f90 in SDL_OutputAudioThreadIterate (device=0x42c6d0)
    at /home/maarten/projects/SDL/src/audio/SDL_audio.c:897
#4  0x00007ffff7d65ab1 in jackProcessPlaybackCallback (nframes=2048, arg=0x42c6d0)
    at /home/maarten/projects/SDL/src/audio/jack/SDL_jackaudio.c:173
#5  0x00007ffff5277a9f in on_rtsocket_condition (data=0x11f1190, fd=<optimized out>, mask=<optimized out>)
    at ../pipewire-jack/src/pipewire-jack.c:1879
#6  0x00007ffff4a52d05 in loop_iterate_cancel (object=<optimized out>, timeout=<optimized out>)
    at ../spa/plugins/support/loop.c:454
#7  0x00007ffff4ab3093 in do_loop (user_data=0x120ed20) at ../src/pipewire/data-loop.c:65
#8  0x00007ffff7aae947 in start_thread (arg=<optimized out>) at pthread_create.c:444
#9  0x00007ffff7b34860 in clone3 () at ../sysdeps/unix/

(pipewire also stutters in testaudiostreamdynamicresample)

@icculus
Copy link
Collaborator

icculus commented Oct 16, 2023

Can you go back a few revisions and see if this is still broken this badly, to make sure it isn't something from today? And if it is...maybe reboot and see if it fixes it? 😬

@madebr
Copy link
Contributor Author

madebr commented Oct 16, 2023

A restart makes pipewire and pipewire-jack behave again. (I didn't try previous comits)
Looks like running testautomation --filter audio --iteraions X + testaudio confuses pipewire.
I got my system in a state where youtube audio did not have audio playback, and playing a mp4 video in the browser made it play with faster playback speed. (I have not tried to reproduce these things)

@icculus
Copy link
Collaborator

icculus commented Oct 18, 2023

I think we can close this one, now that PipeWire added a fix...?

@madebr
Copy link
Contributor Author

madebr commented Oct 18, 2023

Yeah, let's close it.
Looks like pipewire often creates a release, so we'll be able to test this soon enough.

@madebr madebr closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants