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

iOS Examples crashing on load #981

Closed
AlexHarker opened this issue Jun 18, 2023 · 6 comments
Closed

iOS Examples crashing on load #981

AlexHarker opened this issue Jun 18, 2023 · 6 comments
Labels
bug Something isn't working ios Issue relates to iOS

Comments

@AlexHarker
Copy link
Collaborator

AlexHarker commented Jun 18, 2023

See here:

https://iplug2.discourse.group/t/crashing-ios-examples/795/3

reproduced on iPad 9th generation emulator (on intel and ARM desktops) using iPlugEffect

@AlexHarker AlexHarker added the ios Issue relates to iOS label Jun 18, 2023
@AlexHarker
Copy link
Collaborator Author

The crash happens from here when the completion hander is called with an error (and then an error is caused that is unhandled):

[AVAudioUnit instantiateWithComponentDescription:desc options:0

@AlexHarker AlexHarker added the bug Something isn't working label Jun 18, 2023
@AlexHarker
Copy link
Collaborator Author

Actually the above is incorrect - the error returns as nil and then the following line crashes:

[audioEngine connect:audioEngine.inputNode to:avAudioUnit format: micInputFormat];

Possibly this doesn't work on emulator? @olilarkin - do you know anything about this?

@olilarkin
Copy link
Member

IIRC, This is a problem on the simulator when the macOS audio device is not the built-in apple I/O. I get the crash when my babyface pro is the default interface, but not when built-in is the default. Here is a WIP fix I did at somepoint, i don't think it is correct:

diff --git forkSrcPrefix/IPlug/AUv3/iOSApp/IPlugAUPlayer.mm forkDstPrefix/IPlug/AUv3/iOSApp/IPlugAUPlayer.mm
index 159513a624a776092e3bdae25c2e1bc4c710c170..f88c2be0d8099a3bd5fd52182760783490981ac1 100644
--- forkSrcPrefix/IPlug/AUv3/iOSApp/IPlugAUPlayer.mm
+++ forkDstPrefix/IPlug/AUv3/iOSApp/IPlugAUPlayer.mm
@@ -62,7 +62,6 @@
   [session setCategory: AVAudioSessionCategoryPlayAndRecord error:&error];
 #endif
   
-  [session setPreferredSampleRate:iplug::DEFAULT_SAMPLE_RATE error:nil];
   [session setPreferredIOBufferDuration:128.0/iplug::DEFAULT_SAMPLE_RATE error:nil];
   AVAudioMixerNode* mainMixer = [audioEngine mainMixerNode];
   mainMixer.outputVolume = 1;
@@ -72,7 +71,8 @@
   AVAudioFormat* micInputFormat = [[audioEngine inputNode] inputFormatForBus:0];
   AVAudioFormat* pluginInputFormat = [avAudioUnit inputFormatForBus:0];
 #endif
-  
+  [session setPreferredSampleRate:micInputFormat.sampleRate error:nil];
+
   AVAudioFormat* pluginOutputFormat = [avAudioUnit outputFormatForBus:0];
 
   NSLog(@"Session SR: %i", int(session.sampleRate));
@@ -87,7 +87,7 @@
   
 #if PLUG_TYPE != 1
   if (pluginInputFormat != nil)
-    [audioEngine connect:audioEngine.inputNode to:avAudioUnit format: micInputFormat];
+    [audioEngine connect:audioEngine.inputNode to:avAudioUnit format: pluginInputFormat];
 #endif
   
   auto numOutputBuses = [avAudioUnit numberOfOutputs];

@olilarkin
Copy link
Member

duplicate of #944 i think

@AlexHarker
Copy link
Collaborator Author

Confirmed as a duplicate - it so happened that I was on my RME when testing - so this is annoying, but not a showstopper...

@olilarkin
Copy link
Member

closing as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios Issue relates to iOS
Projects
None yet
Development

No branches or pull requests

2 participants