21

My app is crashed only on iOS13 with the following call stack:

#57. Crashed: com.twitter.crashlytics.ios.exception
0  myapp                          0x105d6d494 CLSProcessRecordAllThreads + 376 (CLSProcess.c:376)
1  myapp                          0x105d6d87c CLSProcessRecordAllThreads + 407 (CLSProcess.c:407)
2  myapp                          0x105d5d58c CLSHandler + 26 (CLSHandler.m:26)
3  myapp                          0x105d6bab4 __CLSExceptionRecord_block_invoke + 198 (CLSException.mm:198)
4  libdispatch.dylib              0x1be5c100c _dispatch_client_callout + 20
5  libdispatch.dylib              0x1be5cd804 _dispatch_lane_barrier_sync_invoke_and_complete + 60
6  myapp                          0x105d6b55c CLSExceptionRecord + 205 (CLSException.mm:205)
7  myapp                          0x105d6b390 CLSExceptionRecordNSException + 102 (CLSException.mm:102)
8  myapp                          0x105d6afb4 CLSTerminateHandler() + 258 (CLSException.mm:258)
9  libc++abi.dylib                0x1be6d9634 std::__terminate(void (*)()) + 20
10 libc++abi.dylib                0x1be6d8f58 __cxa_get_exception_ptr + 34
11 libc++abi.dylib                0x1be6d8f10 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 126
12 libobjc.A.dylib                0x1be6341f8 _objc_exception_destructor(void*) + 362
13 Foundation                     0x1bee05434 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints] + 322
14 Foundation                     0x1bebfeb94 -[NSISEngine _optimizeWithoutRebuilding] + 72
15 Foundation                     0x1bebfeaa8 -[NSISEngine optimize] + 116
16 Foundation                     0x1bebfe718 -[NSISEngine performPendingChangeNotifications] + 116
17 UIKitCore                      0x1c2e447c4 -[UIView(Hierarchy) layoutSubviews] + 316
18 UIKitCore                      0x1c23c6948 -[UIButton layoutSubviews] + 596
19 UIKitCore                      0x1c2e57abc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2156
20 libobjc.A.dylib                0x1be62faf0 -[NSObject performSelector:withObject:] + 68
21 QuartzCore                     0x1c53f60f4 -[CALayer layoutSublayers] + 292
22 QuartzCore                     0x1c53f63fc CA::Layer::layout_if_needed(CA::Transaction*) + 484
23 QuartzCore                     0x1c5409964 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140
24 QuartzCore                     0x1c534ec1c CA::Context::commit_transaction(CA::Transaction*, double) + 308
25 QuartzCore                     0x1c5379bd8 CA::Transaction::commit() + 684
26 QuartzCore                     0x1c537abc0 CA::Transaction::release_thread(void*) + 232
27 libsystem_pthread.dylib        0x1be62c3c0 _pthread_tsd_cleanup + 584
28 libsystem_pthread.dylib        0x1be624dbc _pthread_exit + 84
29 libsystem_pthread.dylib        0x1be626de8 _pthread_wqthread_legacy_worker_wrap + 98
30 libsystem_pthread.dylib        0x1be626b30 _pthread_wqthread + 424
31 libsystem_pthread.dylib        0x1be62cc78 start_wqthread + 8

--

Fatal Exception: NSInternalInconsistencyException
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
0  CoreFoundation                 0x1be919c30 __exceptionPreprocess
1  libobjc.A.dylib                0x1be6340c8 objc_exception_throw
2  Foundation                     0x1bee05434 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints]
3  Foundation                     0x1bebfeb94 -[NSISEngine _optimizeWithoutRebuilding]
4  Foundation                     0x1bebfeaa8 -[NSISEngine optimize]
5  Foundation                     0x1bebfe718 -[NSISEngine performPendingChangeNotifications]
6  UIKitCore                      0x1c2e447c4 -[UIView(Hierarchy) layoutSubviews]
7  UIKitCore                      0x1c23c6948 -[UIButton layoutSubviews]
8  UIKitCore                      0x1c2e57abc -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
9  libobjc.A.dylib                0x1be62faf0 -[NSObject performSelector:withObject:]
10 QuartzCore                     0x1c53f60f4 -[CALayer layoutSublayers]
11 QuartzCore                     0x1c53f63fc CA::Layer::layout_if_needed(CA::Transaction*)
12 QuartzCore                     0x1c5409964 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
13 QuartzCore                     0x1c534ec1c CA::Context::commit_transaction(CA::Transaction*, double)
14 QuartzCore                     0x1c5379bd8 CA::Transaction::commit()
15 QuartzCore                     0x1c537abc0 CA::Transaction::release_thread(void*)
16 libsystem_pthread.dylib        0x1be62c3c0 _pthread_tsd_cleanup
17 libsystem_pthread.dylib        0x1be624dbc _pthread_exit
18 libsystem_pthread.dylib        0x1be626de8 _pthread_wqthread_legacy_worker_wrap
19 libsystem_pthread.dylib        0x1be626b30 _pthread_wqthread
20 libsystem_pthread.dylib        0x1be62cc78 start_wqthread

I absolutely do not have any idea, what can occure this problem and how can i reproduce. It crashes randomly. I use Crashlytics v3.14 in my project. Does anybody face with the same problem?

bemul12
  • 413
  • 2
  • 4
  • 13

5 Answers5

18

