Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add experimental route line logs #7153

Draft
wants to merge 2 commits into
base: release-v2.13
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/artifact-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ext {
mapboxArtifactLicenseUrl = 'https://www.mapbox.com/legal/tos/'
snapshot = project.hasProperty("snapshot") ? project.property("snapshot").toBoolean() : false
releaseTagPrefix = project.hasProperty('RELEASE_TAG_PREFIX') ? project.property('RELEASE_TAG_PREFIX') : 'v'
versionName = getVersionName()
versionName = '2.13.0-route-line-3-SNAPSHOT'
}

def getVersionName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import com.mapbox.navigation.ui.maps.util.CacheResultUtils.cacheResult
import com.mapbox.navigation.ui.utils.internal.ifNonNull
import com.mapbox.navigation.utils.internal.InternalJobControlFactory
import com.mapbox.navigation.utils.internal.logE
import com.mapbox.navigation.utils.internal.logI
import com.mapbox.navigation.utils.internal.logW
import com.mapbox.navigation.utils.internal.parallelMap
import kotlinx.coroutines.Deferred
Expand Down Expand Up @@ -254,6 +255,8 @@ class MapboxRouteLineApi(
trafficBackfillRoadClasses.addAll(
routeLineOptions.resourceProvider.trafficBackfillRoadClasses
)
logI("BelowLayerId: ${routeLineOptions.routeLineBelowLayerId}", LOG_CATEGORY)
logI("All options: $routeLineOptions", LOG_CATEGORY)
}

