2

My app is consuming a third party library and there is crash that happens on certain device such as iOS 13.3

Tried calling the method on main thread

Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation] PID: 1496, TID: 390696, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0

2020-01-28 12:31:47.733875+0000 My BT Gotham[1496:390696] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'

Tried calling the method on background thread

Here is the errror

  • Assertion failure in -[FBSSerialQueue assertOnQueue], /BuildRoot/Library/Caches/com.apple.xbs/Sources/FrontBoardServices/FrontBoard-626.4.1/FrontBoardServices/FBSSerialQueue.m:98 2020-01-28 17:23:47.972336+0000 My BT Gotham[1773:459656] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'

FYI: I always the API method on background thread and it works fine in most of the devices the issue that I quoted above works only in some devices.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
    [LibObj model_Method:self];
});
Naveen
  • 77
  • 6
  • 2
    error says " 'threading violation: expected the main thread'", did u try calling it on main thread? – Teja Nandamuri Jan 28 '20 at 17:55
  • 2
    Does this answer your question? [iOS 13: threading violation: expected the main thread](https://stackoverflow.com/questions/58335061/ios-13-threading-violation-expected-the-main-thread) – Teja Nandamuri Jan 28 '20 at 17:56
  • @TejaNandamuri - I tried calling on main thread i'm getting crash again uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread' – Naveen Jan 28 '20 at 17:58
  • 2
    If you really call it on the main thread maybe the bug is on the third party library. In that case I don't think there is much we can do with just this info – jeprubio Jan 28 '20 at 18:02

1 Answers1

0

As it appears, you are calling UI methods from the background... It should be something like:

DispatchQueue.main.async {
  // use your method...
} 

But if your third-party lib is already doing the DispatchQueue.main call behind the scenes, is possible that when you do your async call it gets messed up...

Carla Camargo
  • 574
  • 5
  • 14
  • I tried calling the method on main thread in async fashion on Objective C. dispatch_async(dispatch_get_main_queue(), ^{ }); – Naveen Jan 28 '20 at 18:12
  • But thing to note is it's working in all the devices and crashes in few devices when I call in background thread. – Naveen Jan 28 '20 at 18:13
  • Which devices? arm64e only? ios 13 only? How consistent is the crash? It has to have a pattern... – Carla Camargo Jan 28 '20 at 18:14
  • the device that I'm testing is iphone 6s – Naveen Jan 28 '20 at 18:16
  • dispatch_async(dispatch_get_main_queue(), ^{ ///Write your code Here. Mostly UI update should be writen here. In my case i am calling method of common controller like this. myclass myMethod:self] }); – Shrikant Phadke Apr 03 '20 at 06:59
  • yes, few devices make this crash, and it's seem only debug – famfamfam Mar 27 '21 at 10:45