为了录制音频,我将一个新 View 显示为 subview ,录制后我使用 RemoveFromSuperview 删除其中的 subview 。只是为了描述我如何处理叠加层。
问题是,在使用 AVAudioRecorder 录制后,应用程序有时会在删除覆盖 View 后立即崩溃,有时 super View 会消失。
崩溃日志如下所示:
Incident Identifier: 65BE4068-D7BE-4F3F-B739-00006CAB74CC
CrashReporter Key: d97865bbdce37e60edb2f77974b8b86911a1007e
Hardware Model: iPad4,1
Process: B2MobileBjiOS [8764]
Path: /var/mobile/Applications/3C397A5D-B00B-40CE-BCF8-0C6836B0EBB2/B2MobileBjiOS.app/B2MobileBjiOS
Identifier: ch.bauplus.mobile.bj.trunk
Version: 30 (1.0)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2014-01-20 13:54:04.160 +0100
OS Version: iOS 7.0.4 (11B554a)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x39f8a1fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x39ff1a4f pthread_kill + 55
2 libsystem_c.dylib 0x39f3b029 abort + 73
3 B2MobileBjiOS 0x01607d95 mono_handle_native_sigsegv (mini-exceptions.c:2335)
4 B2MobileBjiOS 0x01612a99 mono_sigsegv_signal_handler (mini.c:6744)
5 libsystem_platform.dylib 0x39fec721 _sigtramp + 41
6 libAVFAudio.dylib 0x2e2db0b3 -[AVAudioRecorder dealloc] + 119
7 libAVFAudio.dylib 0x2e2db0b3 -[AVAudioRecorder dealloc] + 119
8 libobjc.A.dylib 0x399e5b07 objc_object::sidetable_release(bool) + 171
9 B2MobileBjiOS 0x016bfb00 monotouch_release_managed_ref (monotouch-glue.m:1296)
10 B2MobileBjiOS 0x0109629c wrapper_managed_to_native_MonoTouch_Foundation_NSObject_monotouch_release_managed_ref_intptr + 88
11 B2MobileBjiOS 0x00cb31d8 MonoTouch_Foundation_NSObject_ReleaseManagedRef + 28
12 B2MobileBjiOS 0x00cb559c MonoTouch_Foundation_NSObject_NSObject_Disposer_Drain_MonoTouch_Foundation_NSObject + 360
13 B2MobileBjiOS 0x006802cc wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
14 B2MobileBjiOS 0x01614b75 mono_jit_runtime_invoke (mini.c:6610)
15 B2MobileBjiOS 0x0165c77b mono_runtime_invoke (object.c:2827)
16 B2MobileBjiOS 0x0158e7e7 native_to_managed_trampoline_MonoTouch_Foundation_NSObject_NSObject_Disposer_Drain (registrar.m:344)
17 Foundation 0x2fd22e47 __NSThreadPerformPerform + 383
18 CoreFoundation 0x2f309f1d __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 13
19 CoreFoundation 0x2f309469 __CFRunLoopDoSources0 + 337
20 CoreFoundation 0x2f307bd3 __CFRunLoopRun + 627
21 CoreFoundation 0x2f27246d CFRunLoopRunSpecific + 521
22 CoreFoundation 0x2f27224f CFRunLoopRunInMode + 103
23 GraphicsServices 0x33f732e7 GSEventRunModal + 135
24 UIKit 0x31b27841 UIApplicationMain + 1133
25 B2MobileBjiOS 0x010e1af8 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 268
26 B2MobileBjiOS 0x00d617f4 MonoTouch_UIKit_UIApplication_Main_string___string_string + 296
27 B2MobileBjiOS 0x002062f4 B2.Mobile.Bj.iOS.Application:Main (Main.cs:16)
28 B2MobileBjiOS 0x006802cc wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
29 B2MobileBjiOS 0x01614b75 mono_jit_runtime_invoke (mini.c:6610)
30 B2MobileBjiOS 0x0165c77b mono_runtime_invoke (object.c:2827)
31 B2MobileBjiOS 0x016604f9 mono_runtime_exec_main (object.c:4052)
32 B2MobileBjiOS 0x01660349 mono_runtime_run_main (object.c:3678)
33 B2MobileBjiOS 0x015fec5d mono_jit_exec (driver.g.c:1009)
34 B2MobileBjiOS 0x016a95cc main (main.m:489)
35 libdyld.dylib 0x39ed3ab5 start + 1
AudioRecordingOverlay.cs
AudioHelper.cs
Best Answer-推荐答案 strong>
问题在于 AVAudioRecorder。如果使用不带参数的构造函数创建 AVAudioRecorder,则对象释放时会崩溃。
您可以使用 C# 轻松重现崩溃:
var recorder = new AVAudioRecorder();
recorder.Dispose();
或使用 Swift(即使在 Playground 上):
var recorder: AVAudioRecorder? = AVAudioRecorder()
recorder = nil
在您的代码中,您使用 new AVAudioRecorder(); 初始化 _recorder ,因此当它被垃圾收集时,您在处理对象时遇到异常。
只需使用“正确”构造函数创建记录器。
AVAudioRecorder.Create(NSUrl url, AudioSettings settings, out NSError error);
关于c# - View 消失后 AVAudioRecorder 崩溃,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/21235044/
|