Thanks for the reply -- yeah it is kind of driving me crazy. I had tried the "waitUntilCompleted" trick, but it didn't change anything. I also turned on all of those Malloc Guard/Scribble/Zombie settings in my scheme and didn't see any change.
It's so weird -- usually the first time I run the program in the day, it goes for several minutes before glitching out. But then once it has "warmed up", it glitches almost immediately. It seems to be like some kind of interference between my various shaders maybe. For example, I have a simple user interface and then I can draw lines into the "canvas". Only when I draw lines does it glitch. However, if I leave the interface out and ONLY draw lines, no glitches.
I tried recording with Instruments using the "Metal Trace" settings, and I've stared at the GPU frame capture, but I don't really know what I am doing. Nothing jumps out at me, except that after the program has glitched out and started showing those errors, it looks like the CPU usage spikes in the Instrument trace.
I've just moved on to other things now, but it makes it difficult only being able to run the program for a few seconds at a time before it hangs. So any other suggestions you have would be greatly appreciated!
EDIT: Actually what I say above about the line drawing interfering with the UI is incorrect. If I wait, it eventually starts glitching with the UI by itself and no lines drawn. It does seem like it happens more quickly the more elements are onscreen, but that's about all I can deduce from the situation so far.