28

I'm on macOS Sierra, Xcode 8, and get crashes whenever I try to Simulate Background Fetch on an actual iOS 10 device. This does NOT occur when using the simulator. This occurs in all projects, including those freshly created.

    libsystem_kernel.dylib`mach_msg_trap:
    0x18cfec164 <+0>: movn   x16, #0x1e
    0x18cfec168 <+4>: svc    #0x80
->  0x18cfec16c <+8>: ret   (Thread 1: signal SIGSTOP)

I don't have any other iOS devices to test with; is anyone else experiencing this?

1
  • Nope still borken in xcode 8.1
    – Sam B
    Mar 10, 2017 at 19:57

6 Answers 6

20

I'm running Xcode 8.1 with a device - it's not crashing but it's hitting a breakpoint that you can't find/edit/remove.

I go to Debug > Continue and it carries on as expected.

2
  • Do we know that this won't happen in production? - is it just a debugger thing?
    – Wez
    Dec 11, 2017 at 13:50
  • It doesn't happen in prod for me, which makes sense if it's a breakpoint Jan 11, 2018 at 11:38
16

You aren't alone - I'm encountering this as well. Really annoying. I've just filed a bug.

5
  • 12
    In my case, xcode simply pauses execution at that point. I noticed that if you tell it to continue execution that the background fetch is indeed simulated. Oct 1, 2016 at 6:28
  • That's good to hear. By radar was also recently marked as a duplicate, so at least we know Apple's aware of the issue.
    – Mattie
    Oct 4, 2016 at 13:32
  • 3
    @user3034715 is right, it looks like it's not a bug, but apple changing the way xcode does it, just hit the play button to solve this issue on xcode 8.0
    – Alex Trott
    Oct 6, 2016 at 14:30
  • Do you have an openradar I can dupe? Oct 31, 2016 at 21:24
  • I too am still seeing this in 8.2.1. It appears to fine after continuing, does anyone know for sure if this should be ignored? Jan 29, 2017 at 12:07
6

As pointed out by others. it is not a crash, but an auto breakpoint triggered by system. As explained here by eskimo:

So, why does it stop in mach_msg_trap? The goal is to give you a chance to set a breakpoint in your background fetch handling code, so Xcode forces your app to stop, just like it would if you hit the pause button (Debug > Pause). It stops in mach_msg_trap because that’s where your main thread is sitting when your app is suspended in the background. In short, when you do a Debug > Simulate Background Fetch and stop in mach_msg_trap:

  1. That’s expected behaviour
  2. It’s not a sign of any problem
  3. You can safely continue execution via Debug > Continue

Personally, I see it more like a bug than a feature.

2

It's not crashing, something is throwing a signal to pause execution of the app. Without knowing how the simulated fetch happens I can only guess why - it might be part of the simulation or a side effect of the way the app handles it. Xcode used to support permanently disabling breaks on signals (SIGPIPE was always my bane), but that hasn't worked for several versions now.

0

TARGETS -> Gapabilities -> Background Modes -> ON

and check [Audio, AirPlay, and Picture in Picture]

It worked for me.

-1

I just had this issue, it had something to do with pulling data from my backend and a casting type.

If you aren't familiar with firebase just look at the last two lines of this. If you are, here is how I fixed it. My data coming in looked something like this

"Node" : {
      "SubNode" : {
        "-KoB8OMIO0PLiTs8fUkJ" : {
      "ImageName" : "DSC05833-2.jpg",
      "price" : 100,
    },
    "-KoB8Rh9PtSMaMUlaD91" : {
      "ImageName" : "DSC05780-2.jpg",
      "price" : 0,
    },

And my code to pull.

ref.child("Node").child("SubNode").child(uniqueidID).observeSingleEvent(of: DataEventType.value, with: { (snapshot) in
        if snapshot.childrenCount > 0
        {
            let jsonPhoto = snapshot.value as? [String: AnyObject]
            let mageName = jsonPhoto?["ImageName"] as! String            
            photoObj.imagePrice = jsonPhoto?["price"] as! Double //error, Swift didn't catch, just froze my app
        }
})

it worked if value was 100 -> Double, and then for some reason firebase was failing when I casted 0 -> Double

So I fixed how I casted it

I originallyy had this:

photoObj.imagePrice = jsonPhoto?["price"] as! Double // caused error

to..

 photoObj.imagePrice = jsonPhoto?["price"] as? Double ?? 0.00 //fixed error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.