From 47a6fba71d067ef305ad9cbf0596d017aa88ab28 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 30 Nov 2026 09:07:56 +0100 Subject: [PATCH] fix(samples): Avoid an OOM at the end of a Nav3 performance run A run navigates every two frames, so the 350 ms route fade never finished and every outgoing Performance entry stayed composed until the run ended (51 after a Light A/B run). When the run ended, all of them recomposed into the full panel in the same frame, which exceeded the heap on a 48 MB device. Skip the route transitions while a run is active, which leaves 2 entries composed and no OOM. Co-Authored-By: Claude Opus 5.5 --- .../android/navigation/nav3/Nav3Activity.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sentry-android-integration-tests/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/nav3/Nav3Activity.kt b/sentry-android-integration-tests/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/nav3/Nav3Activity.kt index 807fedad09a..c46d161ce80 100644 --- a/sentry-android-integration-tests/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/nav3/Nav3Activity.kt +++ b/sentry-android-integration-tests/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/nav3/Nav3Activity.kt @@ -10,6 +10,9 @@ import android.util.Log import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.animation.ContentTransform +import androidx.compose.animation.EnterTransition +import androidx.compose.animation.ExitTransition import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut @@ -415,13 +418,9 @@ private fun Nav3SampleApp( } }, sceneStrategies = listOf(dialogSceneStrategy, bottomSheetSceneStrategy), - transitionSpec = { - fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)) - .togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))) - }, + transitionSpec = { nav3RouteTransition(animate = !performanceState.performanceRunActive) }, popTransitionSpec = { - fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)) - .togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))) + nav3RouteTransition(animate = !performanceState.performanceRunActive) }, entryProvider = entryProvider { @@ -620,4 +619,16 @@ private fun Nav3SampleApp( } private const val NAV3_TAG = "Nav3Activity" + +// Performance runs navigate every two frames, so fades never finish and every outgoing route stays +// composed; when the run ends, they all recompose into the full panel at once and run out of +// memory. +private fun nav3RouteTransition(animate: Boolean): ContentTransform = + if (animate) { + fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)) + .togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))) + } else { + ContentTransform(EnterTransition.None, ExitTransition.None, sizeTransform = null) + } + private const val COMPOSE_ROUTE_TRANSITION_MILLIS = 350