ios – App crashing due to this error but function found based on error logs seem fine to me

[ad_1]

Im dealing with this type of issue for the time and been stuck at this for weeks now. I already posted about finding location of error & tried to solve on my own after finding however I don’t know what might be causing error here. Everything seems to be fine. Here’s the error log file code:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018569e1a8
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [2868]

Triggered by Thread:  0


Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get


Thread 0 name:
Thread 0 Crashed:
0   libswiftCore.dylib              0x000000018569e1a8 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 300 (AssertCommon.swift:96)
1   libswiftCore.dylib              0x000000018569df48 closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 220 (AssertCommon.swift:89)
2   libswiftCore.dylib              0x000000018569d83c _assertionFailure(_:_:file:line:flags:) + 232 (AssertCommon.swift:85)
3   TestAlertApp                    0x0000000102992da4 0x102834000 + 1437092
4   TestAlertApp                    0x0000000102992320 0x102834000 + 1434400
5   TestAlertApp                    0x000000010288c8a0 0x102834000 + 362656
6   AudioToolbox                    0x000000018b839d1c AudioSessionRequestRecordPermission + 76 (AudioSession.cpp:0)
7   AudioSession                    0x000000018a0640a8 softLink_AudioSessionRequestRecordPermission + 52 (SoftLinking_AudioToolbox_iOS.mm:48)
8   AudioSession                    0x000000018a05af74 -[AVAudioSession requestRecordPermission:] + 116 (AVAudioSession_iOS.mm:1328)
9   TestAlertApp                    0x0000000102991f50 0x102834000 + 1433424
10  TestAlertApp                    0x000000010299187c 0x102834000 + 1431676
11  TestAlertApp                    0x0000000102994f70 0x102834000 + 1445744
12  TestAlertApp                    0x000000010288c37c 0x102834000 + 361340
13  TestAlertApp                    0x0000000102b03b98 closure #1 in AlertMeViewController.initiateAlertMe(_:_:) + 1836 (AlertMeViewController.swift:311)
14  TestAlertApp                    0x00000001029e724c 0x102834000 + 1782348
15  TestAlertApp                    0x0000000102cfbb64 closure #1 in static SLWebRequest.post(url:params:headers:completionHandler:) + 640 (SLWebRequest.swift:55)
16  Alamofire                       0x000000010352bcb0 partial apply for specialized closure #2 in closure #2 in closure #3 in closure #1 in DownloadRequest.response<A>(queue:responseSerializer:completionHandler:) + 48
17  Alamofire                       0x00000001034c441c thunk for @escaping @callee_guaranteed () -> () + 20 (<compiler-generated>:0)
18  libdispatch.dylib               0x000000018091d924 _dispatch_call_block_and_release + 32 (init.c:1517)
19  libdispatch.dylib               0x000000018091f670 _dispatch_client_callout + 20 (object.m:560)
20  libdispatch.dylib               0x000000018092db70 _dispatch_main_queue_callback_4CF + 944 (inline_internal.h:2601)
21  CoreFoundation                  0x0000000180c65d84 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1795)
22  CoreFoundation                  0x0000000180c1ff5c __CFRunLoopRun + 2540 (CFRunLoop.c:3144)
23  CoreFoundation                  0x0000000180c33468 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
24  GraphicsServices                0x000000019c7d738c GSEventRunModal + 164 (GSEvent.c:2200)
25  UIKitCore                       0x00000001835d65d0 -[UIApplication _run] + 1100 (UIApplication.m:3493)
26  UIKitCore                       0x0000000183354f74 UIApplicationMain + 364 (UIApplication.m:5047)
27  TestAlertApp                    0x000000010289654c 0x102834000 + 402764
28  dyld                            0x00000001032adaa4 start + 520 (dyldMain.cpp:879)

So based on this error, I found this code:

func initAudio(_ alertType: String) {
     if self.checkPermission() == 0 {
          if AVAudioSession.sharedInstance().outputVolume < 0.0625 {
              let soundid = kSystemSoundID_Vibrate
              AudioServicesPlaySystemSound(soundid)
              self.deleteAllRecordings()
          }else{
              self.alerttype = alertType
              self.deleteAllRecordings()
           }
       }else if self.checkPermission() == 1 {
           gotoPermission(1)
       }else{
           gotoPermission(2)
       }
}

Im totally lost here what might be wrong. Is it caused by AVAudioSession? or the two functions, self.deleteAllRecordings() or gotoPermission(1) or gotoPermission(2)?

Here’s the code for deleteAllRecordings() just in case:

func deleteAllRecordings() {
        print("\(#function)")

        if self.recorder != nil {
            self.recorder.stop()
        }
        let docsDir =
            NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]

        let fileManager = FileManager.default

        do {
            let files = try fileManager.contentsOfDirectory(atPath: docsDir)
            let recordings = files.filter( { (name: String) -> Bool in
                return name.hasSuffix("wav")
            })
            for i in 0 ..< recordings.count {
                let path = docsDir + "/" + recordings[i]

                print("removing \(path)")
                do {
                    try fileManager.removeItem(atPath: path)
                } catch {
                    NSLog("could not remove \(path)")
                }
            }
            self.record()

        } catch {
            print("could not get contents of directory at \(docsDir)")
            print(error.localizedDescription)
        }

    }

and code for gotoPermission():

func gotoPermission(_ grant: Int){
        if grant == 1 {
            self.askForPermission()
        }else {
            if !self.initiatorStatus.InAlertMe && !self.initiatorStatus.InTimedAlert{
                self.beepStartPlayer.play()
                DispatchQueue.main.async {
                    Timer.scheduledTimer(withTimeInterval: Double(User().cUser.RecordSeconds), repeats: false, block: { _ in
                        if self.initiatorStatus.InAlert == true {
                            self.startBeep()
                        }
                    })
                }
            }  }
        
    }

Is there something that might cause te crash in above code? According to log file, this is where the error occurs.

[ad_2]

Source link

Leave a Reply

Your email address will not be published.