Do you have google ads enabled in your app? It then could be a bug in Google ads sdk or be a bug in WebKit SDK implementation on iOS 13. (sry I can't comment, so I post this as answer)

Piggybacking off of this -- Reading through above linked thread, the "official" solution from the Google Ads team as of Nov 19 2019 is to modify your App's plist to include the following key/pair to use wkwebview instead of uiwebview.

<key>gad_preferred_webview</key>
<string>wkwebview</string>

Source: https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ios/I4EEWrPPbSc

Kurt J
  • 2,558
  • 24
  • 17
own2pwn
  • 311
  • 2
  • 7
  • 1
    Thanks your answer. I do not have Google ads in my app, but i have a UIWebView inside it, but UIWebView is a part of UIKit, not WebKit. – bemul12 Oct 16 '19 at 09:16
  • Do you use UIWebView or WKWebview? – own2pwn Oct 16 '19 at 09:26
  • I use UIWebView. – bemul12 Oct 16 '19 at 09:28
  • 2
    Same issue here. I'm still waiting for a new update by Google. In the current version (7.52.0) this error still exists. – fdlr Nov 27 '19 at 07:32
  • Is using this fix negatively effecting anyones ad delivery/income? – edhnb Dec 06 '19 at 22:10
  • Happening here and release notes for 7.53.1 don't address this. – Mike Flynn Dec 21 '19 at 03:37
  • 1
    @nab Possibly, yes. One developer reported loss of revenue, citing that "show rate" dropped ~10% https://groups.google.com/d/msg/google-admob-ads-sdk/PuHOKMX1mVI/25HdNhRxBgAJ And another reported decrease in "show rate" percentage: https://groups.google.com/d/msg/google-admob-ads-sdk/PuHOKMX1mVI/ScgCHMrLAAAJ – 262Hz Dec 31 '19 at 21:27
  • 1
    Here's the "official" solution from Google: https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ios/I4EEWrPPbSc but note there is one known issue: ads with sound will ALWAYS play the sound, regardless of the vibrate switch being on. – 262Hz Dec 31 '19 at 21:34
12

First of all I would recommend to turn on the "Main Thread Checker", in Xcode, go to Product -> Scheme -> Edit scheme -> Diagnostics, you should see this window Diagnostics tab Another thing you could try is going to your breakpoint section in Xcode and clicking the + sign and adding a symbolic breakpoint, that will listen on a specific call and you can add a condition to it for checking if it is called on the main thread.

A symbolic breakpoint

If you happen to find your bug in the code, please post it here, as I am experiencing the same crash as you in my app, so this is as far as I have gone to finding out the bug. Hope it helps you out!

OldTimes
  • 300
  • 1
  • 3
  • 16
  • I have tried this suggestion, but unfortunately i did not catch the crash. – bemul12 Oct 28 '19 at 10:19
  • My problem was in local authorization (touch ID, face ID), I was presenting another view controller on a background thread, and my app crashed only later after using the app for about 2 minutes randomly. You could try to check that out – OldTimes Oct 29 '19 at 12:20
  • If i understand correctly, your problem was caught by the main thread checker and you found it under the runtime warnings section. I checked a lot of flows in my app and i did not get runtime warnings by main thread checker. – bemul12 Oct 30 '19 at 11:42
  • It wasn't exactly in the closure of the authentication. I was actually calling a delegate method from the closure, telling a view controller that the user is authenticated, start building up the main screen, that seemed to instantiate a tab bar while still on the background thread, and that is where the main thread checker worked, so I digged down and found out that delegate being called not on main thread is the issue – OldTimes Oct 30 '19 at 13:38
6

This issue might be due to Google ads SDK(7.5X.X + iOS13), found this thread.

Developers tried to use below key-pair value in Info.plist file as suggested by Google Ads team.

<key>gad_preferred_webview</key>
<string>wkwebview</string>

This decreased crash but this is giving another freeze issue(100% CPU usages).

Recently Google released 7.55.0 with a note :

Removed all references to UIWebView. UIWebView is no longer supported.

so try to update Google ads SDK to 7.55.0

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65
4

In order to show stack traces for your threads, Crashlytics needs to run some code post-crash. Because this code is executing on one of your app’s threads, Crashlytics always captures information about its own execution as part of this process. You will always see a thread executing the “CLSProcessRecordAllThreads” function. In fact, you’ll see it more than once, due to a compiler optimization called inlining. enter image description here Exceptions add an extra bit of complexity. When a Objective-C or C++ exception goes uncaught, Crashlytics records some information about it before the app is allowed to terminate. When this happens, the CLSProcessRecordAllThreads function must be run on the thread that threw the exception. This means that in the case of an exception, the “crashing” thread will always look like it is running Crashlytics code. This is normal, and is just an artifact of how we capture and present the stack traces at the time of exception.

Zubair
  • 525
  • 4
  • 13
  • 1
    Since the "the crashing thread will always look like it is running Crashlytics code", how do you determine what the actual crashing thread is? – johnny Feb 04 '20 at 17:58
  • I am also getting the error, please find the given crashlytics stacktrace Please help if someone knows the reason and way to fix, Its more than a week, I couldn't figure it out. I am very frustrated and it's become a headache now `Stacktrace: https://i.stack.imgur.com/xszZY.jpg` – Muhammad Owais Jun 13 '20 at 13:41
0

Is this still a thing with Google-Mobile-Ads-SDK version 8.8 and iOS 14.x?

Adding gad_preferred_webview wkwebview to the info.plist just decreases the amount of errors in my app, but still does not dissappear completely.

CoreAutoLayout: _AssertAutoLayoutOnAllowedThreadsOnly

still occurs on some devices (around 5% of total users), even GADBannerView is only created and accessed from DispatchQueue.main.async {}

cpro90
  • 176
  • 10