Skip to content

Commit 0b0196d

Browse files
0xadam-browncodex
andcommitted
fix(samples): Correct Nav3 measurement state
Restore the idle state after warm-up and keep integration-mode recompositions out of extractor and processed-call counters until real navigation work begins. Refs GH-6222 Co-Authored-By: Codex <noreply@openai.com>
1 parent 0bb37f1 commit 0b0196d

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/nav3/Nav3PerformanceControls.kt‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ internal class Nav3PerformanceState(
106106
private var abComparisonCount = 0
107107
private var collectMeasurements = true
108108
private var discardNextSentryNavEffectMeasurement = false
109+
private var suppressExtractorMeasurementsUntilNavigation = false
109110
private var suppressNextDestinationChange = false
110111
private var pendingProcessedNavigationWork = false
111112

@@ -121,6 +122,7 @@ internal class Nav3PerformanceState(
121122
sentryNavEffectAttempts = 0
122123
sentryNavEffectProcessedCalls = 0
123124
capturedEntriesResolved = 0
125+
pendingProcessedNavigationWork = false
124126
mutationToCompositionDurations.clear()
125127
mutationToFirstDrawDurations.clear()
126128
comparisonResult = null
@@ -149,7 +151,7 @@ internal class Nav3PerformanceState(
149151

150152
fun markNavigationMutation() {
151153
navigationMutations++
152-
pendingProcessedNavigationWork = true
154+
markNavigationWorkPending()
153155
if (!performanceRunActive) {
154156
displayRevision++
155157
}
@@ -161,15 +163,15 @@ internal class Nav3PerformanceState(
161163
return
162164
}
163165
destinationChanges++
164-
pendingProcessedNavigationWork = true
166+
markNavigationWorkPending()
165167
if (!performanceRunActive) {
166168
displayRevision++
167169
}
168170
}
169171

170172
fun markPerformanceDestinationChange() {
171173
destinationChanges++
172-
pendingProcessedNavigationWork = true
174+
markNavigationWorkPending()
173175
}
174176

175177
fun suppressNextDestinationChange() {
@@ -179,6 +181,8 @@ internal class Nav3PerformanceState(
179181
fun updateIntegrationMode(mode: Nav3PerformanceIntegrationMode) {
180182
if (integrationMode != mode) {
181183
discardNextSentryNavEffectMeasurement = true
184+
suppressExtractorMeasurementsUntilNavigation = true
185+
pendingProcessedNavigationWork = false
182186
integrationMode = mode
183187
}
184188
}
@@ -240,6 +244,7 @@ internal class Nav3PerformanceState(
240244
) {
241245
if (discardNextSentryNavEffectMeasurement) {
242246
discardNextSentryNavEffectMeasurement = false
247+
pendingProcessedNavigationWork = false
243248
return
244249
}
245250
if (!collectMeasurements) {
@@ -283,8 +288,7 @@ internal class Nav3PerformanceState(
283288

284289
fun finishWarmUp() {
285290
resetCounters()
286-
performanceRunActive = true
287-
performanceStatus = "Warm-up complete"
291+
cancelPerformanceRun(status = "Warm-up complete")
288292
}
289293

290294
fun finishPerformanceRun(result: String? = null) {
@@ -405,7 +409,7 @@ internal class Nav3PerformanceState(
405409
return block()
406410
} finally {
407411
Trace.endSection()
408-
if (collectMeasurements && !discardNextSentryNavEffectMeasurement) {
412+
if (collectMeasurements && !suppressExtractorMeasurementsUntilNavigation) {
409413
nameExtractorCalls++
410414
nameExtractorNanos += System.nanoTime() - startedAt
411415
}
@@ -422,12 +426,17 @@ internal class Nav3PerformanceState(
422426
return block()
423427
} finally {
424428
Trace.endSection()
425-
if (collectMeasurements && !discardNextSentryNavEffectMeasurement) {
429+
if (collectMeasurements && !suppressExtractorMeasurementsUntilNavigation) {
426430
argumentsExtractorCalls++
427431
argumentsExtractorNanos += System.nanoTime() - startedAt
428432
}
429433
}
430434
}
435+
436+
private fun markNavigationWorkPending() {
437+
suppressExtractorMeasurementsUntilNavigation = false
438+
pendingProcessedNavigationWork = true
439+
}
431440
}
432441

433442
private data class PendingNav3PerformanceOperation(

0 commit comments

Comments
 (0)