Skip to content

Commit 06388af

Browse files
pengdevnatiginfo
authored andcommitted
[compose] Avoid excessive debug logging on SourceState. (#5279)
Fixes https://mapbox.atlassian.net/browse/MAPSAND-2263 * [compose] Avoid excessive debug logging on SourceState, which can result in Out Of Memory in extreme cases. * Avoid appending geojson data in `GeoJsonSourceState.toString()` override. * Update per platform code owner for maps-stylegen. cc @mapbox/maps-android cc @mapbox/maps-ios cc @mapbox/sdk-ci --------- Co-authored-by: Natig Babayev <[email protected]> GitOrigin-RevId: 4243fcb3065fe6d40bedeffed9beab90291cf1af
1 parent eeccf6e commit 06388af

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ Mapbox welcomes participation and contributions from everyone.
44

55
# main
66

7-
## Dependencies
8-
* Update license to reflect license changes in underlying modules.
7+
8+
# 11.14.0
9+
## Bug fixes 🐞
10+
* [compose] Avoid excessive debug logging on SourceState, which can result in Out Of Memory in extreme cases. Avoid appending geojson data in `GeoJsonSourceState.toString()` override.
11+
912

1013
# 11.14.0-rc.1
1114
## Features ✨ and improvements 🏁

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/sources/SourceState.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public abstract class SourceState internal constructor(
114114
}
115115

116116
internal fun attachToLayer(layerId: String, mapboxMap: MapboxMap) {
117-
logD(TAG, "$this attachToLayer: layerId=$layerId")
117+
logD(TAG, "$sourceType - $sourceId attachToLayer: layerId=$layerId")
118118
this.mapboxMap?.let {
119119
if (it !== mapboxMap) {
120120
logW(TAG, "The source state should not be used across multiple map instances!")
@@ -128,7 +128,7 @@ public abstract class SourceState internal constructor(
128128
}
129129

130130
internal fun detachFromLayer(layerId: String, mapboxMap: MapboxMap) {
131-
logD(TAG, "$this detachFromLayer: layerId=$layerId")
131+
logD(TAG, "$sourceType $sourceId detachFromLayer: layerId=$layerId")
132132
associatedLayers.remove(layerId)
133133
if (associatedLayers.isEmpty() && !sourceAddedExternally) {
134134
detachFrom(mapboxMap)
@@ -149,7 +149,7 @@ public abstract class SourceState internal constructor(
149149
- the source was added outside of compose (e.g. MapEffect)
150150
- there was a previous SourceState with the same id already added
151151
*/
152-
logW(TAG, "Source [$this] already exists. This might lead to conflicting states.")
152+
logW(TAG, "Source [$sourceId] already exists. This might lead to conflicting states.")
153153
sourceAddedExternally = true
154154
true
155155
} else {
@@ -185,9 +185,9 @@ public abstract class SourceState internal constructor(
185185
* @return false if the source was already added or if it failed to be added.
186186
*/
187187
private fun addSource(mapboxMap: MapboxMap, cachedProperties: Map<String, Value>): Boolean {
188-
logD(TAG, "Adding source: $this")
188+
logD(TAG, "Adding source: $sourceType - $sourceId")
189189
if (mapboxMap.styleSourceExists(sourceId)) {
190-
logW(TAG, "Source already exists: $this")
190+
logW(TAG, "Source already exists: $sourceId")
191191
throw IllegalStateException("Source $sourceId already exists in map $mapboxMap")
192192
}
193193
// Merge the cachedProperties from gl-native with the ones we are aware of:
@@ -210,7 +210,7 @@ public abstract class SourceState internal constructor(
210210
false
211211
},
212212
{
213-
logD(TAG, "Added source: $this")
213+
logD(TAG, "Added source: $sourceType - $sourceId")
214214
if (isGeoJsonSource && geoJSONData != GeoJSONData.DEFAULT) {
215215
// Set the GeoJSON data after the source is added
216216
// Note that if the source was a pre-existing one outside of compose we will override it
@@ -320,7 +320,7 @@ public abstract class SourceState internal constructor(
320320
}
321321

322322
private fun removeSource(mapboxMap: MapboxMap) {
323-
logD(TAG, "Removing source: $this")
323+
logD(TAG, "Removing $sourceType source: $sourceId")
324324
mapboxMap.removeStyleSourceUnchecked(sourceId).onError {
325325
logE(TAG, "Failed to remove $sourceType Source $sourceId: $it")
326326
}

extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/sources/generated/GeoJsonSourceState.kt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)