-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ASTextKitComponents] Make sure Main Thread Checker isn't triggered during background calculations #trivial #612
[ASTextKitComponents] Make sure Main Thread Checker isn't triggered during background calculations #trivial #612
Conversation
… upsetting Main Thread Checker - Add a new thread-safe text view bounds. - Temporary components stack doesn't have a text view so it can be safely deallocated off main.
🚫 CI failed with log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
#import <tgmath.h> | ||
|
||
@interface ASTextKitComponentsTextView () | ||
@property (nonatomic, assign) CGRect threadSafeBounds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be atomic
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
…uring background calculations #trivial (TextureGroup#612) * Add unit test * Make sure TextKit components can calculate size in background without upsetting Main Thread Checker - Add a new thread-safe text view bounds. - Temporary components stack doesn't have a text view so it can be safely deallocated off main. * Add ASTextKitComponentsTextView * Remove unnecessary change * Fix minor mistake * ASTextKitComponentsTextView has only 1 initializer * Minor change * Switch to atomic property * Remove manual synthesization
Currently the checker is triggered either when the components need to get the backing text view's bounds, or when the text view's delegate is cleared out during deallocation.
In the first case, I add a new subclass of UITextView that has a thread-safe bounds property and is used exclusively by ASTextKitComponents.
The second case is handled in #598. However, a new main thread assertion added in #603 causes background deallocations of temporary components to fail. #610 attempts to fix that, but since temporary components don't have a reference to a text view, it's fine to avoid the assertion altogether.