Unsupported use of UIKit API off the main thread: UIAccessibilityIsAssistiveTouchRunning()

Hi,


I have been seen the following errors in our app on iOS 13 Beta:


[Assert] Unsupported use of UIKit API off the main thread: UIAccessibilityIsAssistiveTouchRunning()

[Assert] Unsupported use of UIKit API off the main thread: UIAccessibilityIsGuidedAccessEnabled()


The errors are not seen on iOS 12 and older versions. Does anyone know what caused these errors?


Thanks!

Replies

You (or some other code) probably call those API out of the main thread.


Need to execute the call in the main thread.

        DispatchQueue.main.async { () -> Void in
          // call API here
     }


The cause is probably that IOS 13 is more strict on checking this requirement.

You could run threadChecker or threadSanitizer tool on your code, to find any other similar issue:


https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

Thanks for the help.


I enabled both threadChecker or threadSanitizer tool in my project but when I saw the warnings about "Unsupported use of UIKit API off the main thread", there was no issue ever caught.


Also, I searched for the usage of those calls "UIAccessibilityIsAssistiveTouchRunning()" and "UIAccessibilityIsGuidedAccessEnabled()" but they were never called directly in the project.

Problem is that they are probably called indirectly.


Could you set a breakpoint in debugger to stop on UIAccessibilityIsAssistiveTouchRunning and see who's calling ?

Did you every find the solution for this? I have the same issue and cannot find the cause.

In my case it was called by Firebase/Chrashlytics/etc google stuff, I just updated their cocoapods and everything was fixed.

This solved the issue for me 😎

I'm getting a similar crash, but having to do with setTintColor on UIImageView, but it's not my code:


2019-11-12 10:36:54.498311-0500 <APP NAME>[850:78347] [Assert] Unsupported use of UIKit view-customization API off the main thread. -setTintColor: sent to <UIImageView: 0x155d97130; frame = (0 0; 22 22); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x283cc11c0>>

2019-11-12 10:36:54.505194-0500 <APP NAME>[850:78347] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

Stack:(

0 Foundation 0x0000000193176cd4 0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 2251988

1 Foundation 0x0000000192f81fd4 0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 200660

2 Foundation 0x0000000192f81eec 0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 200428

3 Foundation 0x0000000192f81b60 0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 199520

4 UIKitCore 0x00000001971388a0 82C949DD-37F6-35F7-B3EF-62BA342F6BF5 + 15181984

5 UIKitCore 0x00000001971392d8 82C949DD-37F6-35F7-B3EF-62BA342F6BF5 + 15184600

6 QuartzCore 0x00000001996255f8 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 1377784

7 QuartzCore 0x0000000199629e28 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 1396264

8 QuartzCore 0x0000000199635894 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 1443988

9 QuartzCore 0x000000019957e9f0 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 694768

10 QuartzCore 0x00000001995a8890 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 866448

11 QuartzCore 0x00000001995a9814 5A4A8F86-A37D-3290-AC6A-9C03140FA5D3 + 870420

12 libsystem_pthread.dylib 0x00000001929c0350 C3FA4F34-750F-362B-BEFE-835BFB15C0F8 + 58192

13 libsystem_pthread.dylib 0x00000001929bd248 C3FA4F34-750F-362B-BEFE-835BFB15C0F8 + 45640

14 libsystem_pthread.dylib 0x00000001929be29c C3FA4F34-750F-362B-BEFE-835BFB15C0F8 + 49820

15 libsystem_pthread.dylib 0x00000001929be034 _pthread_wqthread + 420

16 libsystem_pthread.dylib 0x00000001929c0ae0 start_wqthread + 8

)


I tried setting a symbolic breakpoint for [UIImageView setTintColor], but it doesn't get hit.

I found the issue. It was this code executed in a background thread:


self->bbi_sort.enabled = YES;


UIBarButtonItem *bbi_sort;


The Main Thread Checker didn't catch it and the crash backtrace was no help. And it only actually crashed in iOS 13.