/**
Expand Down Expand Up @@ -663,9 +666,11 @@ class MapboxRouteLineApi(
lastLocationPoint = null
routeLineOptions.vanishingRouteLine?.vanishPointOffset = 0.0
activeLegIndex = INVALID_ACTIVE_LEG_INDEX
logI("Updated leg index to $activeLegIndex (from clearRouteLine)", LOG_CATEGORY)
routes.clear()
routeFeatureData.clear()
routeLineExpressionData = emptyList()
logI("Cleared route line expression data (from clearRouteLine)", LOG_CATEGORY)
resetCaches()

consumer.accept(
Expand Down Expand Up @@ -823,6 +828,12 @@ class MapboxRouteLineApi(
routeProgressUpdatesQueue.addJob(
CoalescingBlockingQueue.Item(
{
logI(
"Update with route progress. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}",
LOG_CATEGORY
)
val currentPrimaryRoute = primaryRoute
if (currentPrimaryRoute == null) {
val msg =
Expand All @@ -845,6 +856,12 @@ class MapboxRouteLineApi(
updateVanishingPointState(routeProgress.currentState)

val currentLegIndex = routeProgress.currentLegProgress?.legIndex
logI(
"Calculate routeLineMaskingLayerDynamicData. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}, activeLegIndex: $activeLegIndex",
LOG_CATEGORY
)
val routeLineMaskingLayerDynamicData =
when ((currentLegIndex ?: INVALID_ACTIVE_LEG_INDEX) != activeLegIndex) {
true -> getRouteLineDynamicDataForMaskingLayers(
Expand All @@ -855,6 +872,7 @@ class MapboxRouteLineApi(
}
val legChange = (currentLegIndex ?: 0) > activeLegIndex
activeLegIndex = currentLegIndex ?: INVALID_ACTIVE_LEG_INDEX
logI("Update leg index to $activeLegIndex (from route progress update)", LOG_CATEGORY)

// If the de-emphasize inactive route legs feature is enabled and the vanishing route line
// feature is enabled and the active leg index has changed, then calling the
Expand Down Expand Up @@ -1005,6 +1023,8 @@ class MapboxRouteLineApi(
routeLineOptions.resourceProvider.routeLineColorResources,
restrictedExpressionData
)
logI("Masking layer main exp: $mainExp", LOG_CATEGORY)
logI("Masking layer traffic exp: $trafficExp", LOG_CATEGORY)

return RouteLineDynamicData(
{ mainExp },
Expand Down Expand Up @@ -1036,6 +1056,11 @@ class MapboxRouteLineApi(
return ifNonNull(route, routeProgress.currentLegProgress) { navRoute, currentLegProgress ->
val numLegs = navRoute.directionsRoute.legs()?.size ?: 0
val legIndex = currentLegProgress.legIndex
logI(
"getRouteLineDynamicDataForMaskingLayers for legIndex: $legIndex, " +
"numLegs: $numLegs, data size: ${routeLineExpressionData.size}",
LOG_CATEGORY
)
if (numLegs > 1 && legIndex < numLegs) {
getRouteLineDynamicDataForMaskingLayers(routeLineExpressionData, legIndex)
} else {
Expand Down Expand Up @@ -1421,6 +1446,7 @@ class MapboxRouteLineApi(
primaryRoute = distinctNewRoutes.firstOrNull()
MapboxRouteLineUtils.trimRouteDataCacheToSize(size = distinctNewRoutes.size)
this.activeLegIndex = INVALID_ACTIVE_LEG_INDEX
logI("Updated activeLegIndex to $activeLegIndex (from setNewRouteData)", LOG_CATEGORY)

preWarmRouteCaches(
distinctNewRoutes,
Expand Down Expand Up @@ -1653,10 +1679,18 @@ class MapboxRouteLineApi(
when (legsCount > 1) {
true -> {
routeLineExpressionData = deferred.await()
logI(
"Inited route line expression data: ${routeLineExpressionData.size} sync",
LOG_CATEGORY
)
}
false -> {
jobControl.scope.launch(Dispatchers.Main) {
routeLineExpressionData = deferred.await()
logI(
"Inited route line expression data: ${routeLineExpressionData.size} async",
LOG_CATEGORY
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import com.mapbox.navigation.ui.maps.route.line.model.RouteLineUpdateValue
import com.mapbox.navigation.ui.maps.route.line.model.RouteSetValue
import com.mapbox.navigation.utils.internal.ifNonNull
import com.mapbox.navigation.utils.internal.logE
import com.mapbox.navigation.utils.internal.logI
import org.jetbrains.annotations.TestOnly

/**
Expand Down Expand Up @@ -169,6 +170,11 @@ class MapboxRouteLineView @VisibleForTesting internal constructor(
Pair(MapboxRouteLineUtils.layerGroup3SourceKey, RouteLineFeatureId(null))
)

init {
logI("BelowLayerId: ${options.routeLineBelowLayerId}", TAG)
logI("All options: $options", TAG)
}

@TestOnly
internal fun initPrimaryRouteLineLayerGroup(layerIds: Set<String>) {
primaryRouteLineLayerGroup = layerIds
Expand Down Expand Up @@ -244,6 +250,10 @@ class MapboxRouteLineView @VisibleForTesting internal constructor(
callback: RoutesRenderedCallbackWrapper?
) {
rebuildSourcesAndLayersIfNeeded(style)
logI("Layers size: ${style.styleLayers.size}", TAG)
style.styleLayers.forEach {
logI("${it.id} properties: ${style.getStyleLayerProperties(it.id).value}", TAG)
}
val primaryRouteTrafficVisibility = getTrafficVisibility(style)
val primaryRouteVisibility = getPrimaryRouteVisibility(style)
val alternativeRouteVisibility = getAlternativeRoutesVisibility(style)
Expand Down Expand Up @@ -430,6 +440,11 @@ class MapboxRouteLineView @VisibleForTesting internal constructor(
.forEach { mutationCommand ->
mutationCommand()
}

logI("Layers moved. New order:", TAG)
style.styleLayers.forEach {
logI("After render ${it.id} properties: ${style.getStyleLayerProperties(it.id).value}", TAG)
}
}

private fun getRelatedSourceKey(
Expand Down Expand Up @@ -459,6 +474,7 @@ class MapboxRouteLineView @VisibleForTesting internal constructor(
}
}

val trafficProvider = it.routeLineMaskingLayerDynamicData?.trafficExpressionProvider
ifNonNull(it.routeLineMaskingLayerDynamicData) { overlayData ->
overlayData.restrictedSectionExpressionProvider?.apply {
getExpressionUpdateFun(MASKING_LAYER_RESTRICTED, this)(style)
Expand Down Expand Up @@ -490,9 +506,13 @@ class MapboxRouteLineView @VisibleForTesting internal constructor(
if (
overlayData.baseExpressionProvider !is RouteLineTrimExpressionProvider
) {
logI("Move layers up.", TAG)
getMaskingLayerMoveCommands(style).forEach { mutationCommand ->
mutationCommand()
}
style.styleLayers.forEach {
logI("Moved up ${it.id} properties: ${style.getStyleLayerProperties(it.id).value}", TAG)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,6 @@ class RouteLineColorResources private constructor(
.inActiveRouteLegsColor(inActiveRouteLegsColor)
}

/**
* Returns a string representation of the object.
*/
override fun toString(): String {
return "RouteLineColorResources(" +
"lowCongestionRange=$lowCongestionRange, " +
"heavyCongestionRange=$heavyCongestionRange, " +
"severeCongestionRange=$severeCongestionRange, " +
"moderateCongestionRange=$moderateCongestionRange, " +
"routeDefaultColor=$routeDefaultColor, " +
"routeLowCongestionColor=$routeLowCongestionColor, " +
"routeModerateCongestionColor=$routeModerateCongestionColor, " +
"routeHeavyCongestionColor=$routeHeavyCongestionColor, " +
"routeSevereCongestionColor=$routeSevereCongestionColor, " +
"routeUnknownCongestionColor=$routeUnknownCongestionColor, " +
"routeClosureColor=$routeClosureColor, " +
"restrictedRoadColor=$restrictedRoadColor, " +
"alternativeRouteDefaultColor=$alternativeRouteDefaultColor, " +
"alternativeRouteLowCongestionColor=$alternativeRouteLowCongestionColor, " +
"alternativeRouteModerateCongestionColor=$alternativeRouteModerateCongestionColor, " +
"alternativeRouteHeavyCongestionColor=$alternativeRouteHeavyCongestionColor, " +
"alternativeRouteSevereCongestionColor=$alternativeRouteSevereCongestionColor, " +
"alternativeRouteUnknownCongestionColor=$alternativeRouteUnknownCongestionColor, " +
"alternativeRouteRestrictedRoadColor=$alternativeRouteRestrictedRoadColor, " +
"alternativeRouteClosureColor=$alternativeRouteClosureColor, " +
"routeLineTraveledColor=$routeLineTraveledColor, " +
"routeLineTraveledCasingColor=$routeLineTraveledCasingColor, " +
"routeCasingColor=$routeCasingColor, " +
"alternativeRouteCasingColor=$alternativeRouteCasingColor, " +
"inActiveRouteLegsColor=$inActiveRouteLegsColor" +
")"
}

