Skip to content

Commit

Permalink
Disable interface coalescing (TextureGroup#862)
Browse files Browse the repository at this point in the history
* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#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
  • Loading branch information
wsdwsd0829 authored and bernieperez committed Apr 25, 2018
1 parent 5071f11 commit f8dbec1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Source/ASConfigurationInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 13 additions & 1 deletion Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}
};
Expand Down
4 changes: 4 additions & 0 deletions Tests/ASRunLoopQueueTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit f8dbec1

Please sign in to comment.