diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/utils/RoutesParsingManager.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/utils/RoutesParsingManager.kt index 969671da297..5073af9e6b3 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/utils/RoutesParsingManager.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/utils/RoutesParsingManager.kt @@ -4,7 +4,7 @@ package com.mapbox.navigation.base.internal.utils import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI import com.mapbox.navigation.base.options.LongRoutesOptimisationOptions -import com.mapbox.navigation.utils.internal.logD +import com.mapbox.navigation.utils.internal.logI import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import java.nio.ByteBuffer @@ -59,12 +59,18 @@ private class OptimisedRoutesParsingManager( parsing: suspend (ParseArguments) -> T ): T { return if (routeResponseInfo.sizeBytes < options.responseToParseSizeBytes) { - parsing(ParseArguments(optimiseDirectionsResponseStructure = true)) + logI(LOG_TAG) { "Starting parsing" } + parsing(ParseArguments(optimiseDirectionsResponseStructure = true)).also { + logI(LOG_TAG) { "Finished parsing" } + } } else { - logD(LOG_TAG) { "Enqueuing routes parsing" } + logI(LOG_TAG) { "Enqueuing routes parsing" } mutex.withLock { prepareForParsing() - parsing(ParseArguments(optimiseDirectionsResponseStructure = true)) + logI(LOG_TAG) { "Starting parsing" } + parsing(ParseArguments(optimiseDirectionsResponseStructure = true)).also { + logI(LOG_TAG) { "Finished parsing" } + } } } } @@ -74,10 +80,10 @@ private class OptimisedRoutesParsingManager( parsing: suspend (ParseArguments) -> T ): AlternativesParsingResult { return if (arguments.userTriggeredAlternativesRefresh) { - logD(LOG_TAG) { "skipping parsing of immediate route alternatives response" } + logI(LOG_TAG) { "skipping parsing of immediate route alternatives response" } AlternativesParsingResult.NotActual } else if (mutex.isLocked) { - logD(LOG_TAG) { + logI(LOG_TAG) { "skipping parsing of routes alternatives" + " as a different route is being parsed already" } @@ -93,11 +99,11 @@ private class OptimisedRoutesParsingManager( } private suspend fun prepareForParsing() { - logD(LOG_TAG) { + logI(LOG_TAG) { "Preparing for routes response parsing" } prepareForParsingAction() - logD(LOG_TAG) { + logI(LOG_TAG) { "Preparation for routes parsing completed" } } diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/route/NavigationRoute.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/route/NavigationRoute.kt index 7c7932cd45e..10956430f4f 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/route/NavigationRoute.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/route/NavigationRoute.kt @@ -26,7 +26,6 @@ import com.mapbox.navigation.base.internal.utils.refreshTtl import com.mapbox.navigation.base.trip.model.roadobject.UpcomingRoadObject import com.mapbox.navigation.utils.internal.ThreadController import com.mapbox.navigation.utils.internal.ifNonNull -import com.mapbox.navigation.utils.internal.logD import com.mapbox.navigation.utils.internal.logE import com.mapbox.navigation.utils.internal.logI import com.mapbox.navigator.RouteInterface @@ -36,6 +35,7 @@ import java.io.InputStream import java.io.InputStreamReader import java.net.URL import java.nio.ByteBuffer +import java.util.UUID /** * Wraps a route object used across the Navigation SDK features. @@ -204,34 +204,50 @@ class NavigationRoute internal constructor( routeParser: SDKRouteParser = SDKRouteParser.default, optimiseMemory: Boolean = false ): List { - logI("NavigationRoute.createAsync is called", LOG_CATEGORY) + val parsingId = UUID.randomUUID() + logI(LOG_CATEGORY) { + "NavigationRoute.createAsync is called. Parsing id $parsingId" + } return coroutineScope { val deferredResponseParsing = async(ThreadController.DefaultDispatcher) { + logI(LOG_CATEGORY) { + "Started java parsing. Parsing id $parsingId" + } directionsResponseJson.toDirectionsResponse().also { - logD( - "parsed directions response to java model for ${it.uuid()}", + logI( LOG_CATEGORY - ) + ) { + "Finished java parsing. " + + "Parsing id $parsingId, response id ${it.uuid()}" + } } } val deferredNativeParsing = async(ThreadController.DefaultDispatcher) { + logI(LOG_CATEGORY) { + "Started native parsing. Parsing id $parsingId" + } routeParser.parseDirectionsResponse( directionsResponseJson, routeRequestUrl, routerOrigin, ).also { - logD( - "parsed directions response to RouteInterface " + - "for ${it.value?.firstOrNull()?.responseUuid}", + logI( LOG_CATEGORY - ) + ) { + "Finished native parsing. Parsing id $parsingId, " + + "response id ${it.value?.firstOrNull()?.responseUuid}" + } } } val deferredRouteOptionsParsing = async(ThreadController.DefaultDispatcher) { + logI(LOG_CATEGORY) { + "started route options parsing. Parsing id $parsingId" + } RouteOptions.fromUrl(URL(routeRequestUrl)).also { - logD(LOG_CATEGORY) { - "parsed request url to RouteOptions: ${it.toUrl("***")}" + logI(LOG_CATEGORY) { + "finished RouteOptions parsing. Parsing id $parsingId," + + "result ${it.toUrl("***")}" } } } @@ -242,11 +258,12 @@ class NavigationRoute internal constructor( responseTimeElapsedSeconds, optimiseMemory ).also { - logD( - "NavigationRoute.createAsync finished " + - "for ${it.firstOrNull()?.directionsResponse?.uuid()}", + logI( LOG_CATEGORY - ) + ) { + "NavigationRoute.createAsync finished. Parsing id $parsingId, " + + "response id ${it.firstOrNull()?.directionsResponse?.uuid()}" + } } } }