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

NAVAND-1842 more logs #7772

Draft
wants to merge 3 commits into
base: release-v2.17
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
}
}
}
}
Expand All @@ -74,10 +80,10 @@ private class OptimisedRoutesParsingManager(
parsing: suspend (ParseArguments) -> T
): AlternativesParsingResult<T> {
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"
}
Expand All @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -204,34 +204,50 @@ class NavigationRoute internal constructor(
routeParser: SDKRouteParser = SDKRouteParser.default,
optimiseMemory: Boolean = false
): List<NavigationRoute> {
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("***")}"
}
}
}
Expand All @@ -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()}"
}
}
}
}
Expand Down