Xamarin throwing error when stopping audio

0

On occassion, my Xamarin.iOS throws a SIGSEGV error when stopping audio.

2016-08-30 11:34:28.400 MyAppiOS[285:23021] critical: Stacktrace:
2016-08-30 11:34:28.400 MyAppiOS[285:23021] critical:   at <unknown> <0xffffffff>
2016-08-30 11:34:28.401 MyAppiOS[285:23021] critical:   at (wrapper managed-to-native) System.Runtime.InteropServices.GCHandle.CheckCurrentDomain (int) <0x0003f>
2016-08-30 11:34:28.401 MyAppiOS[285:23021] critical:   at System.Runtime.InteropServices.GCHandle.op_Explicit (intptr) [0x0001b] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Runtime.InteropServices/GCHandle.cs:124
2016-08-30 11:34:28.402 MyAppiOS[285:23021] critical:   at System.Runtime.InteropServices.GCHandle.FromIntPtr (intptr) [0x00000] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Runtime.InteropServices/GCHandle.cs:166
2016-08-30 11:34:28.403 MyAppiOS[285:23021] critical:   at AudioToolbox.SystemSound.SoundCompletionShared (AudioToolbox.SystemSoundId,intptr) <0x0002b>
2016-08-30 11:34:28.403 MyAppiOS[285:23021] critical:   at (wrapper native-to-managed) AudioToolbox.SystemSound.SoundCompletionShared (AudioToolbox.SystemSoundId,intptr) <0x0004f>
2016-08-30 11:34:28.403 MyAppiOS[285:23021] critical:   at <unknown> <0xffffffff>
2016-08-30 11:34:28.404 MyAppiOS[285:23021] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x0004f>
2016-08-30 11:34:28.404 MyAppiOS[285:23021] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/UIKit/UIApplication.cs:79
2016-08-30 11:34:28.404 MyAppiOS[285:23021] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/UIKit/UIApplication.cs:62
2016-08-30 11:34:28.404 MyAppiOS[285:23021] critical:   at MyApp.iOS.Application.Main (string[]) [0x00001] in C:\Dev\securecom\Mobile\MyApp\trunk\MyApp.iOS\Main.cs:26
2016-08-30 11:34:28.405 MyAppiOS[285:23021] critical:   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0x000ff>
2016-08-30 11:34:28.407 MyAppiOS[285:23021] critical: 
Native stacktrace:
2016-08-30 11:34:28.507 MyAppiOS[285:23021] critical:   0   MyAppiOS                       0x00093a91 mono_handle_native_sigsegv + 242
2016-08-30 11:34:28.507 MyAppiOS[285:23021] critical:   1   MyAppiOS                       0x0009afeb mono_sigsegv_signal_handler + 222
2016-08-30 11:34:28.508 MyAppiOS[285:23021] critical:   2   libsystem_platform.dylib            0x242d585f _sigtramp + 42
2016-08-30 11:34:28.508 MyAppiOS[285:23021] critical:   3   ???                                 0x0000000a 0x0 + 10
2016-08-30 11:34:28.508 MyAppiOS[285:23021] critical:   4   MyAppiOS                       0x000bfb0b mono_gc_GCHandle_CheckCurrentDomain + 18
2016-08-30 11:34:28.508 MyAppiOS[285:23021] critical:   5   MyAppiOS                       0x004fa414 wrapper_managed_to_native_System_Runtime_InteropServices_GCHandle_CheckCurrentDomain_int + 72
2016-08-30 11:34:28.508 MyAppiOS[285:23021] critical:   6   MyAppiOS                       0x004fa34c System_Runtime_InteropServices_GCHandle_op_Explicit_intptr + 72
2016-08-30 11:34:28.509 MyAppiOS[285:23021] critical:   7   MyAppiOS                       0
x004fa82c System_Runtime_InteropServices_GCHandle_FromIntPtr_intptr + 36
2016-08-30 11:34:28.509 MyAppiOS[285:23021] critical:   8   MyAppiOS                       0x00642e84 AudioToolbox_SystemSound_SoundCompletionShared_AudioToolbox_SystemSoundId_intptr + 44
2016-08-30 11:34:28.509 MyAppiOS[285:23021] critical:   9   MyAppiOS                       0x006948ec wrapper_native_to_managed_AudioToolbox_SystemSound_SoundCompletionShared_AudioToolbox_SystemSoundId_intptr + 80
2016-08-30 11:34:28.510 MyAppiOS[285:23021] critical:   10  CoreFoundation                      0x24567909 <redacted> + 12
2016-08-30 11:34:28.511 MyAppiOS[285:23021] critical:   11  CoreFoundation                      0x245673c5 <redacted> + 216
2016-08-30 11:34:28.511 MyAppiOS[285:23021] critical:   12  CoreFoundation                      0x2456594b <redacted> + 818
2016-08-30 11:34:28.511 MyAppiOS[285:23021] critical:   13  CoreFoundation                      0x244b41c9 CFRunLoopRunSpecific + 516
2016-08-30 11:34:28.512 MyAppiOS[285:23021] critical:   14  CoreFoundation                      0x244b3fbd CFRunLoopRunInMode + 108
2016-08-30 11:34:28.512 MyAppiOS[285:23021] critical:   15  GraphicsServices                    0x25ad0af9 GSEventRunModal + 160
2016-08-30 11:34:28.512 MyAppiOS[285:23021] critical:   16  UIKit                               0x28bed435 UIApplicationMain + 144
2016-08-30 11:34:28.512 MyAppiOS[285:23021] critical:   17  MyAppiOS                       0x00682310 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 252
2016-08-30 11:34:28.512 MyAppiOS[285:23021] critical:   18  MyAppiOS                       0x005fabe0 UIKit_UIApplication_Main_string___intptr_intptr + 52
2016-08-30 11:34:28.513 MyAppiOS[285:23021] critical:   19  MyAppiOS                       0x005faba0 UIKit_UIApplication_Main_string___string_string + 204
2016-08-30 11:34:28.513 MyAppiOS[285:23021] critical:   20  MyAppiOS                       0x0016d92c MyApp_iOS_Application_Main_string__ + 160
2016-08-30 11:34:28.513 MyAppiOS[285:23021] critical:   21  MyAppiOS                       0x00593dc4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 
ime or one of the native libraries 
used by your application.
=================================================================
256
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   22  MyAppiOS                       0x0009ca19 mono_jit_runtime_invoke + 1588
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   23  MyAppiOS                       0x000e141f mono_runtime_invoke + 102
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   24  MyAppiOS                       0x000e49fb mono_runtime_exec_main + 284
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   25  MyAppiOS                       0x0015939c xamarin_main + 2232
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   26  MyAppiOS                       0x00c09669 main + 112
2016-08-30 11:34:28.514 MyAppiOS[285:23021] critical:   27  libdyld.dylib                       0x24160873 <redacted> + 2
2016-08-30 11:34:28.515 MyAppiOS[285:23021] critical: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runt

Any help preventing this error from being thrown? I've tried putting the code that stops the audio into a try-catch but it still crashes the app.

I have an array of SystemSounds that when I exit the ViewController I want to stop playing all of the sounds. If a sound is currently playing then the code executes fine. It appears to throw the above error when one sound is completed and the next hasn't started. My code for stopping the audio is:

try
{
    if (_tracks != null)  // an array of tracks that have to be played
    {
         for (int i = _soundQueue - 1; i >= 0; i--)  // _soundQueue is the num of tra
         {
              _tracks[i].Item1.RemoveSystemSoundCompletion();
              _tracks[i].Item1.Close();
         }
    }
    _soundQueue = 0;
    _tracks = null;
    _playingAudio = false; 
}
catch (Exception ex)
{

}
ios
audio
xamarin.ios
audiotoolbox
system-sounds
asked on Stack Overflow Aug 30, 2016 by binncheol

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0