/**
* Returns a hash code value for the object.
*/
Expand Down Expand Up @@ -256,6 +223,36 @@ class RouteLineColorResources private constructor(
return true
}

override fun toString(): String {
return "RouteLineColorResources(" +
"lowCongestionRange=$lowCongestionRange, " +
"moderateCongestionRange=$moderateCongestionRange, " +
"heavyCongestionRange=$heavyCongestionRange, " +
"severeCongestionRange=$severeCongestionRange, " +
"routeDefaultColor=$routeDefaultColor, " +
"routeLowCongestionColor=$routeLowCongestionColor, " +
"routeModerateCongestionColor=$routeModerateCongestionColor, " +
"routeHeavyCongestionColor=$routeHeavyCongestionColor, " +
"routeSevereCongestionColor=$routeSevereCongestionColor, " +
"routeUnknownCongestionColor=$routeUnknownCongestionColor, " +
"alternativeRouteDefaultColor=$alternativeRouteDefaultColor, " +
"alternativeRouteLowCongestionColor=$alternativeRouteLowCongestionColor, " +
"alternativeRouteModerateCongestionColor=$alternativeRouteModerateCongestionColor, " +
"alternativeRouteHeavyCongestionColor=$alternativeRouteHeavyCongestionColor, " +
"alternativeRouteSevereCongestionColor=$alternativeRouteSevereCongestionColor, " +
"alternativeRouteUnknownCongestionColor=$alternativeRouteUnknownCongestionColor, " +
"restrictedRoadColor=$restrictedRoadColor, " +
"routeClosureColor=$routeClosureColor, " +
"alternativeRouteRestrictedRoadColor=$alternativeRouteRestrictedRoadColor, " +
"alternativeRouteClosureColor=$alternativeRouteClosureColor, " +
"routeLineTraveledColor=$routeLineTraveledColor, " +
"routeLineTraveledCasingColor=$routeLineTraveledCasingColor, " +
"routeCasingColor=$routeCasingColor, " +
"alternativeRouteCasingColor=$alternativeRouteCasingColor, " +
"inActiveRouteLegsColor=$inActiveRouteLegsColor" +
")"
}

