ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.84k stars 1.68k forks source link

YYTextAsyncLayer非主线程刷新 #904

Open zhengrush opened 4 years ago

zhengrush commented 4 years ago

项目中使用了YYLabel做图文混排,但是最近后台有捕获到非主线程操作UI的提示,堆栈信息如下:

ERROR: All calls to UIKit need to happen on the main thread. You have a bug in your code. Use dispatch_async(dispatch_get_main_queue(), ^{ ... }); if you're unsure what thread you're in. Break on PSPDFAssertIfNotMainThread to find out where. Stacktrace: ( 0 xxxxxxxxxxx 0x000000010349632c 7660332 PSPDFAssertIfNotMainThread (in xxxxxxxxxxx) (PSPDFUIKitMainThreadGuard.m:79) 1 xxxxxxxxxxx 0x00000001034963ac 7660460 __PSPDFUIKitMainThreadGuard_block_invoke_2 (in xxxxxxxxxxx) (PSPDFUIKitMainThreadGuard.m:100) 2 UIKitCore 0x0000000184f1cf58 3687CEEA-802A-37F0-B01C-9A936B6124EE + 14245720 3 UIKitCore 0x0000000184fe4568 3687CEEA-802A-37F0-B01C-9A936B6124EE + 15062376 4 xxxxxxxxxxx 0x0000000103869644 11671108 -[YYTextLayout drawInContext:size:point:view:layer:debug:cancel:] (in xxxxxxxxxxx) (YYTextLayout.m:0) 5 xxxxxxxxxxx 0x000000010384fef4 11566836 __30-[YYLabel newAsyncDisplayTask]_block_invoke.339 (in xxxxxxxxxxx) (YYLabel.m:1185) 6 xxxxxxxxxxx 0x00000001038526e8 11577064 -[YYTextAsyncLayer _displayAsync:] (in xxxxxxxxxxx) (YYTextAsyncLayer.m:226) 7 xxxxxxxxxxx 0x0000000103852180 11575680 -[YYTextAsyncLayer display] (in xxxxxxxxxxx) (YYTextAsyncLayer.m:115) 8 QuartzCore 0x00000001874f4470 5D2389C9-FC56-3789-AB36-898D07CC6AC5 + 1447024 9 QuartzCore 0x000000018743cedc 5D2389C9-FC56-3789-AB36-898D07CC6AC5 + 696028 10 QuartzCore 0x0000000187466e44 5D2389C9-FC56-3789-AB36-898D07CC6AC5 + 867908 11 QuartzCore 0x0000000187467838 5D2389C9-FC56-3789-AB36-898D07CC6AC5 + 870456 12 CoreFoundation 0x0000000180b004f8 6E8ED431-E507-3897-BF3A-AFD3D4C2C49F + 689400 13 CoreFoundation 0x0000000180afb3e4 6E8ED431-E507-3897-BF3A-AFD3D4C2C49F + 668644 14 CoreFoundation 0x0000000180afb18c CFRunLoopRunSpecific + 496 15 WebCore 0x0000000188988434 E901465C-333F-308E-B25B-E91608E5572B + 4109364 16 libsystem_pthread.dylib 0x00000001808a01f0 _pthread_start + 124 17 libsystem_pthread.dylib 0x00000001808a3af0 thread_start + 8 )

里面有显示[YYTextAsyncLayer display]是在非主线程调用,检查代码涉及到YYLabel的操作都没有在非主线程,这是被PSPDFUIKitMainThreadGuard误伤吗?