From 093ae3fba03103c78d0f1df917cf9f1f3a2008d2 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 2 Aug 2018 08:39:01 -0700 Subject: [PATCH] Remove CATransaction signposts because they cause more transactions than needed and are too chatty. (#1060) --- CHANGELOG.md | 1 + Source/ASRunLoopQueue.mm | 68 ---------------------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f87a289..2533928b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Source/ASRunLoopQueue.mm b/Source/ASRunLoopQueue.mm index 6f5c2232a..2cc4fc6b3 100644 --- a/Source/ASRunLoopQueue.mm +++ b/Source/ASRunLoopQueue.mm @@ -254,29 +254,6 @@ - (void)drain @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 @@ - (instancetype)init 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