Skip to content

Conversation

Copy link

Copilot AI commented Oct 30, 2025

App crashes with NoSuchElementException during navigateUp() show New Relic in the stacktrace, obscuring that the root cause is the app's navigation state management.

Changes

  • Wrap navigateUp() in try-catch-finally: Capture runtime exceptions while ensuring breadcrumbs are always recorded
  • Add exception metadata to breadcrumbs: Record exception class name and message when navigation fails, improving observability
  • Preserve exception propagation: Re-throw exceptions to maintain transparent instrumentation behavior
@ReplaceCallSite
static public boolean navigateUp(NavController navController) {
    boolean rc = false;
    RuntimeException exception = null;
    
    try {
        rc = navController.navigateUp();
    } catch (RuntimeException e) {
        exception = e;
        throw e;
    } finally {
        final boolean result = rc;
        final RuntimeException finalException = exception;
        submit(requiredFeatures, () -> {
            Map<String, Object> attrs = new HashMap<String, Object>() {{
                put("span", "navigateUp");
                put("result", result);
                if (finalException != null) {
                    put("exception", finalException.getClass().getName());
                    put("exceptionMessage", finalException.getMessage());
                }
            }};
            analyticsController.recordBreadcrumb("Compose", attrs);
        });
    }
    
    return rc;
}

The instrumentation remains transparent—exceptions still propagate to the app—but developers now see exception details in breadcrumbs for debugging.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -XX:&#43;HeapDumpOnOutOfMemoryError --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xms1024m -Xmx8192m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.6-bin/9l9tetv7ltxvx3i8an4pb86ye/gradle-7.6/lib/gradle-launcher-7.6.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.6 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>App crashes with a stacktrace from NR component/action "com.newrelic.agent.android.instrumentation.androidx.navigation.NavigationController.navigateUp"</issue_title>
<issue_description>## Description

We got a reported crash on both Crashlytics & NR regarding the navigation logic with stacktrace from NR component/action com.newrelic.agent.android.instrumentation.androidx.navigation.NavigationController.navigateUp.

Steps to Reproduce

N/A

Expected Behavior

No crash related to NR.

Relevant Logs / Console output

          Fatal Exception: java.util.NoSuchElementException: List is empty.
       at kotlin.collections.CollectionsKt__MutableCollectionsKt.removeLast(MutableCollections.kt:257)
       at androidx.navigation.NavController.tryRelaunchUpToExplicitStack(NavController.kt:881)
       at androidx.navigation.NavController.navigateUp(NavController.kt:854)
       at com.newrelic.agent.android.instrumentation.androidx.navigation.NavigationController.navigateUp(NavigationController.java)
       at com.cbtl.nexus.navigation.AppNavigationKt$navigate$1.invoke(AppNavigation.kt:204)
       at com.cbtl.nexus.navigation.AppNavigationKt$navigate$1.invoke(AppNavigation.kt)
       at com.cbtl.nexus.navigation.AppNavigationKt.throttleNavigation(AppNavigation.kt:249)
       at com.cbtl.nexus.navigation.AppNavigationKt.navigate(AppNavigation.kt:198)
       at com.cbtl.nexus.navigation.AppNavigationKt.navigate$default(AppNavigation.kt:195)
       at com.cbtl.nexus.navigation.extensions.NavigationExtKt.navigateAppDestinationUp(NavigationExt.kt:185)
       at com.cbtl.nexus.navigation.navgraphs.MainNavGraphKt$mainNavGraph$1$14$2.invoke(MainNavGraph.kt:718)
       at com.cbtl.nexus.navigation.navgraphs.MainNavGraphKt$mainNavGraph$1$14$2.invoke(MainNavGraph.kt)
       at androidx.compose.foundation.ClickableNode$clickPointerInput$3.invoke-k-4lQ0M(Clickable.kt:639)
       at androidx.compose.foundation.ClickableNode$clickPointerInput$3.invoke(Clickable.kt:633)
       at androidx.compose.foundation.gestures.TapGestureDetectorKt$detectTapAndPress$2$1.invokeSuspend(TapGestureDetector.kt:255)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:165)
       at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:154)
       at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core(CancellableContinuationImpl.kt:504)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$kotlinx_coroutines_core$default(CancellableContinuationImpl.kt:493)
       at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:359)
       at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:719)
       at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:598)
       at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:620)
       at androidx.compose.foundation.AbstractClickableNode.onPointerEvent-H0pRuoY(Clickable.kt:1044)
       at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:387)
       at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:373)
       at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:373)
       at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:229)
       at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:144)
       at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:120)
       at androidx.compose.ui.platform.AndroidComposeView.sendMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1999)
       at androidx.compose.ui.platform.AndroidComposeView.handleMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1950)
       at androidx.compose.ui.platform.AndroidComposeView.dispatchTouchEvent(AndroidComposeView.android.kt:1834)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3923)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:3597)
       at android.view.ViewGr...

</details>

- Fixes newrelic/newrelic-android-agent#319

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Copilot AI changed the title [WIP] Fix app crash from navigation logic Capture exception details in NavigationController breadcrumbs Oct 30, 2025
Copilot AI requested a review from ndesai-newrelic October 30, 2025 15:43
Copilot finished work on behalf of ndesai-newrelic October 30, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants