Status Update
Comments
al...@google.com <al...@google.com> #2
Triage notes: If the app hasn't optimized out all the useful information (e.g. source information is stripped by R8) then we could construct a Composable "stack trace" by examining the slot table and dump that alongside the exception during recomposition -- and it's fine if this is expensive at the time of the crash. Andrei has looked at a similar issue. We'll need to discourage people from using this at runtime outside of an exception (@Discouraged
? restricted API?).
al...@google.com <al...@google.com> #3
This is important and feasible. Ben -- let's go through a design review if you want to pursue this, otherwise we'll push it onto the backlog for ~next quarter.
be...@google.com <be...@google.com> #4
Thanks Alan, I'll assign it to me for now and see how I go at least proving out the idea
be...@google.com <be...@google.com> #5
I have implemented a rough proof of concept and I think the idea definitely shows promise. I'm working with Andrei to get this into a proper design doc
aosp/3195995
be...@google.com <be...@google.com> #6
Noting down another example:
Unsupported concurrent change during composition. A state object was modified by composition as well as being modified outside composition.
be...@google.com <be...@google.com>
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
Author: Andrei Shikov <
Link:
Introduce Compose stack traces based on source information
Expand for full commit details
Introduce Compose stack traces based on source information
Appends a trace of @Composable functions retrieved from a slot table traversal as a suppressed exception on composition crash (coverage of other phases in the following commits).
The trace frames are based on the source information which has an associated performance cost. Enabling this feature might regress performance of the app.
Note that Compose also ships with a minifier config hat removes source information from the release builds. Enabling this feature in minified builds will have no effect.
Test: ComposeErrorTraceTests
Bug: 354163858
Relnote: """
Introduce diagnostic Compose stack traces based on source information stored in composition.
"""
Change-Id: I3db9fb976f61c768e2d1cf11d69019e4d0a08330
Files:
- M
compose/runtime/runtime-test-utils/src/commonMain/kotlin/androidx/compose/runtime/mock/CompositionTest.kt
- M
compose/runtime/runtime/api/current.txt
- M
compose/runtime/runtime/api/restricted_current.txt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/CompositionContext.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SlotTable.kt
- A
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/ComposeTrace.kt
- A
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/СomposeTraceBuilder.kt
- A
compose/runtime/runtime/src/jvmMain/kotlin/androidx/compose/runtime/tooling/DiagnosticComposeException.jvm.kt
- A
compose/runtime/runtime/src/linuxx64StubsMain/kotlin/androidx/compose/runtime/tooling/DiagnosticComposeException.linuxx64Stubs.kt
- A
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/tooling/ErrorTraceComposables.kt
- A
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/tooling/ErrorTraceTests.kt
Hash: f442c3e9ffc8598e743b8f540f0f4464942ea173
Date: Mon Nov 18 19:37:30 2024
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-main
Author: Andrei Shikov <
Link:
Support Compose stack traces in LayoutNode phases
Expand for full commit details
Support Compose stack traces in LayoutNode phases
This change adds a composition local that exposes access to the slot table lookup through `CompositionErrorContext`. The layout node now rethrows exceptions in measure / layout / draw with a Compose stack trace attached.
Test: UiErrorTraceTests
Bug: 354163858
Relnote: "Expose a composition local that allows to attach a compose stack trace based on a compose node location in composition."
Change-Id: Ie0bdaffb43a46328057c31e7fc9db51a80789b5e
Files:
- M
compose/runtime/runtime/api/current.txt
- M
compose/runtime/runtime/api/restricted_current.txt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/RememberEventDispatcher.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/CompositionErrorContext.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/CompositionTrace.kt
- M
compose/ui/ui/api/current.txt
- M
compose/ui/ui/api/restricted_current.txt
- A
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/tooling/UiErrorTraceTests.kt
- M
compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LookaheadPassDelegate.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/MeasureAndLayoutDelegate.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/MeasurePassDelegate.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/RootForTest.kt
Hash: 7b1ea920699ea415434402b37c108421e3550776
Date: Wed Jan 29 16:22:59 2025
ap...@google.com <ap...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-main
Author: Andrei Shikov <
Link:
Implement compose stack traces for applyChanges()
Expand for full commit details
Implement compose stack traces for applyChanges()
Handles crashes in the apply phase by connecting crash execution place to a location in composition.
For changelist:
Updates Operation interface to have an overload that accept stack trace context. The context connects operation invocation place (usually marked by the slot writer position) with the parent context to provide a full trace to the root.
For most operations it is enough to just use current location of the writer, which is handled by the default implementation. Some operations (e.g. node insertion fixups) require additional context stitching, so they are implemented separately.
For remember observer events:
Looks up the location of the node / observer holder in the slot table. This implementation does not provide context for `onForgotten` callbacks (or `onDetach`/`onRelease` of the node) at the moment.
Test: ErrorTraceTests
Bug: 354163858
Change-Id: I6ccb66004099d895ddffecacb85f582c9f7c9cc8
Files:
- M
compose/runtime/runtime-test-utils/src/commonMain/kotlin/androidx/compose/runtime/mock/CompositionTest.kt
- M
compose/runtime/runtime-test-utils/src/commonMain/kotlin/androidx/compose/runtime/mock/View.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/PausableComposition.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/changelist/ChangeList.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/changelist/FixupList.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/changelist/Operation.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/changelist/OperationArgContainer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/changelist/Operations.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/RememberEventDispatcher.kt
- A
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/CompositionErrorContext.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/CompositionTrace.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/СompositionTraceBuilder.kt
- M
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/tooling/ErrorTraceComposables.kt
- M
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/tooling/ErrorTraceTests.kt
Hash: f24d76510c1b22ee54a36e74dddc80b35a40a6f7
Date: Wed Nov 20 00:29:43 2024
ap...@google.com <ap...@google.com> #10
Project: platform/frameworks/support
Branch: androidx-main
Author: Andrei Shikov <
Link:
Support composition traces in effects
Expand for full commit details
Support composition traces in effects
Uses `CompositionErorContext` primitive to look up the effect instance in the slot table from scopes that are connected to composition. The exception is intercepted with `CoroutineExceptionHandler`, so only uncaught exceptions contain the trace.
Test: UiErrorTests
Bug: 354163858
Relnote: "Added support for compose stack traces in LaunchedEffect and rememberCoroutineScope"
Change-Id: I705c0898bc527741d87cc9ff838016b87b14fb54
Files:
- M
compose/runtime/runtime-test-utils/src/commonMain/kotlin/androidx/compose/runtime/mock/CompositionTest.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/tooling/CompositionErrorContext.kt
- M
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/tooling/ErrorTraceTests.kt
- M
compose/ui/ui-test/src/androidMain/kotlin/androidx/compose/ui/test/ComposeUiTest.android.kt
- M
compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/UncaughtExceptionHandler.kt
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/tooling/UiErrorTraceTests.kt
Hash: 064b5505376311828509df9f3a822c7769fe466d
Date: Wed Jan 29 10:43:20 2025
Description
Jetpack Compose component used: All
If an exception occurs outside of a composable, the stacktrace will often have no reference to the app developers code. This often leads to crashes being reported in Play Vitals/Crashlytics that have no ability to be debugged. As such developers cannot provide us with reproduction steps.
Recent examples include:
We could possibly help fix this using source information