Skip to content

Commit

Permalink
Revert - Assert node did load before did enter visible way 1 (Texture…
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestmama committed Nov 14, 2018
1 parent 88c3463 commit 45b179a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,4 @@



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
19 changes: 2 additions & 17 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2260,14 +2260,7 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode atSubnodeIndex:(NSInteger)subnod
[_subnodes insertObject:subnode atIndex:subnodeIndex];
_cachedSubnodes = nil;
__instanceLock__.unlock();

if (!isRasterized && self.nodeLoaded) {
// Trigger the subnode to load its layer, which will create its view if it needs one.
// By doing this prior to downward propagation of .interfaceState in _setSupernode:,
// we can guarantee that -didEnterVisibleState is only called with .isNodeLoaded = YES.
[subnode layer];
}


// This call will apply our .hierarchyState to the new subnode.
// If we are a managed hierarchy, as in ASCellNode trees, it will also apply our .interfaceState.
[subnode _setSupernode:self];
Expand Down Expand Up @@ -3280,19 +3273,11 @@ - (void)didEnterVisibleState
{
// subclass override
ASDisplayNodeAssertMainThread();

#if ASDISPLAYNODE_ASSERTIONS_ENABLED
// Rasterized node's loading state is merged with root node of rasterized tree.
if (!(self.hierarchyState & ASHierarchyStateRasterized)) {
ASDisplayNodeAssert(self.isNodeLoaded, @"Node should be loaded before entering visible state.");
}
#endif


ASAssertUnlocked(__instanceLock__);
[self enumerateInterfaceStateDelegates:^(id<ASInterfaceStateDelegate> del) {
[del didEnterVisibleState];
}];

#if AS_ENABLE_TIPS
[ASTipsController.shared nodeDidAppear:self];
#endif
Expand Down
1 change: 0 additions & 1 deletion Tests/ASNetworkImageNodeTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ - (void)DISABLED_testThatProgressBlockIsSetAndClearedCorrectlyOnVisibility

- (void)testThatProgressBlockIsSetAndClearedCorrectlyOnChangeURL
{
[node layer];
[node enterInterfaceState:ASInterfaceStateInHierarchy];

// Set URL while visible, should set progress block
Expand Down
12 changes: 5 additions & 7 deletions Tests/ASVideoNodeTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ - (void)testPlayerLayerNodeIsNotAddedIfVisibleButShouldNotBePlayingWithUrl
- (void)doPlayerLayerNodeIsNotAddedIfVisibleButShouldNotBePlaying
{
[_videoNode pause];
[_videoNode layer];
[_videoNode setInterfaceState:ASInterfaceStateVisible | ASInterfaceStateDisplay];

[_videoNode didLoad];

XCTAssert(![_videoNode.subnodes containsObject:_videoNode.playerNode]);
}

Expand All @@ -226,8 +226,7 @@ - (void)doVideoStartsPlayingOnDidDidBecomeVisibleWhenShouldAutoplay
return playerLayer;
}];
_videoNode.playerNode.layer.frame = CGRectZero;

[_videoNode layer];

[_videoNode didEnterVisibleState];

XCTAssertTrue(_videoNode.shouldBePlaying);
Expand Down Expand Up @@ -305,7 +304,7 @@ - (void)testVideoThatDoesNotAutorepeatsShouldPauseOnPlaybackEnd
_videoNode.asset = assetMock;
_videoNode.shouldAutorepeat = NO;

[_videoNode layer];
[_videoNode didLoad];
[_videoNode setInterfaceState:ASInterfaceStateVisible | ASInterfaceStateDisplay | ASInterfaceStatePreload];
[_videoNode prepareToPlayAsset:assetMock withKeys:_requestedKeys];
[_videoNode play];
Expand All @@ -326,7 +325,7 @@ - (void)testVideoThatAutorepeatsShouldRepeatOnPlaybackEnd
_videoNode.asset = assetMock;
_videoNode.shouldAutorepeat = YES;

[_videoNode layer];
[_videoNode didLoad];
[_videoNode setInterfaceState:ASInterfaceStateVisible | ASInterfaceStateDisplay | ASInterfaceStatePreload];
[_videoNode prepareToPlayAsset:assetMock withKeys:_requestedKeys];
[_videoNode play];
Expand All @@ -343,7 +342,6 @@ - (void)testVideoResumedWhenBufferIsLikelyToKeepUp

_videoNode.asset = assetMock;

[_videoNode layer];
[_videoNode setInterfaceState:ASInterfaceStateVisible | ASInterfaceStateDisplay | ASInterfaceStatePreload];
[_videoNode prepareToPlayAsset:assetMock withKeys:_requestedKeys];
ASCATransactionQueueWait(nil);
Expand Down

0 comments on commit 45b179a

Please sign in to comment.