Ok, so after looking into your suggestions with renewed interest and with SDK 2.1.1 (thanks again for the pointers @professir ), and also trying to debug Copying a sample-based synth produces distorted sound, I think this crash is related to the latter bug.
At first, toggling the garbage collector off or removing the channels (and, I assume, recreating them afterwards with channel.new()
, since I didn't see a different way to add them back to the global list) did not seem to make a difference for this crash. As I mentioned I was already stopping all sound sources, so that didn't seem to be the problem either.
Then, narrowing down the repro steps for the above bug I had a breakthrough. Turns out that when loading a new music track for transitioning to a new level I was setting up instruments and, for polyphonic tracks, adding multiple voices with copies of the same synth; on repeating these steps for the next level, I would simply create a new instrument with the plain instrument.new()
, add voices the same way, then add the new instrument as a source to one of my channels (which made your suggestion of removing channels sound (no pun intended) very promising). Eventually this would make the OS crash, and this ended up happening in the simulator as well, despite my initial analysis indicating the contrary.
With the workaround from the bug above of creating a new synth for each voice, even with the same sample data, this crash seems to disappear. Back when this started happening the cause wasn't obvious to me at all, but getting distorted sound when copying synths showed that something was very wrong -- turns out there may be more going wrong with that synth copy than I first thought.
Perhaps this new information will be helpful for @wade or @dave or others who may want to take a look at what is happening in firmware code around synth copying.
EDIT: I've renamed this thread to make it clear this was no longer device-only.