AUSampler crash: 'breaking out of infinite loop'

I have an AUSampler and occassionally my app will crash with a log message

912:  BREAKING OUT OF INFINITE LOOP
. The stack trace is:
#0  0x000000018515b548 in VoiceZone::Process(unsigned long long, AudioBufferList**, unsigned int, unsigned int) ()
#1  0x00000001852a17bc in SamplerNote::Render(unsigned long long, unsigned int, AudioBufferList**, unsigned int) ()
#2  0x00000001852a1b28 in non-virtual thunk to SamplerNote::Render(unsigned long long, unsigned int, AudioBufferList**, unsigned int) ()
#3  0x000000018544abf4 in SynthGroupElement::Render(long long, unsigned int, AUScope&) ()
#4  0x000000018544f588 in AUInstrumentBase::Render(unsigned int&, AudioTimeStamp const&, unsigned int) ()
#5  0x000000018520f168 in SamplerBase::Render(unsigned int&, AudioTimeStamp const&, unsigned int) ()
#6  0x0000000185445480 in AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement*, unsigned int, AudioBufferList&) ()
#7  0x0000000185444c0c in AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) ()
#8  0x000000018544dfb0 in AUMethodRender(void*, unsigned int*, AudioTimeStamp const*, unsigned int, unsigned int, AudioBufferList*) ()
#9 <my code>

This only seems to happen with certain presets and certain combinations of events, although I haven't figured out the pattern. Does anyone know why this may be happening and how to prevent it?

I believe this was fixed in iOS 11.3. The cause was very complicated.


-DS

I'm running into this issue again in iOS 14.0. This time it's not crashing or logging a message, but the audio thread is stuck in an infinite loop when playing a note.

The audio thread hangs and never returns from AudioUnitRender, and stopping the app at various points shows a stack trace in various calls below SamplerNote::Render but never above it.

The issue seems to relate to the envelope parameters & the timing of the note start & stop events. For example:

Given a DAHDSR envelope described as: (D:0, A:0, H:0, D:0, S:0, R:0):

A 32nd note at 104-123 BPM (note durations of 0.06097561s-0.072115385s) with envelope (D:0, A:0, H:0.06 D:0, S:0, R:0) will hang after playing a few times. Changing the Hold to 0.5 causes "bad BPMs" to move to 120-149 BPM (0.05033557s-0.0625s). Changing other envelope parameters to be > 0 also seems to cause the issue to go away but there is no clear pattern or guarantee that it's fixed for all BPMs/note durations.

This issue is not reproducible on iOS 13 and macOS 10.15.6.
AUSampler crash: 'breaking out of infinite loop'
 
 
Q