mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-09 15:51:05 +00:00
Remove CATransaction signposts because they cause more transactions than needed and are too chatty. (#1060)
This commit is contained in:
parent
78be342e77
commit
093ae3fba0
@ -26,6 +26,7 @@
|
||||
- Reduced binary size by disabling exception support (which we don't use.) [Adlai Holler](https://github.com/Adlai-Holler)
|
||||
- Create and set delegate for clip corner layers within ASDisplayNode [Michael Schneider](https://github.com/maicki) [#1029](https://github.com/TextureGroup/Texture/pull/1029)
|
||||
- Improve locking situation in ASVideoPlayerNode [Michael Schneider](https://github.com/maicki) [#1042](https://github.com/TextureGroup/Texture/pull/1042)
|
||||
- Remove CA transaction signpost injection because it causes more transactions and is too chatty. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||
|
||||
|
||||
## 2.7
|
||||
|
||||
@ -254,29 +254,6 @@ static void runLoopSourceCallback(void *info) {
|
||||
|
||||
@end
|
||||
|
||||
#if AS_KDEBUG_ENABLE
|
||||
/**
|
||||
* This is real, private CA API. Valid as of iOS 10.
|
||||
*/
|
||||
typedef enum {
|
||||
kCATransactionPhasePreLayout,
|
||||
kCATransactionPhasePreCommit,
|
||||
kCATransactionPhasePostCommit,
|
||||
} CATransactionPhase;
|
||||
|
||||
@interface CATransaction (Private)
|
||||
+ (void)addCommitHandler:(void(^)(void))block forPhase:(CATransactionPhase)phase;
|
||||
+ (int)currentState;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#pragma mark - ASAbstractRunLoopQueue
|
||||
|
||||
@interface ASAbstractRunLoopQueue (Private)
|
||||
+ (void)load;
|
||||
+ (void)registerCATransactionObservers;
|
||||
@end
|
||||
|
||||
@implementation ASAbstractRunLoopQueue
|
||||
|
||||
- (instancetype)init
|
||||
@ -289,51 +266,6 @@ typedef enum {
|
||||
return self;
|
||||
}
|
||||
|
||||
#if AS_KDEBUG_ENABLE
|
||||
+ (void)load
|
||||
{
|
||||
[self registerCATransactionObservers];
|
||||
}
|
||||
|
||||
+ (void)registerCATransactionObservers
|
||||
{
|
||||
static BOOL privateCAMethodsExist;
|
||||
static dispatch_block_t preLayoutHandler;
|
||||
static dispatch_block_t preCommitHandler;
|
||||
static dispatch_block_t postCommitHandler;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
privateCAMethodsExist = [CATransaction respondsToSelector:@selector(addCommitHandler:forPhase:)];
|
||||
privateCAMethodsExist &= [CATransaction respondsToSelector:@selector(currentState)];
|
||||
if (!privateCAMethodsExist) {
|
||||
NSLog(@"Private CA methods are gone.");
|
||||
}
|
||||
preLayoutHandler = ^{
|
||||
ASSignpostStartCustom(ASSignpostCATransactionLayout, 0, [CATransaction currentState]);
|
||||
};
|
||||
preCommitHandler = ^{
|
||||
int state = [CATransaction currentState];
|
||||
ASSignpostEndCustom(ASSignpostCATransactionLayout, 0, state, ASSignpostColorDefault);
|
||||
ASSignpostStartCustom(ASSignpostCATransactionCommit, 0, state);
|
||||
};
|
||||
postCommitHandler = ^{
|
||||
ASSignpostEndCustom(ASSignpostCATransactionCommit, 0, [CATransaction currentState], ASSignpostColorDefault);
|
||||
// Can't add new observers inside an observer. rdar://problem/31253952
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self registerCATransactionObservers];
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
if (privateCAMethodsExist) {
|
||||
[CATransaction addCommitHandler:preLayoutHandler forPhase:kCATransactionPhasePreLayout];
|
||||
[CATransaction addCommitHandler:preCommitHandler forPhase:kCATransactionPhasePreCommit];
|
||||
[CATransaction addCommitHandler:postCommitHandler forPhase:kCATransactionPhasePostCommit];
|
||||
}
|
||||
}
|
||||
|
||||
#endif // AS_KDEBUG_ENABLE
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - ASRunLoopQueue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user