Repository navigation
Conversation
asheemmamoowala
left a comment
There was a problem hiding this comment.
These changes do not address the scenario in testOpenGLLayerDoesNotLeakWhenStyleChanged. (It's possible the test is passing, but I believe the underlying issue is not addressed here).
When the style is changed with a call like [mapView setStyleURL:styleURL], the core layer is eventually cleaned up, but there will not be a corresponding call to [MGLStyle removeFromManagedLayers].
One possible way to capture this case is to handle the StyleObserver::OnStyleLoaded callback and check if any layer ids have been removed. To implement this, the NSMutableSet will need to be changed to an NSMutableDictionary so that the layer identifier does not have to be compared against the id in the core layer, which may already have been deleted.
|
|
||
| #pragma mark - Layer retain/release management | ||
|
|
||
| - (void)addToManagedLayers:(MGLStyleLayer*)layer { |
There was a problem hiding this comment.
This needs to be invoked from [MGLStyle layerFromMBGLLayer] as well, to capture internally created style layers.
| @property (nonatomic) NS_MUTABLE_DICTIONARY_OF(NSString *, NS_DICTIONARY_OF(NSObject *, MGLTextLanguage *) *) *localizedLayersByIdentifier; | ||
|
|
||
| // Used for retain/release management | ||
| @property (nonatomic) NSMutableSet *layersForUpdating; |
There was a problem hiding this comment.
Does the use of these properties remove the need for tracking the peer object in core for style layers? For layers created in the SDK, [MGLStlye layerFromMBGLLayer] could be used to lookup this set instead of querying core
…MGLOpenGLStyleLayers for the 2 trips through the render loop that are needed before they can be deallocated. Added additional tests.
|
The latest changes have evolved somewhat from the initial PR:
|
|
Closing in preference of #11553 |
(Obj-C) Layers are not retained at all by the SDK, but the C++ Layers can reach back to them (especially as custom layer contexts). I think there needs to be some mechanism that holds on to the Obj-C layers, regardless of what the client app does.
This PR adds a set (to
MGLStyle) to which these layers are added, purely to manage the retain counts. When rendering starts, this set is copied, so that their lifetime is guaranteed (and so those contexts was become garbage).(It's possible that the initial copy might need to move from rendering start to being triggered
Map::Impl::onUpdate())(This addresses #11143)