From 4f8b90467ab687a47f9f5425729ccee83cc6c743 Mon Sep 17 00:00:00 2001 From: Vadzim Vysotski Date: Tue, 5 Mar 2024 17:51:44 +0100 Subject: [PATCH 1/3] added more logs to route parsing --- .../navigation/base/route/NavigationRoute.kt | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) 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..e51d5adcebb 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 for. 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 ${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 " + + "for ${it.firstOrNull()?.directionsResponse?.uuid()}" + } } } } From 32814558c5935f54eec986ac9c527e6370de8e2d Mon Sep 17 00:00:00 2001 From: Vadzim Vysotski Date: Tue, 5 Mar 2024 17:54:18 +0100 Subject: [PATCH 2/3] added more logs to parsing manager --- .../internal/utils/RoutesParsingManager.kt | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) 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" } } From 9367922e86eadaed8fabe54435c425e494655120 Mon Sep 17 00:00:00 2001 From: Vadzim Vysotski Date: Tue, 5 Mar 2024 18:11:20 +0100 Subject: [PATCH 3/3] adjusted parsing messages --- .../navigation/base/route/NavigationRoute.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 e51d5adcebb..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 @@ -206,26 +206,26 @@ class NavigationRoute internal constructor( ): List { val parsingId = UUID.randomUUID() logI(LOG_CATEGORY) { - "NavigationRoute.createAsync is called for. Parsing id $parsingId" + "NavigationRoute.createAsync is called. Parsing id $parsingId" } return coroutineScope { val deferredResponseParsing = async(ThreadController.DefaultDispatcher) { logI(LOG_CATEGORY) { - "started java parsing. Parsing id $parsingId" + "Started java parsing. Parsing id $parsingId" } directionsResponseJson.toDirectionsResponse().also { logI( LOG_CATEGORY ) { - "finished java parsing. " + + "Finished java parsing. " + "Parsing id $parsingId, response id ${it.uuid()}" } } } val deferredNativeParsing = async(ThreadController.DefaultDispatcher) { logI(LOG_CATEGORY) { - "started native parsing. Parsing id $parsingId" + "Started native parsing. Parsing id $parsingId" } routeParser.parseDirectionsResponse( directionsResponseJson, @@ -235,7 +235,7 @@ class NavigationRoute internal constructor( logI( LOG_CATEGORY ) { - "finished native parsing. Parsing id $parsingId, " + + "Finished native parsing. Parsing id $parsingId, " + "response id ${it.value?.firstOrNull()?.responseUuid}" } } @@ -247,7 +247,7 @@ class NavigationRoute internal constructor( RouteOptions.fromUrl(URL(routeRequestUrl)).also { logI(LOG_CATEGORY) { "finished RouteOptions parsing. Parsing id $parsingId," + - "result it ${it.toUrl("***")}" + "result ${it.toUrl("***")}" } } } @@ -261,8 +261,8 @@ class NavigationRoute internal constructor( logI( LOG_CATEGORY ) { - "NavigationRoute.createAsync finished. Parsing id $parsingId " + - "for ${it.firstOrNull()?.directionsResponse?.uuid()}" + "NavigationRoute.createAsync finished. Parsing id $parsingId, " + + "response id ${it.firstOrNull()?.directionsResponse?.uuid()}" } } }