12

I have an app that runs fine on iOS, but when running with catalyst, it gives me this crash intermittently if I swipe to another virtual Desktop on macOS, and then back, for about 10 times. It mostly happens on a UICollectionViewController

This is the backtrace:

(lldb) bt
* thread #5, queue = 'com.apple.xpc.activity.com.apple.cloudkit.scheduler.com.apple.coredata.cloudkit.activity.export', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007fff68c373ae libxpc.dylib`___xpc_activity_dispatch_block_invoke.107.cold.3 + 19
    frame #1: 0x00007fff68c1ecdb libxpc.dylib`___xpc_activity_dispatch_block_invoke.107 + 746
    frame #2: 0x00000001010377b3 libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #3: 0x000000010103878f libdispatch.dylib`_dispatch_client_callout + 8
    frame #4: 0x000000010103fd31 libdispatch.dylib`_dispatch_lane_serial_drain + 777
    frame #5: 0x0000000101040ae8 libdispatch.dylib`_dispatch_lane_invoke + 438
    frame #6: 0x000000010104df2e libdispatch.dylib`_dispatch_workloop_worker_thread + 681
    frame #7: 0x00000001010c4053 libsystem_pthread.dylib`_pthread_wqthread + 290
    frame #8: 0x00000001010c3eb3 libsystem_pthread.dylib`start_wqthread + 15
(lldb) 

I have tried reviewing the codes, adding print statements, adding breakpoints, commenting out certain parts etc, trying to figure out which part of my code causes this, but failed so far.

I am using NSPersistentCloudKitContainer from iOS 13. Does the stack trace points to a bug inside there?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Phuah Yee Keat
  • 1,572
  • 1
  • 17
  • 17
  • 2
    Did you ever figure this out? I'm having the same problem. – CompC Nov 15 '19 at 15:44
  • No I haven't, and this question gets downvoted, sigh. – Phuah Yee Keat Nov 16 '19 at 07:38
  • 3
    Same issue here but on Mac... – Niels Mouthaan Jan 18 '20 at 09:01
  • 6
    Worth mentioning the issue only seems to appear when running directly from Xcode. The exported release build seems to work without any problems. I have not tested it with the latest Xcode and SDK yet so perhaps that could fix the issue... – Niels Mouthaan Jan 23 '20 at 09:44
  • 1
    Has anyone figured out how to fix this? – fphelp Apr 19 '20 at 07:18
  • 1
    This is weird, but I'm getting the exact same crash, while running the app from Xcode. When I run the app alone (without Xcode) it works perfectly, so that makes me thinking that there's a bug within Xcode? Has anyone fixed this? – Ivan Cantarino Apr 27 '20 at 10:04
  • I'm seeing the same crash running my mac app in Xcode. I've made an attempt at isolating and reproducing the crash in a small sample project but I've had no luck.. Is anyone able to do this and then potentially submit feedback to Apple? – Joey Slomowitz Apr 27 '20 at 13:03
  • 1
    Update: I've successfully isolated and reproduced the crash in my sample project. I'll prepare to submit this as feedback to Apple now. – Joey Slomowitz Apr 27 '20 at 14:20
  • 1
    This is driving me nuts. I cannot figure out why this happens and have to run the app from Xcode, then quit, then run the app all by itself in order to test it; otherwise the app will crash with that same error after a few seconds. It even crashes without me performing any CoreData operations. – Ivan Cantarino Apr 29 '20 at 17:22
  • @IvanCantarino would be great if you could also send feedback to Apple with your crash. Perhaps this may raise the priority surrounding this issue – Joey Slomowitz Apr 30 '20 at 00:43
  • @JoeySlomowitz I will do it, but I don’t know what’s really causing it internally (some CoreData CloudKit collision). Don’t they always ask for the steps to reproduce the error? – Ivan Cantarino Apr 30 '20 at 07:23
  • Actually the issue can be reproduced with apple sample app for the cloudkitpersistentcontainer. Apple have responded to ask me to test on beta Xcode and beta MacOS. Which I can’t because I need the stable version for building and I don’t have a spare. – Phuah Yee Keat Apr 30 '20 at 07:26
  • @PhuahYeeKeat well, that's an advance. It crashes even with the Apple's sample app, so I guess they might be into it now. – Ivan Cantarino Apr 30 '20 at 08:25
  • @PhuahYeeKeat thank goodness, I hope they're onto it – Joey Slomowitz Apr 30 '20 at 08:36
  • 7
    Same crash here on macOS. On my project it looks like it only happens when I use spotlight with CoreData. I also reproduced it using Apple's sample code and submitted a feedback for it - FB7677591. Finally, as this is really annoying, I also opened a developer's support ticket, so I'm actually in contact with Apple technical support team about this. Fingers crossed... – Macmade May 01 '20 at 00:23
  • any updates on this @Macmade? – Joey Slomowitz May 24 '20 at 00:46

1 Answers1

4

I've wasted so much time trying to understand the source of the problem and hope that this answer helps many others.

This problems seems to persist now since a long time and has not been fixed, nor understood. But the big hint I've read in the comments: This crash happens only when the app is run from within Xcode.

Another important hint: You can can run your build product directly from Finder without crashing. Even if it is a "Debug" build.

Based on this, I've come to the conclusion that the problem is related to the Debug execution environment and I found the solution: Disable "Debug XPC services used by this application"
There must be some bug in the debugging code used by this option.

You can find this option in your targets scheme.

  1. Click on your target in the window bar
  2. Select "Edit Scheme..."
  3. Make sure "Run" is selected and remove the checkmark for "Debug XPC services used by this application"

I hope this helps everybody!

pd95
  • 1,999
  • 1
  • 20
  • 33
  • 1
    still crashing with "___xpc_activity_dispatch_block_invoke.109.cold.3" but maybe less often – Munhitsu May 28 '20 at 22:51
  • @Munhitsu Hmm... This was exactly the error location I had when "Debug XPC services" was still enabled. Did you verify you disabled Debug XPC on the correct scheme? Possibly you have multiple schemes in your project. Can you confirm, that running your product directly from Finder (=Catalyst App?!), does not lead to the crash? – pd95 May 29 '20 at 20:29