Commit 6f2fa46
authored
[e-m-c] fix queue assertion crash (expo#41296)
# Why
Ran into an issue with background tasks (triggered by a background
notification):
<details>
<summary>Details</summary>
```
(lldb) bt
* thread #19, queue = 'expo.application.remoteNotification', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1038578e4)
frame #0: 0x00000001038578e4 libdispatch.dylib`_dispatch_assert_queue_fail + 120
frame #1: 0x000000010388e01c libdispatch.dylib`dispatch_assert_queue$V2.cold.1 + 116
frame #2: 0x0000000103857868 libdispatch.dylib`dispatch_assert_queue + 108
frame #3: 0x000000018996003c libswift_Concurrency.dylib`_swift_task_checkIsolatedSwift + 48
frame #4: 0x00000001899bf724 libswift_Concurrency.dylib`swift_task_isCurrentExecutorWithFlagsImpl(swift::SerialExecutorRef, swift::swift_task_is_current_executor_flag) + 356
frame #5: 0x00000001050e6678 notificationtester.debug.dylib`closure #1 in closure #2 in static ExpoAppDelegateSubscriberManager.application(result=.noData, failedCount=0, newDataCount=0,
subscribersLeft=2, completionHandler=0x0000000104f6dea8 notificationtester.debug.dylib`partial apply forwarder for reabstraction thunk helper from @escaping @callee_unowned @convention(block) (@unowned
__C.UIBackgroundFetchResult) -> () to @escaping @callee_guaranteed (@unowned __C.UIBackgroundFetchResult) -> () at <compiler-generated>) at ExpoAppDelegateSubscriberManager.swift:0
frame #8: 0x000000010386e2e0 libdispatch.dylib`_dispatch_client_callout + 16
frame #9: 0x00000001038653cc libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 172
* frame #10: 0x00000001050e650c notificationtester.debug.dylib`closure #2 in static ExpoAppDelegateSubscriberManager.application(result=.noData, dispatchQueue=0x000000012c455d80, failedCount=0,
newDataCount=0, subscribersLeft=2, completionHandler=0x0000000104f6dea8 notificationtester.debug.dylib`partial apply forwarder for reabstraction thunk helper from @escaping @callee_unowned @convention(block)
(@unowned __C.UIBackgroundFetchResult) -> () to @escaping @callee_guaranteed (@unowned __C.UIBackgroundFetchResult) -> () at <compiler-generated>) at ExpoAppDelegateSubscriberManager.swift:225:21
frame #12: 0x0000000104f6bad8 notificationtester.debug.dylib`__94-[EXLegacyAppDelegateWrapper
application:didReceiveRemoteNotification:fetchCompletionHandler:]_block_invoke(.block_descriptor=0x0000000120206340, result=UIBackgroundFetchResultNoData) at EXLegacyAppDelegateWrapper.m:212:9
frame #13: 0x0000000104f65064 notificationtester.debug.dylib`__63-[EXTaskService runTasksWithReason:userInfo:completionHandler:]_block_invoke(.block_descriptor=0x000000012bbebc90, results=@"1 element")
at EXTaskService.m:351:7
frame #14: 0x0000000104f666f8 notificationtester.debug.dylib`__67-[EXTaskService _runTasksSupportingLaunchReason:userInfo:callback:]_block_invoke(.block_descriptor=0x0000000120204f80, results=@"1
element") at EXTaskService.m:517:7
frame #15: 0x0000000104f60cdc notificationtester.debug.dylib`-[EXTaskExecutionRequest _maybeExecuteCallback](self=0x000000012c519b60, _cmd="_maybeExecuteCallback") at EXTaskExecutionRequest.m:59:5
frame #16: 0x0000000104f60c74 notificationtester.debug.dylib`-[EXTaskExecutionRequest maybeEvaluate](self=0x000000012c519b60, _cmd="maybeEvaluate") at EXTaskExecutionRequest.m:46:5
frame #17: 0x0000000104f60b98 notificationtester.debug.dylib`-[EXTaskExecutionRequest task:didFinishWithResult:](self=0x000000012c519b60, _cmd="task:didFinishWithResult:", task=0x0000000120370840,
result=(long)1) at EXTaskExecutionRequest.m:35:3
frame #18: 0x0000000104f63e64 notificationtester.debug.dylib`-[EXTaskService notifyTaskWithName:forAppId:didFinishWithResponse:](self=0x00000001200014c0,
_cmd="notifyTaskWithName:forAppId:didFinishWithResponse:", taskName=@"BACKGROUND_NOTIFICATION_TASK", appId=@"mainApplication", response=1 key/value pair) at EXTaskService.m:217:7
frame #19: 0x0000000104f617c4 notificationtester.debug.dylib`-[EXTaskManager notifyTaskFinished:withResponse:resolve:reject:](self=0x0000000120371600,
_cmd="notifyTaskFinished:withResponse:resolve:reject:", taskName=@"BACKGROUND_NOTIFICATION_TASK", response=1 key/value pair, resolve=0x000000010ad20e7c, reject=0x000000010ad213bc) at EXTaskManager.m:104:3
frame #20: 0x000000018b4ee6c4 CoreFoundation`__invoking___ + 148
frame #21: 0x000000018b4ee550 CoreFoundation`-[NSInvocation invoke] + 424
frame #22: 0x0000000105015b5c notificationtester.debug.dylib`-[EXExportedModule callExportedMethod:withArguments:resolver:rejecter:](self=0x0000000120371600,
_cmd="callExportedMethod:withArguments:resolver:rejecter:", methodName=@"notifyTaskFinishedAsync", arguments=@"2 elements", resolve=0x000000010ad20e7c, reject=0x000000010ad213bc) at EXExportedModule.m:168:3
frame #23: 0x000000010501fa10 notificationtester.debug.dylib`__79-[EXNativeModulesProxy callMethod:methodNameOrKey:arguments:resolver:rejecter:]_block_invoke(.block_descriptor=0x0000000122ea9270) at
EXNativeModulesProxy.mm:243:7
frame #24: 0x000000010385463c libdispatch.dylib`_dispatch_call_block_and_release + 32
frame #25: 0x000000010386e2e0 libdispatch.dylib`_dispatch_client_callout + 16
frame expo#26: 0x000000010385cb4c libdispatch.dylib`_dispatch_lane_serial_drain + 796
frame expo#27: 0x000000010385d7d4 libdispatch.dylib`_dispatch_lane_invoke + 432
frame expo#28: 0x0000000103869b20 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 344
frame expo#29: 0x00000001038691c4 libdispatch.dylib`_dispatch_workloop_worker_thread + 752
frame expo#30: 0x00000001e7d803b8 libsystem_pthread.dylib`_pthread_wqthread + 292
```
</details>
# How
- dispatch the completion handlers on main queue
# Test Plan
- tested locally with notification-tester app
# Checklist
<!--
Please check the appropriate items below if they apply to your diff.
-->
- [x] I added a `changelog.md` entry and rebuilt the package sources
according to [this short
guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)1 parent 4cf4ae0 commit 6f2fa46
File tree
2 files changed
+41
-44
lines changed- packages/expo-modules-core
- ios/AppDelegates
2 files changed
+41
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
Lines changed: 40 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
170 | 174 | | |
171 | | - | |
172 | 175 | | |
173 | | - | |
174 | | - | |
| 176 | + | |
| 177 | + | |
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
| |||
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 186 | + | |
| 187 | + | |
189 | 188 | | |
190 | 189 | | |
191 | 190 | | |
| |||
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
219 | 223 | | |
220 | | - | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | | - | |
225 | | - | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
| |||
243 | 246 | | |
244 | 247 | | |
245 | 248 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 249 | + | |
| 250 | + | |
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
| |||
288 | 287 | | |
289 | 288 | | |
290 | 289 | | |
291 | | - | |
292 | 290 | | |
293 | 291 | | |
294 | | - | |
295 | | - | |
| 292 | + | |
| 293 | + | |
296 | 294 | | |
297 | 295 | | |
298 | 296 | | |
| |||
306 | 304 | | |
307 | 305 | | |
308 | 306 | | |
309 | | - | |
| 307 | + | |
310 | 308 | | |
311 | 309 | | |
312 | 310 | | |
| |||
319 | 317 | | |
320 | 318 | | |
321 | 319 | | |
322 | | - | |
323 | 320 | | |
324 | 321 | | |
325 | | - | |
326 | | - | |
| 322 | + | |
| 323 | + | |
327 | 324 | | |
328 | 325 | | |
329 | 326 | | |
| |||
337 | 334 | | |
338 | 335 | | |
339 | 336 | | |
340 | | - | |
| 337 | + | |
341 | 338 | | |
342 | 339 | | |
343 | 340 | | |
| |||
369 | 366 | | |
370 | 367 | | |
371 | 368 | | |
372 | | - | |
373 | 369 | | |
374 | | - | |
375 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
| |||
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 386 | + | |
| 387 | + | |
391 | 388 | | |
392 | 389 | | |
393 | 390 | | |
| |||
403 | 400 | | |
404 | 401 | | |
405 | 402 | | |
406 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
411 | | - | |
| 410 | + | |
| 411 | + | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
| 432 | + | |
| 433 | + | |
438 | 434 | | |
439 | 435 | | |
440 | 436 | | |
| |||
0 commit comments