From df7d2a57373a754a34c3e1548e6fa8fa58a113ca Mon Sep 17 00:00:00 2001 From: Max Wang Date: Wed, 28 Mar 2018 18:29:05 -0700 Subject: [PATCH] Disable interface coalescing (#862) * fix SIMULATE_WEB_RESPONSE not imported #449 * Fix to make rangeMode update in right time * disable interface coalescing and fix tests * Revert to before coalescing for ease of reading * refactor, make min change * refactor * add comments * Add change log --- CHANGELOG.md | 1 + Source/ASConfigurationInternal.m | 4 ++-- Source/ASDisplayNode.mm | 14 +++++++++++++- Tests/ASRunLoopQueueTests.m | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4597b64..5beec7c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- Disable interface colescing and match to pre-colescing interface update behavior [Max Wang](https://github.com/wsdwsd0829) [#862](https://github.com/TextureGroup/Texture/pull/862) - [ASDisplayNode] Add safeAreaInsets, layoutMargins and related properties to ASDisplayNode, with full support for older OS versions [Yevgen Pogribnyi](https://github.com/ypogribnyi) [#685](https://github.com/TextureGroup/Texture/pull/685) - [ASPINRemoteImageDownloader] Allow cache to provide animated image. [Max Wang](https://github.com/wsdwsd0829) [#850](https://github.com/TextureGroup/Texture/pull/850) - [tvOS] Fixes errors when building against tvOS SDK [Alex Hill](https://github.com/alexhillc) [#728](https://github.com/TextureGroup/Texture/pull/728) diff --git a/Source/ASConfigurationInternal.m b/Source/ASConfigurationInternal.m index db2ab9d54..a11e24229 100644 --- a/Source/ASConfigurationInternal.m +++ b/Source/ASConfigurationInternal.m @@ -37,8 +37,8 @@ + (CFTypeRef)sharedInstance + (ASConfiguration *)defaultConfiguration NS_RETURNS_RETAINED { ASConfiguration *config = [[ASConfiguration alloc] init]; - // On by default for now, pending fix for https://github.com/TextureGroup/Texture/issues/853 - config.experimentalFeatures = ASExperimentalInterfaceStateCoalescing; + // TODO(wsdwsd0829): Fix #788 before enabling it. + // config.experimentalFeatures = ASExperimentalInterfaceStateCoalescing; return config; } diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index adddc67df..f638960ee 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -57,6 +57,10 @@ #else #define TIME_SCOPED(outVar) #endif +// This is trying to merge non-rangeManaged with rangeManaged, so both range-managed and standalone nodes wait before firing their exit-visibility handlers, as UIViewController transitions now do rehosting at both start & end of animation. +// Enable this will mitigate interface updating state when coalescing disabled. +// TODO(wsdwsd0829): Rework enabling code to ensure that interface state behavior is not altered when ASCATransactionQueue is disabled. +#define ENABLE_NEW_EXIT_HIERARCHY_BEHAVIOR 0 static ASDisplayNodeNonFatalErrorBlock _nonFatalErrorBlock = nil; NSInteger const ASDefaultDrawingPriority = ASDefaultTransactionPriority; @@ -3005,6 +3009,13 @@ - (void)didExitHierarchy // same runloop. Strategy: strong reference (might be the last!), wait one runloop, and confirm we are still outside the hierarchy (both layer-backed and view-backed). // TODO: This approach could be optimized by only performing the dispatch for root elements + recursively apply the interface state change. This would require a closer // integration with _ASDisplayLayer to ensure that the superlayer pointer has been cleared by this stage (to check if we are root or not), or a different delegate call. + +#if !ENABLE_NEW_EXIT_HIERARCHY_BEHAVIOR + if (![self supportsRangeManagedInterfaceState]) { + self.interfaceState = ASInterfaceStateNone; + return; + } +#endif if (ASInterfaceStateIncludesVisible(_pendingInterfaceState)) { void(^exitVisibleInterfaceState)(void) = ^{ // This block intentionally retains self. @@ -3013,11 +3024,12 @@ - (void)didExitHierarchy BOOL isVisible = ASInterfaceStateIncludesVisible(_pendingInterfaceState); ASInterfaceState newState = (_pendingInterfaceState & ~ASInterfaceStateVisible); __instanceLock__.unlock(); - if (!isStillInHierarchy && isVisible) { +#if ENABLE_NEW_EXIT_HIERARCHY_BEHAVIOR if (![self supportsRangeManagedInterfaceState]) { newState = ASInterfaceStateNone; } +#endif self.interfaceState = newState; } }; diff --git a/Tests/ASRunLoopQueueTests.m b/Tests/ASRunLoopQueueTests.m index b195cbc4d..7889be9be 100644 --- a/Tests/ASRunLoopQueueTests.m +++ b/Tests/ASRunLoopQueueTests.m @@ -188,6 +188,10 @@ - (void)testASCATransactionQueueDisable - (void)testASCATransactionQueueProcess { + ASConfiguration *config = [[ASConfiguration alloc] initWithDictionary:nil]; + config.experimentalFeatures = ASExperimentalInterfaceStateCoalescing; + [ASConfigurationManager test_resetWithConfiguration:config]; + ASCATransactionQueue *queue = [[ASCATransactionQueue alloc] init]; QueueObject *object = [[QueueObject alloc] init]; [queue enqueue:object];