-
Notifications
You must be signed in to change notification settings - Fork 2
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
loading large chuck files before turning on audio causes Max to crash #11
Comments
@HighHarmonics2 Thanks for this report. Let's try to figure what is causing the crash: First thing Is that after it you crashes see if there is an error report that you can get on macOS. If you get one, can you just show what is on the top part of the traceback so we can see where it crashes specifically. Also it would useful to figure out if it's due to the large size of the chuck file or the fact that you are running two instances of chuck~ or the combination thereof: i.e. two instances each running large files?
Maybe you can shrink it to the smallest case which is causing the crash and then we can be better informed on where to begin addressing it. |
I created a new Max patch and put in just one chuck~ with a subpatch with multiple It had the same behavior. Here is the top of the crash report:
|
Thanks, it looks like the audio thread crashed for some reason. Is there anyway to run the same patch in vanilla chuck (i.e. outside of Max using command line chuck or miniaudicle) |
Otherwise, can you provide more details of the patch and/or the file which is causing the crash, to see if I can replicate it somehow. |
Yes, this runs fine locally. I have a variable I've attached a zip file with all the files. burst.ck is the main file and has details on running it. It has file dependencies on all the other .ck files. To run:
That should also give you sound output. I've included two Max files. One is the bare patch with just the chuck files loader. The other is the full patch. Both of these crash Max when I load chuck files first, then turn on audio, and work file when audio is on before loading chuck. fyi - it is still possible this is something local to me. I've had some problems in the past with Max crashing - but nothing like this where I can reproduce it. Thanks for looking into this. Hopefully it yields something helpful. |
Ok thanks. I'll check it out. |
I think the problem was related to the file loading... I had a crash initially. I made some consistency changes in the chuck_tilde dev code and also added the feature to search for chuck files in the directory of the active patcher which simplifies things considerably. I also tweaked your patch a little bit (see attached)... but in the end it worked for me without issues. The code could use some cleanup, but in the interest of you being able to test / use it, I have committed it to the main branch. Let me know if it works for you. |
Thanks! I'm tied up the rest of the day but will get to it as soon as I can. Searching in the current directory is a nice improvement. |
No luck. I continue to have the same crash results. The new |
I just tried it again without it crashing (I'm on an M1 MacBook Air). I followed this sequence:
No issue with any of the above sequence... Are you following a different sequence which is leading to a crash? |
No - see my 1st comment:
So, to get a crash do this:
I'm on an intel iMac - MacOS 12.7.4 |
Ok, now I can reproduce it. I got the exact same crash. While it refers to the crash thread as:
The given crash traceback is as follows:
I think it has to do with how the audio thread starts and stops in void ck_dsp64(t_ck* x, t_object* dsp64, short* count, double samplerate,
long maxvectorsize, long flags)
{
// post("sample rate: %f", samplerate);
// post("maxvectorsize: %d", maxvectorsize);
delete[] x->in_chuck_buffer;
delete[] x->out_chuck_buffer;
x->in_chuck_buffer = new float[maxvectorsize * x->channels];
x->out_chuck_buffer = new float[maxvectorsize * x->channels];
memset(x->in_chuck_buffer, 0.f,
sizeof(float) * maxvectorsize * x->channels);
memset(x->out_chuck_buffer, 0.f,
sizeof(float) * maxvectorsize * x->channels);
object_method(dsp64, gensym("dsp_add64"), x, ck_perform64, 0, NULL);
}
void ck_perform64(t_ck* x, t_object* dsp64, double** ins, long numins,
double** outs, long numouts, long sampleframes, long flags,
void* userparam)
{
float* in_ptr = x->in_chuck_buffer;
float* out_ptr = x->out_chuck_buffer;
long n = sampleframes; // n = 64
if (ins) {
for (int i = 0; i < n; i++) {
for (int chan = 0; chan < numins; chan++) {
*(in_ptr++) = ins[chan][i];
}
}
}
x->chuck->run(x->in_chuck_buffer, x->out_chuck_buffer, n);
for (int i = 0; i < n; i++) {
for (int chan = 0; chan < numouts; chan++) {
outs[chan][i] = *out_ptr++;
}
}
} In Since the crashing point is given as the |
Ok - I had two attempts, the 2nd disables more code and doesn't crash. The first still crashes at thread with First attempt - same crash
Second attempt - runs without crash
|
I spent some time yesterday and today trying to figure this out.
Would it be possible get a minimum reproducible case where with one change in the code it starts working and if that is reversed it's stops working. I was having difficulties getting this from my side even with your instructions. I think this issue has something to do with events (as per the error traceback) and also threads, so it's going to take time to figure out. I'd like to have a minimal reproducible case to share with Chuck core developers. I noted in the comments in the chuck code around the event buffer that there was a crash previously circa 1.3 which was fixed with the addition of the event buffer, perhaps this crash is related to startup assumptions made around this which were broken with the combination of Max / chuck~ In any case, until this is figured out, the question is how do we fix this critical bug now? Here are some ideas:
I'd like to avoid (1), potentially start with (2) and hopefully, once we have understood the minimal reproducible case more clearly, end up with (3) or with another direct solution which address the problem at its source. |
@HighHarmonics2 I've applied the fix as per solution (2) in my prior post, and committed the change to main branch.. It's looks like scotch-tape but at least it works for now. |
On second thoughts, I will turn this into a switch that you can use for practical purposes, but I would like it off by default in order to catch more instances which crashes can occur. |
This makes sense - detect the fault condition and prevent the crash. I can work on a minimum reproducible solution. All that is needed is a .ck file with a minimal audio chain, an event, and a few globals to control the event from Max. Then a max patch that doesn't do much except trigger the event and change the globals. I don't think this needs multiple files, public classes, lots of globals, etc. But I'll make sure I can crash it reliably. It's great to have you working hard to get this fixed - full crashes in Max are awful, particularly to users who might not be prepared for it. But just so you know - I'm not blocked by this for my own chuck-max work. As long as audio is on before loading chuck files, everything runs fine. I'm offline the rest of today - but will try to test and respond again later tonight or tomorrow. |
Here is a ck + maxpat that can be used to test / validate.
|
Thanks for the new crash examples. FYI, I have added a not-so-well named attribute, |
fyi - |
Glad it's working for you. It's really a stop-gap measure until we can figure what's going on. |
I have a larger project with multiple chuck files, 12+ object instances, and a large event handler function. The Max patch is also large, with 2 separate instances of chuck~.
When I start the Max audio first, then load (run) the chuck program files, all is well.
When I load the chuck program files first, then start the audio, Max crashes.
I can reproduce the crash.
This is not a priority. I just need to remember to always start audio in Max before loading chuck files.
But it is worth considering. I would generally not expect to require the audio driver to be on first.
This problem does not occur with smaller chuck programs.
I may be operating outside the norm with 2 separate instances of chuck~ in a single Max patch.
The text was updated successfully, but these errors were encountered: