nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

[Bug]: Navigation trace label can be too long, leading to a crash while tracing

Open alexvanyo opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is there a StackOverflow question about this issue?

  • [X] I have searched StackOverflow

What happened?

The trace call for the navigate function uses the toString representation of the destination, which can exceed the 127 character limit for the trace label.

This leads to a crash when navigating while tracing.

Relevant logcat output

2022-09-08 09:04:07.224 27645-27645 AndroidRuntime          com...s.nowinandroid.demo.benchmark  E  FATAL EXCEPTION: main
                                                                                                    Process: com.google.samples.apps.nowinandroid.demo.benchmark, PID: 27645
                                                                                                    java.lang.IllegalArgumentException: sectionName is too long
                                                                                                    	at android.os.Trace.beginSection(Trace.java:287)
                                                                                                    	at androidx.tracing.TraceApi18Impl.beginSection(TraceApi18Impl.java:49)
                                                                                                    	at androidx.tracing.Trace.beginSection(Trace.java:129)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppState.navigate(NiaAppState.kt:160)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppState.navigate$default(NiaAppState.kt:113)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppKt$NiaApp$1$1$3$1$1.invoke(NiaApp.kt:98)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppKt$NiaApp$1$1$3$1$1.invoke(NiaApp.kt:98)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppKt$NiaNavRail$1$1$1.invoke(NiaApp.kt:131)
                                                                                                    	at com.google.samples.apps.nowinandroid.ui.NiaAppKt$NiaNavRail$1$1$1.invoke(NiaApp.kt:129)
                                                                                                    	at androidx.compose.foundation.ClickableKt$clickable$4$gesture$1$1$2.invoke-k-4lQ0M(Clickable.kt:167)

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

alexvanyo avatar Sep 08 '22 16:09 alexvanyo