Bug 53180 - SIGABRT on AVAudioRecorder PrepareToRecord()
Summary: SIGABRT on AVAudioRecorder PrepareToRecord()
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-03-09 10:41 UTC by norman.schuett
Modified: 2017-03-13 09:46 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: Yes
Last known good build: 31.05.2016


Attachments
Test Case (6.77 KB, application/zip)
2017-03-10 09:55 UTC, norman.schuett
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description norman.schuett 2017-03-09 10:41:17 UTC
I took this code from an app we made and which is already in store (and still running without issues). But when I try to run it in a new app, I get a SIGABRT.

Here´s a sample class which I used to reproduced the crash in Xamarin.Forms via DependencyService. The error property remains null after creating the recorder.


public class RedordDependencies : IRecordDependencies
{
    NSObject[] values = new NSObject[] {
        NSNumber.FromFloat (44100.0f), //Sample Rate
        NSNumber.FromInt32 ((int)AudioToolbox.AudioFormatType.LinearPCM), //AVFormat
        NSNumber.FromInt32 (2), //Channels
        NSNumber.FromInt32 (16), //PCMBitDepth
        NSNumber.FromBoolean (false), //IsBigEndianKey
        NSNumber.FromBoolean (false) //IsFloatKey
    };

    NSObject[] keys = new NSObject[] {
        AVAudioSettings.AVSampleRateKey,
        AVAudioSettings.AVFormatIDKey,
        AVAudioSettings.AVNumberOfChannelsKey,
        AVAudioSettings.AVLinearPCMBitDepthKey,
        AVAudioSettings.AVLinearPCMIsBigEndianKey,
        AVAudioSettings.AVLinearPCMIsFloatKey
    };

    AVAudioRecorder recorder;
    NSError error;
    NSDictionary settings;

    public RedordDep()
    {
        settings = NSDictionary.FromObjectsAndKeys(values, keys);
    }

    public string Prepare()
    {
        NSUrl path = NSUrl.FromString(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), DateTime.Now.Ticks.ToString() + ".wav"));
        recorder = AVAudioRecorder.Create(path, new AudioSettings(settings), out error);
        bool prepared = recorder.PrepareToRecord();
        return path.Path;
    }
}
Comment 1 norman.schuett 2017-03-10 09:55:59 UTC
Created attachment 20267 [details]
Test Case
Comment 2 Vincent Dondain [MSFT] 2017-03-10 18:32:00 UTC
Hey,

Just tried the test case with the following environment (https://gist.github.com/VincentDondain/bb2959c3f7571f01de3edc7ceb878fd8) and it works fine.

No SIGABRT.

Could you please send us the application output showing the SIGABRT as well as your environment information: Xamarin Studio > About > Show details.
Comment 3 norman.schuett 2017-03-13 06:56:11 UTC
Hi,

thanks for your feedback. Did you try it on Device?
On Simulator it seems to working.
Here is my Version: 

https://gist.github.com/SYNTaXx89/789f68be977942af8e84c1e22f96bdca
Comment 4 norman.schuett 2017-03-13 07:23:58 UTC
Here is the SIGABRT

https://gist.github.com/SYNTaXx89/86c8ac9ea54d392d565f405f69f8fed7
Comment 5 norman.schuett 2017-03-13 09:46:10 UTC
Just got a similar SIGABRT when using

AVCaptureDeviceInput.FromDevice(device);

After more research it came out that this stacktrace is related to missing privacy setup in info.plist.
In my case I was missing the Keys:
NSCameraUsageDescription
NSMicrophoneUsageDescription