Fix RUM-13135: Compose Instrumentation modifying expected layout#3249
Draft
Fix RUM-13135: Compose Instrumentation modifying expected layout#3249
Conversation
…ment
Root cause: The Datadog Kotlin Compiler Plugin prepends Modifier.semantics {}
to every composable call's modifier chain. In certain Compose versions, the
CoreSemanticsModifierNode implementation may participate in the layout
measurement chain, causing constraint propagation issues in SubcomposeLayout-
based components (e.g., Coil SubcomposeAsyncImage) inside LazyRow/LazyColumn.
Changes:
- Replace Modifier.semantics {} with custom DatadogSemanticsElement/Node
- DatadogSemanticsNode explicitly implements only SemanticsModifierNode
- Node is guaranteed to never interfere with layout constraints
- DatadogSemanticsPropertyKey and public API remain unchanged
Tests: 7 unit
Apply ktlint standard:class-signature and standard:function-signature rules to DatadogSemanticsElement, DatadogSemanticsNode, and test methods.
…shCode Convert DatadogSemanticsElement from data class to regular class to avoid detekt DataClassContainsFunctions violation. Manually implement equals() and hashCode() to maintain the same behavior for Compose modifier reuse.
Revert ktlint auto-format to use multi-line class and function signatures that match the existing project style conventions (parameters on separate lines when there are 2+ parameters).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes layout constraint propagation issue caused by Datadog Compose auto-instrumentation. When the compiler plugin prepends
Modifier.semantics {}to composable modifier chains, it can interfere withSubcomposeLayout-based components (e.g., Coil'sSubcomposeAsyncImage) insideLazyRow/LazyColumn, causinghasBoundedHeightto becomefalseandminHeightto become0.RUM-13135
Root Cause
The Datadog Kotlin Compiler Plugin (
ComposeTagTransformer) auto-instruments composable functions by insertinginstrumentedDatadog(name).then(originalModifier)at every composable call site. TheinstrumentedDatadog()function previously usedModifier.semantics {}(fromCoreSemanticsModifierNode), which in certain Compose framework versions may participate in the layout measurement chain, modifying constraint propagation.Changes
DatadogModifier.kt: ReplacedModifier.semantics {}with customDatadogSemanticsElement/DatadogSemanticsNodeusing theModifierNodeElementAPIDatadogSemanticsNodeexplicitly implements onlySemanticsModifierNode(NOTLayoutModifierNode)DatadogSemanticsPropertyKeyand publicModifier.datadog()API remain unchangedDatadogSemanticsElementTest.kt: 7 unit tests for the new element/nodeCompanion Change (separate repo)
dd-sdk-android-gradle-plugin:ComposeTagTransformer.buildIrExpression()should change modifier order fromdatadogTag.then(original)tooriginal.then(datadogTag), placing semantics INNER instead of OUTER so layout modifiers process constraints first.Test Plan
DatadogSemanticsElementandDatadogSemanticsNodeGenerated by rum:fix-jira-issues