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

"Headless" version of SynthOne crashes in manual render mode #110

Closed
jbmaxwell opened this issue Sep 25, 2019 · 8 comments
Closed

"Headless" version of SynthOne crashes in manual render mode #110

jbmaxwell opened this issue Sep 25, 2019 · 8 comments

Comments

@jbmaxwell
Copy link

jbmaxwell commented Sep 25, 2019

We're using a "headless" (UI-less) version of SynthOne in our app, just drawing on presets. We built an offline render mode, which renders into a tap and then writes to a file. We had it working on an earlier version, but some recent changes caused an error where now, as soon as we pass the first event after switching to manual render mode, the app crashes in void S1NoteState::startNoteHelper(int noteNumber, int velocity, float frequency) with an EXC_BAD_ACCESS.

* thread #18, queue = 'renderQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x4028000000000000)
  * frame #0: 0x00000001023a1e2c Spliqs`S1NoteState::startNoteHelper(this=0x0000000109561140, noteNumber=48, velocity=55, frequency=130.812775) at S1NoteState.mm:105:21
    frame #1: 0x00000001023b2818 Spliqs`S1DSPKernel::turnOnKey(this=0x000000010a06eb90, noteNumber=48, velocity=55, frequency=130.812775) at S1DSPKernel+toggleKeys.mm:85:14
    frame #2: 0x00000001023a6c84 Spliqs`S1DSPKernel::startNote(this=0x000000010a06eb90, noteNumber=48, velocity=55, frequency=130.812775) at S1DSPKernel+startStopNotes.mm:45:9
    frame #3: 0x000000010239d34c Spliqs`::-[S1AudioUnit startNote:velocity:frequency:](self=0x000000010a06ea00, _cmd="startNote:velocity:frequency:", note='0', velocity='7', frequency=130.812775) at S1AudioUnit.mm:98:13
    frame #4: 0x00000001027eb040 Spliqs`AKSynthOne.play(noteNumber=48, velocity=55, frequency=130.81277465820313, channel=0, self=0x00000002832c47d0) at AKSynthOne.swift:223:21
    frame #5: 0x00000001029ead8c Spliqs`AudioKit.AKPolyphonicNode.play(noteNumber: Swift.UInt8, velocity: Swift.UInt8, channel: Swift.UInt8) -> () + 328
    frame #6: 0x00000001026aca64 Spliqs`Conductor.handleMIDI(data1=144, data2=48, data3=55, self=0x000000010940f400) at Conductor.swift:392:23
    frame #7: 0x00000001026abb48 Spliqs`Conductor.handle(noteEvent=AudioKit.AKMIDINoteData @ 0x000000016e36a248, self=0x000000010940f400) at Conductor.swift:350:22
    frame #8: 0x0000000102823d28 Spliqs`SQRenderManager.createBufferArrayForFile(audioFile=0x0000000281394600, maximumFrameCount=512, duration=21.279160997732426, tail=1.5, self=0x0000000287a44070) at SQRenderManager.swift:286:31
    frame #9: 0x0000000102821e34 Spliqs`SQRenderManager.offlineRender(spliq=0x00000001094a6e00, completion=0x000000010282f488 Spliqs`closure #1 () -> () in closure #1 () -> () in closure #1 (RxSwift.Event<Spliqs.TimedWatchableEvent>) -> () in Spliqs.SQRenderManager.init(withModule: Spliqs.SequencerModule) -> Spliqs.SQRenderManager at SQRenderManager.swift:652, self=0x0000000287a44070) at SQRenderManager.swift:106:38
    frame #10: 0x000000010282f470 Spliqs`closure #1 in closure #1 in SQRenderManager.init(self=0x0000000287a44070, spliq=0x00000001094a6e00) at SQRenderManager.swift:652:76
    frame #11: 0x00000001023c37c0 Spliqs`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
    frame #12: 0x000000010902b1fc libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #13: 0x000000010902c77c libdispatch.dylib`_dispatch_client_callout + 20
    frame #14: 0x0000000109034a34 libdispatch.dylib`_dispatch_lane_serial_drain + 716
    frame #15: 0x000000010903573c libdispatch.dylib`_dispatch_lane_invoke + 412
    frame #16: 0x000000010903f474 libdispatch.dylib`_dispatch_workloop_worker_thread + 1172
    frame #17: 0x00000001f43c9a98 libsystem_pthread.dylib`_pthread_wqthread + 308
    frame #18: 0x00000001f43cfdc4 libsystem_pthread.dylib`start_wqthread + `4`

