Error on iPhone but not on the simulator - swift

Since today i was running my app on Simulator with the 6s on iOS 10, but now I am running it on the iPhone 7. It shows me the following error when i press the Save button: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x000cfba4)
My code look like this:
#IBAction func SaveAction(_ sender: AnyObject) {
let dataString = DateTextfield.text
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM d, yyyy"
// convert string into date
let dateValue:NSDate? = dateFormatter.date(from: dataString!) as NSDate?
let nowDouble = dateValue?.timeIntervalSince1970
let hey = Int64(nowDouble!*1000) //Here is the error
let newdouble = Double(hey)
MyArray[Work]!["Date"]?.append(newdouble)
}
In the iOS simulator it works fine it saves the newdouble correctly to the dictionary named MyArray
If i run the app with Build Configuration: Debug
libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x100385174 <+0>: stp x26, x25, [sp, #-80]!
0x100385178 <+4>: stp x24, x23, [sp, #16]
0x10038517c <+8>: stp x22, x21, [sp, #32]
0x100385180 <+12>: stp x20, x19, [sp, #48]
0x100385184 <+16>: stp x29, x30, [sp, #64]
0x100385188 <+20>: add x29, sp, #64 ; =64
0x10038518c <+24>: mov x19, x6
0x100385190 <+28>: mov x20, x5
0x100385194 <+32>: mov x21, x4
0x100385198 <+36>: mov x22, x3
0x10038519c <+40>: mov x23, x2
0x1003851a0 <+44>: mov x24, x1
0x1003851a4 <+48>: mov x25, x0
0x1003851a8 <+52>: adr x8, #936952 ; protocol descriptor for Swift.CVarArg + 88
0x1003851ac <+56>: nop
0x1003851b0 <+60>: add x0, x8, #16 ; =16
0x1003851b4 <+64>: movz w1, #0x28
0x1003851b8 <+68>: orr w2, wzr, #0x7
0x1003851bc <+72>: bl 0x1003854a0 ; rt_swift_allocObject
0x1003851c0 <+76>: mov x8, x0
0x1003851c4 <+80>: stp x22, x21, [x8, #16]
0x1003851c8 <+84>: strb w20, [x8, #32]
0x1003851cc <+88>: str w19, [x8, #36]
0x1003851d0 <+92>: adr x3, #241008 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x1003851d4 <+96>: nop
0x1003851d8 <+100>: mov x0, x25
0x1003851dc <+104>: mov x1, x24
0x1003851e0 <+108>: mov x2, x23
0x1003851e4 <+112>: mov x4, x8
0x1003851e8 <+116>: bl 0x100278b70 ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (#out ()), Argument Types : [#callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x1003851ec <+120>: brk #0x1 //Error message here

Related

AVFoundation Mutex interlock on AVAudioPlayerNode.Stop

I am trying to write my first Swift application, and its running great!… in the simulator. The application is generating tones via AVFoundation, and it works well when I start playing the tones on the iPhone, but as soon as i try to stop the AVAudioPlayerNode, then 5 out of 10 times my iPhone application freezes up. Everything is working perfectly in the simulator.
Here are the stopping code:
#IBAction func togglePlay(_ sender: UIButton) {
if tone.isPlaying {
engine.mainMixerNode.volume = 0.0
tone.stop() // This is where is freezes up and tone is a AVAudioPlayerNode
engine.reset() // engine is a AVAudioEngine
sender.setImage(UIImage(named:"icons8-play-100")!, for: UIControl.State())
} else {
tone.preparePlaying()
tone.play()
engine.mainMixerNode.volume = 1.0
sender.setImage(UIImage(named:"icons8-stop-filled-100")!, for: UIControl.State())
}
If i pause the code when it freeze and look at the stack trace, then it looks like it's waiting for some sort of Mutex be be released. But I'm not experienced enough to know how to investigate further on what i'm doing wrong
Here are the stack trace:
VFAudio`-[AVAudioPlayerNode stop]:
0x187b68c34 <+0>: stp x22, x21, [sp, #-0x30]!
0x187b68c38 <+4>: stp x20, x19, [sp, #0x10]
0x187b68c3c <+8>: stp x29, x30, [sp, #0x20]
0x187b68c40 <+12>: add x29, sp, #0x20 ; =0x20
0x187b68c44 <+16>: mov x21, x0
0x187b68c48 <+20>: adrp x8, 177438
0x187b68c4c <+24>: add x8, x8, #0x700 ; =0x700
0x187b68c50 <+28>: ldr x19, [x8]
0x187b68c54 <+32>: cbz x19, 0x187b68c70 ; <+60>
0x187b68c58 <+36>: ldr x8, [x19]
0x187b68c5c <+40>: ldr x8, [x8, #0x10]
0x187b68c60 <+44>: mov x0, x19
0x187b68c64 <+48>: blr x8
0x187b68c68 <+52>: mov x20, x0
0x187b68c6c <+56>: b 0x187b68c74 ; <+64>
0x187b68c70 <+60>: mov w20, #0x0
0x187b68c74 <+64>: adrp x8, 177435
0x187b68c78 <+68>: add x8, x8, #0x9dc ; =0x9dc
0x187b68c7c <+72>: ldrsw x8, [x8]
0x187b68c80 <+76>: ldr x21, [x21, x8]
0x187b68c84 <+80>: ldr x8, [x21]
0x187b68c88 <+84>: ldr x8, [x8, #0x198]
0x187b68c8c <+88>: mov x0, x21
0x187b68c90 <+92>: blr x8
0x187b68c94 <+96>: ldr x0, [x21, #0x8] <— This is where it breaks
libsystem_kernel.dylib`__psynch_mutexwait:
0x181c15134 <+0>: mov x16, #0x12d
0x181c15138 <+4>: svc #0x80
-> 0x181c1513c <+8>: b.lo 0x181c15154 ; <+32>
What would be next step in debugging?
Pay attention to threading in your audio engine setup.
Had the same issue when saved audio frames from the injected equalizer unit:
equalizer.installTap(onBus: 0, ... ) { buffer, _ in
...
status = ExtAudioFileWrite(file, numberOfFrames, audioBufferList)
...
}
Mutex interlock was fixed by forwarding ExtAudioFileWrite call to the main thread

Why does my app run in the simulator but crash trying to launch on my iPhone?

I'm writing an app in Swift 3 using Xcode 8.3.2. My app runs fine in the Simulator but I get an ugly error message when I try to run it on my iPhone (iOS 10.3.1):
libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x1005203d0 <+0>: stp x26, x25, [sp, #-0x50]!
0x1005203d4 <+4>: stp x24, x23, [sp, #0x10]
0x1005203d8 <+8>: stp x22, x21, [sp, #0x20]
0x1005203dc <+12>: stp x20, x19, [sp, #0x30]
0x1005203e0 <+16>: stp x29, x30, [sp, #0x40]
0x1005203e4 <+20>: add x29, sp, #0x40 ; =0x40
0x1005203e8 <+24>: mov x19, x6
0x1005203ec <+28>: mov x20, x5
0x1005203f0 <+32>: mov x21, x4
0x1005203f4 <+36>: mov x22, x3
0x1005203f8 <+40>: mov x23, x2
0x1005203fc <+44>: mov x24, x1
0x100520400 <+48>: mov x25, x0
0x100520404 <+52>: adr x8, #0xf11fc ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
0x100520408 <+56>: nop
0x10052040c <+60>: add x0, x8, #0x10 ; =0x10
0x100520410 <+64>: mov w1, #0x28
0x100520414 <+68>: orr w2, wzr, #0x7
0x100520418 <+72>: bl 0x100520750 ; swift_rt_swift_allocObject
0x10052041c <+76>: mov x8, x0
0x100520420 <+80>: stp x22, x21, [x8, #0x10]
0x100520424 <+84>: strb w20, [x8, #0x20]
0x100520428 <+88>: str w19, [x8, #0x24]
0x10052042c <+92>: adr x3, #0x40440 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x100520430 <+96>: nop
0x100520434 <+100>: mov x0, x25
0x100520438 <+104>: mov x1, x24
0x10052043c <+108>: mov x2, x23
0x100520440 <+112>: mov x4, x8
0x100520444 <+116>: bl 0x1004014dc ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (#out ()), Argument Types : [#callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x100520448 <+120>: brk #0x1
I set an exception breakpoint that led me to this bit of code:
if let defaultFormula = dataManager.fetchDefaultFormula(moc) {
self.formula = defaultFormula.first! <<< Unexpectedly found nil...
}
and here is the function it's calling:
func fetchDefaultFormula(_ moc: NSManagedObjectContext) -> [Formula]? {
let defaultFormulaID = UserDefaults.formula()
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Formula")
let filterPredicate = NSPredicate(format: "uuid = [c] %#", defaultFormulaID)
fetchRequest.predicate = filterPredicate
do {
return try moc.fetch(fetchRequest) as? [Formula]
} catch {
fatalError("There was an error fetching the lifts")
}
return nil
}
The fetch request is returning 0 values so it's clear why I get the exception when I force unwrap it. However, the object property 'formula' must have a value. The first thing the app does is check to see if the default data (like the available formulas) exists in the persistent store and if it doesn't, it adds it. I've reset the Simulator and it dutifully adds them but it seems that this isn't happening on the iPhone. If there's a way for me to determine whether or not the records are being added to the store when running it on the iPhone, please enlighten me.
I've found a few SO threads in which others have experienced this cryptic error (the big, ugly one, not the unexpected nil) and I've tried all of the remedies suggested:
cleaned the project unplugged the iPhone, plugged it back in
restarted all devices
changed the Team to None and back to me
turned off Automatically manage signing and turned it back on
downloaded my current certificates
turned some flags from No to Yes in Build Settings
etc
I don't know where to go from here having exhausted all of the suggestions I've been able to find.
Any suggestions are greatly appreciated.
Well, I guess there was one thing I didn't try - uninstalling the app from my phone first, then build and run it on the phone.
So I don't really know what the root cause was, but at least this resolved the problem.

Thread issues happened whenever I tried to touch specific functions on my phone

My app does not crash on iOS 8.
But after updating it to 10 version on my phone, my app crashes when I try to use specific functions in the app.
But on simulator, it works well.
Whenever I installed the app on my phone, Thread # issues happened. And the number on # part always changes like below and I don't know why.
libsystem_kernel.dylib`__abort_with_payload:
0x1c5eb440 <+0>: mov r12, sp
0x1c5eb444 <+4>: push {r4, r5, r6, r8}
0x1c5eb448 <+8>: ldm r12, {r4, r5, r6}
0x1c5eb44c <+12>: mov r12, #512
0x1c5eb450 <+16>: orr r12, r12, #9
0x1c5eb454 <+20>: svc #0x80
-> 0x1c5eb458 <+24>: pop {r4, r5, r6, r8}
0x1c5eb45c <+28>: blo 0x1c5eb474 ; <+52>
0x1c5eb460 <+32>: ldr r12, [pc, #0x4] ; <+44>
0x1c5eb464 <+36>: ldr r12, [pc, r12]
0x1c5eb468 <+40>: b 0x1c5eb470 ; <+48>
0x1c5eb46c <+44>: bne 0x1cea6364 ; CFStringROMTableHashData + 14212
0x1c5eb470 <+48>: bx r12
0x1c5eb474 <+52>: bx lr
what does the below error mean?
0x1c5eb458 <+24>: pop {r4, 45, r6, r8} = Thread #: signal SIGABRT
And some comments mentioned that I can solve this issues if I deleted "search path" on info.plist. So I tried to delete "Search Path" on info following them but it didn't work at all.
This issue is solved.
The reason is microphone provisioning on info.plist.
Therefore, I added "privacy-microphone" menu on it.
And it's solved.

Automatic Reverse Segues

My app make a telephone call from my collection view controller. After the call app shows home page. Call is not returned to called controller.
I put break points and checked execution flow. Then I could realise that call returned to called controller. But after that some internal codes are running and automatically segue to home page view controller (initial view controller). I don't know anything about internal execution like
UIKit-[UIControl sendAction:to:forEvent:]:
0x1891f93b4 <+0>: stp x22, x21, [sp, #-48]!
0x1891f93b8 <+4>: stp x20, x19, [sp, #16]
0x1891f93bc <+8>: stp x29, x30, [sp, #32]
0x1891f93c0 <+12>: add x29, sp, #32
0x1891f93c4 <+16>: mov x19, x4
0x1891f93c8 <+20>: mov x20, x2
0x1891f93cc <+24>: mov x21, x0
0x1891f93d0 <+28>: mov x0, x3
0x1891f93d4 <+32>: bl
Finally I could track my problem..For some other reason I put a line of code inside the following App delegate method like:-
func applicationWillResignActive(application: UIApplication) {
window?.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
I commented the line of code and everything work fine...Thank God!!!!!

error: EXC_BREAKPOINT {code=1, subcode=0x18ee3c5c0}

I have problem with error. In theory this is breakpoint but I don't any.
0x18ee3c5a8 <+324>: b 0x18d9b2f20 ; objc_msgSend
0x18ee3c5ac <+328>: adrp x8, 145858
0x18ee3c5b0 <+332>: add x8, x8, #2296 ; =2296
0x18ee3c5b4 <+336>: adrp x9, 853
0x18ee3c5b8 <+340>: add x9, x9, #2656 ; =2656
0x18ee3c5bc <+344>: str x9, [x8, #8]
-> 0x18ee3c5c0 <+348>: brk #0x1
0x18ee3c5c4 <+352>: brk #0x1
0x18ee3c5c8 <+356>: brk #0x1
My app works when I use it on iPhone alone, but when I test it using Xcode and iPhone bug appers. Always in the same place. Sometimes after 5s sometimes after fiew minutes.
What XCode show me