EXC_BREAKPOINT in BGAppRefreshTask

When I run my app with XCode on my iPhone, and then moved into the background, I'm getting a EXC_BREAKPOINT exception after a few minutes, seemingly when iOS attempts to call my app with a BGAppRefreshTask:

Thread 23 Queue: com.apple.BGTaskScheduler (com.mycompany.MyApp.RefreshTask) (serial)
0 _dispatch_assert_queue_fail
12 _pthread_wqthread
Enqueued from com.apple.duet.activityscheduler.client.xpcqueue (Thread 23)
0 dispatch_async
20 start_wqthread

I can't quite understand the reason from this crash. In the background task, I'm attempting to update live activities. In the process, it might encounter code that calls MainActor and manipulate @Observable objects. Might that be the reason?

It still happens even after clearing any MainActor in its way.

The assert happens in this assembly:

libdispatch.dylib`_dispatch_assert_queue_fail:
...
    0x103ae8274 <+68>:  add    x9, x9, #0xe52            ; "BUG IN CLIENT OF LIBDISPATCH: Assertion failed: "
    0x103ae8278 <+72>:  stp    x9, x8, [sp]
    0x103ae827c <+76>:  adrp   x1, 63
    0x103ae8280 <+80>:  add    x1, x1, #0xe1d            ; "%sBlock was %sexpected to execute on queue [%s (%p)]"
    0x103ae8284 <+84>:  sub    x0, x29, #0x18
    0x103ae8288 <+88>:  bl     0x103b23d60               ; symbol stub for: asprintf
    0x103ae828c <+92>:  ldur   x19, [x29, #-0x18]
    0x103ae8290 <+96>:  str    x19, [sp]
    0x103ae8294 <+100>: adrp   x0, 63
    0x103ae8298 <+104>: add    x0, x0, #0xe88            ; "%s"
    0x103ae829c <+108>: bl     0x103b1fed4               ; _dispatch_log
    0x103ae82a0 <+112>: adrp   x8, 101
    0x103ae82a4 <+116>: str    x19, [x8, #0x1c0]
->  0x103ae82a8 <+120>: brk    #0x1

Is that something I control or is it a bug for Apple?

Please post a full crash report; see Posting a Crash Report for advice on how to do that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

EXC_BREAKPOINT in BGAppRefreshTask
 
 
Q