fix LabelLayout async init used UILabel().#173
fix LabelLayout async init used UILabel().#173ghmake1y wants to merge 1 commit intoLinkedInAttic:masterfrom ghmake1y:master
Conversation
|
@ghmake1y Thanks for your PR. Could you elaborate why |
|
@ghmake1y Does the test you added fail without your change? |
|
@nicksnyder Yes,the test function named 'testAsyncAttributedLabel' is failed if i don't change default font. |
|
@jingwei-huang1 You can see code of function testAsyncAttributedLabel in LabelLayoutTests.swit.If async call UILabel() will be crashed,it will be trigger Main Thread Checker: UI API called on a background. |
|
@jingwei-huang1 UILabel() is not safe because LayoutKit can call it in background queue. When use LabelLayout in ReloadableViewLayoutAdapter, I saw Xcode complaint
You can reproduce this issue by running the LayoutKitSampleApp and open the "FeedCollectionViewController" example. |
|
If using system font is not ideal, maybe we can replace it with |
If we initialize the LabelLayout asynchronously with an NSAttributedString, most of the time we don't have to set the font, but the default access to UILabel(). Font, this is not safe.I don't quite understand why this is designed in this way.