ARTiledImageView icon indicating copy to clipboard operation
ARTiledImageView copied to clipboard

UIKit work is done on the main thread

Open orta opened this issue 6 years ago • 2 comments

In Folio, which may have more things turned on - I get errors about doing UI work on a background thread. This could be the cause of some of our crashes. /cc @alloy

Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 67828, TID: 2321153, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057cde2b -[ARTiledImageView drawRect:] + 107
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13

2018-03-25 14:42:35.225523-0400 FolioDev[67828:2321153] [reports] Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 67828, TID: 2321153, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057cde2b -[ARTiledImageView drawRect:] + 107
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView bounds]
PID: 67828, TID: 2321098, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057ce3a8 -[ARTiledImageView drawRect:] + 1512
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13

orta avatar Mar 25 '18 18:03 orta

screen shot 2018-03-25 at 3 16 39 pm

Perhaps a later iOS allowed drawrect on a BG thread? Seems off to me

orta avatar Mar 25 '18 19:03 orta

Pretty sure that was never allowed, but looking at this stack trace it does appear to come out of legit call sites so kinda weird that it would invoke code on the wrong thread 🤔

alloy avatar Mar 26 '18 13:03 alloy