This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Adds tests and potential fixes for #10771 and #11143 #11291
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48918fa
Adds failing tests for #10771 and #11143
e4aaaa3
[ios] Potential fix for over retain/release issues with adding layers…
2a4d13b
[ios] Release only called if the layer is really being removed from t…
47e6a03
[ios] Add explicit dependency for integration tests (for CI)
fafedb6
[ios] Adding a few more test cases. testOpenGLLayerDoesNotLeakWhenSty…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ - (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { | |
- (void)tearDown { | ||
_styleLoadingExpectation = nil; | ||
self.mapView = nil; | ||
self.style = nil; | ||
|
||
[super tearDown]; | ||
} | ||
|
@@ -53,25 +54,68 @@ - (MGLStyle *)style { | |
- (void)testAddingRemovingOpenGLLayer { | ||
XCTAssertNotNil(self.style); | ||
|
||
void(^addRemoveGLLayer)(void) = ^{ | ||
MGLOpenGLStyleLayer *layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"]; | ||
[self.style insertLayer:layer atIndex:0]; | ||
layer = nil; | ||
// Test fails with 0.1 (presumably because it's < one frame, ie. 1/60) | ||
NSTimeInterval waitInterval = 0.02; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; | ||
void(^addRemoveGLLayer)(void) = ^{ | ||
|
||
id retrievedLayer = [self.style layerWithIdentifier:@"gl-layer"]; | ||
XCTAssertNotNil(retrievedLayer); | ||
[self.style removeLayer:retrievedLayer]; | ||
MGLOpenGLStyleLayer *layer = nil; | ||
__weak id retrievedLayer = nil; | ||
|
||
@autoreleasepool { | ||
layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"]; | ||
[self.style insertLayer:layer atIndex:0]; | ||
layer = nil; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
|
||
retrievedLayer = [self.style layerWithIdentifier:@"gl-layer"]; | ||
XCTAssertNotNil(retrievedLayer); | ||
[self.style removeLayer:retrievedLayer]; | ||
|
||
// We need to run the runloop for a little while so that the following assert will be correct | ||
// this is because although the layer has been removed from the style, there's still a pending | ||
// render (deinitialize) call, that will needs to be handled, which will finally release the | ||
// layer (and then the layer will be dealloc'd when the autorelease pool drains) | ||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we expect the layer to be released as of the next render, how about putting in an expectation that gets satisfied upon the next call to |
||
} | ||
|
||
XCTAssertNil(retrievedLayer); | ||
}; | ||
|
||
addRemoveGLLayer(); | ||
addRemoveGLLayer(); | ||
addRemoveGLLayer(); | ||
} | ||
|
||
//- (void)testOpenGLLayerDoesNotLeakWhenCreatedAndDestroyedWithoutAddingToStyle { | ||
// XCTFail(@"Not yet implemented"); | ||
//} | ||
- (void)testReusingOpenGLLayer { | ||
NSTimeInterval waitInterval = 0.02; | ||
|
||
MGLOpenGLStyleLayer *layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"]; | ||
[self.style insertLayer:layer atIndex:0]; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
|
||
[self.style removeLayer:layer]; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
|
||
[self.style insertLayer:layer atIndex:0]; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
|
||
[self.style removeLayer:layer]; | ||
|
||
[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:waitInterval]]; | ||
} | ||
|
||
// This test does not strictly need to be in this test file/target. Including here for convenience. | ||
- (void)testOpenGLLayerDoesNotLeakWhenCreatedAndDestroyedWithoutAddingToStyle { | ||
MGLOpenGLStyleLayer *layer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"gl-layer"]; | ||
__weak id weakLayer = layer; | ||
layer = nil; | ||
|
||
XCTAssertNil(weakLayer); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm wondering - is this guaranteed to happen, always? Or do we need more of a dance to ensure this is released if the whole style is destroyed without an explicit call to
-removeFromStyle:
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so, when the style gets cleaned up. But we should add a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that - I think we need some more clean-up.