I've tried completely reconnecting my node graph, but I can't seem to find a way around it. Can anyone shed any light on why it's crashing?

Is there a recommended process for tearing down and rebuilding SynthOne, after stopping and restarting audio? Or is it possible that this is just something to do with manual rendering mode?

One possibility for the change in behaviour is that one of our developers upgraded to Xcode 10.3, which I believe forced an upgrade of AudioKit (i.e., to Swift 4.2). Is it possible that there's an incompatibility between AudioKit and the version of SynthOne we're using (it is not the most recent version).

@jbmaxwell
Copy link
Author

Adding a little info... I did try to upgrade the SynthOne code we're using, but I was getting build errors on sp_oscmorph2d. I've just tried building from the SynthOne repo and I see the same errors if I remove the version number from the Podfile.

@sieren
Copy link
Contributor

sieren commented Sep 25, 2019

Are you building from the develop branch? master is currently outdated.

@jbmaxwell
Copy link
Author

Ah, I am building from master, yes. I'll try with develop.

@jbmaxwell
Copy link
Author

jbmaxwell commented Sep 25, 2019

I'm getting Swift 5 related errors now. Our project is 4.2 (on Xcode 10.3). Is that going to be a showstopper, or is there a version of AudioKit that will work?

UPDATE: Okay, looks like I get back to the same issue with sp_oscmorph2d when running on 4.8 (specifying the pod as < 4.9 just installs 4.8). Maybe this is a showstopper... Do you have any idea what might be going on with the EXC_BAD_ACCESS when stopping and restarting AudioKit? I have tested SynthOne itself (master branch, with the AK 4.7 beta version specified in that podfile) and the problem doesn't happen there.
I've double-checked the problem, and even just adding:

DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
            print("Stop engine (as a test)")
            AudioKit.engine.stop()
            DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
                print("Restart engine... does stuff play?")
                try! AudioKit.engine.start()
            }
        }

at the end of my init (in Conductor), and it will crash on playing from SynthOne.

@sieren
Copy link
Contributor

sieren commented Sep 26, 2019

The oscmorph bug got fixed in AudioKit 4.9, so you might wanna use that.

Please provide me with a new stacktrace based on a recent Synth One version, else I can't make any sense of the line numbers inside of it.

Unforuntately I don't have enough time right now to set up an environment that reflects yours. Is there any specific reason you cannot upgrade your project to the most recent swift version?

@jbmaxwell
Copy link
Author

Yes, like you, time is the main reason we're still on Swift 4.2... But I guess we may have to change that sooner rather than later. I did try with AudioKit 4.7.2.b1 (as in the master branch), using our original Synth One code, but I get the same crash. What I'll do a little later is try with 4.7.2.b1 with your master code (which I've confirmed doesn't have the basic stop/start bug), in our project, and see if that works to keep us going, for now.

@jbmaxwell
Copy link
Author

Failing a short-term fix for the stop/restart crash, what would be the recommended routine for tearing everything down and starting over—i.e., as if from initial launch? Since it is only the offline rendering/export routine that's causing a problem, it is an option for us to just completely rebuild the audio graph, but I haven't found a reliable process for doing that (which surprises me, since it seems like it should be very simple). Are there any "gotchas" that come to mind, in terms of de/re-instantiating Synth One?

@jbmaxwell
Copy link
Author

Okay, a Swift 5 upgrade did cure this issue. Thanks.

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