/**
* A builder for instantiating the RouteLineResources class
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,6 @@ class RouteLineResources private constructor(
.restrictedRoadLineWidth(restrictedRoadLineWidth)
}

/**
* Returns a string representation of the object.
*/
override fun toString(): String {
return "RouteLineResources(" +
"routeLineColorResources=$routeLineColorResources, " +
"roundedLineCap=$roundedLineCap, " +
"originWaypointIcon=$originWaypointIcon, " +
"destinationWaypointIcon=$destinationWaypointIcon, " +
"routeLineScaleExpression=$routeLineScaleExpression, " +
"routeCasingLineScaleExpression=$routeCasingLineScaleExpression, " +
"routeTrafficLineScaleExpression=$routeTrafficLineScaleExpression, " +
"trafficBackfillRoadClasses=$trafficBackfillRoadClasses, " +
"alternativeRouteLineScaleExpression=$alternativeRouteLineScaleExpression, " +
"alternativeRouteCasingLineScaleExpression=" +
"$alternativeRouteCasingLineScaleExpression, " +
"alternativeRouteTrafficLineScaleExpression=" +
"$alternativeRouteTrafficLineScaleExpression, " +
"routeLineColorResources=$routeLineColorResources, " +
"roundedLineCap=$roundedLineCap, " +
"originWaypointIcon=$originWaypointIcon, " +
"destinationWaypointIcon=$destinationWaypointIcon, " +
"routeLineScaleExpression=$routeLineScaleExpression, " +
"routeCasingLineScaleExpression=$routeCasingLineScaleExpression, " +
"routeTrafficLineScaleExpression=$routeTrafficLineScaleExpression, " +
"trafficBackfillRoadClasses=$trafficBackfillRoadClasses, " +
"restrictedRoadDashArray=$restrictedRoadDashArray, " +
"restrictedRoadOpacity=$restrictedRoadOpacity, " +
"restrictedRoadLineWidth=$restrictedRoadLineWidth" +
")"
}

/**
* Indicates whether some other object is "equal to" this one.
*/
Expand Down Expand Up @@ -166,6 +134,27 @@ class RouteLineResources private constructor(
return result
}

override fun toString(): String {
return "RouteLineResources(" +
"routeLineColorResources=$routeLineColorResources, " +
"roundedLineCap=$roundedLineCap, " +
"originWaypointIcon=$originWaypointIcon, " +
"destinationWaypointIcon=$destinationWaypointIcon, " +
"trafficBackfillRoadClasses=$trafficBackfillRoadClasses, " +
"routeLineScaleExpression=$routeLineScaleExpression, " +
"routeCasingLineScaleExpression=$routeCasingLineScaleExpression, " +
"routeTrafficLineScaleExpression=$routeTrafficLineScaleExpression, " +
"alternativeRouteLineScaleExpression=$alternativeRouteLineScaleExpression, " +
"alternativeRouteCasingLineScaleExpression=" +
"$alternativeRouteCasingLineScaleExpression, " +
"alternativeRouteTrafficLineScaleExpression=" +
"$alternativeRouteTrafficLineScaleExpression, " +
"restrictedRoadDashArray=$restrictedRoadDashArray, " +
"restrictedRoadOpacity=$restrictedRoadOpacity, " +
"restrictedRoadLineWidth=$restrictedRoadLineWidth" +
")"
}

/**
* A builder for instantiating the RouteLineResources class
*/
Expand Down