Skip to content

fix(compose): add isImportantForBounds() to SentryTagModifierNode for compose-ui 1.11+#5672

Open
tsushanth wants to merge 1 commit into
getsentry:mainfrom
tsushanth:fix/sentry-compose-isimportantforbounds-1-11
Open

fix(compose): add isImportantForBounds() to SentryTagModifierNode for compose-ui 1.11+#5672
tsushanth wants to merge 1 commit into
getsentry:mainfrom
tsushanth:fix/sentry-compose-isimportantforbounds-1-11

Conversation

@tsushanth

Copy link
Copy Markdown
Contributor

Fixes #5662

Problem

compose-ui 1.11 added SemanticsModifierNode.isImportantForBounds() as an abstract method. SentryTagModifierNode was compiled against compose-ui 1.6.x, where the method does not exist, so its class bytecode has no implementation. When an accessibility client (TalkBack, UiAutomator2, adb shell uiautomator dump) traverses the Compose semantics tree at runtime with compose-ui 1.11+, the JVM cannot find the method and throws:

AbstractMethodError: abstract method "boolean androidx.compose.ui.node.SemanticsModifierNode.isImportantForBounds()"
    at SentryTagModifierNode (SentryModifier.kt)

Fix

Add fun isImportantForBounds(): Boolean = false to SentryTagModifierNode.

The override keyword is intentionally omitted because the method is absent from the compose-ui 1.6.x compile-time dependency — using override would fail to compile. The JVM satisfies the abstract-method contract at runtime via bytecode signature matching, regardless of whether the Kotlin compiler knew about the override at compile time.

SentryTagModifierNode stores only a semantic tag with no layout or visual effect, so false is the correct return value (it does not affect touch-bounds computation).

Testing

Verified no public API changes (./gradlew sentry-compose:apiCheck passes — SentryTagModifierNode is private, so no .api file update required). The fix applies cleanly to the existing compose-ui 1.6.x compile target without version bumps.

… compose-ui 1.11+

compose-ui 1.11 added SemanticsModifierNode.isImportantForBounds() as an
abstract method. SentryTagModifierNode was compiled against compose-ui 1.6.x,
where the method does not exist, so its bytecode lacks an implementation.
When an accessibility client (TalkBack, UiAutomator, adb uiautomator dump)
traverses the Compose semantics tree at runtime on 1.11+, the JVM cannot find
the method and throws AbstractMethodError.

Adding fun isImportantForBounds(): Boolean = false without the override keyword
(since the method is absent from the 1.6.x compile-time dependency) places the
method in the class bytecode. The JVM satisfies the abstract method requirement
via signature matching at runtime. SentryTagModifierNode stores only a semantic
tag with no layout/visual effect, so false is the correct return value.
Comment on lines +65 to +66
@Suppress("unused")
fun isImportantForBounds(): Boolean = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The isImportantForBounds method in SentryTagModifierNode lacks a -keep ProGuard rule. R8 will likely strip it as unused code, causing an AbstractMethodError in release builds with accessibility enabled.
Severity: CRITICAL

Suggested Fix

Add a ProGuard rule to explicitly keep the isImportantForBounds method within the SentryTagModifierNode class. For example: -keep class io.sentry.compose.SentryModifier$SentryTagModifierNode { *** isImportantForBounds(...); }. This will prevent R8 from stripping the method during minification.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryModifier.kt#L65-L66

Potential issue: The newly added `isImportantForBounds()` method in the
`SentryTagModifierNode` class is intended to provide runtime compatibility with newer
Compose UI versions. However, it lacks the `override` keyword and is annotated with
`@Suppress("unused")`. Without a specific `-keep` rule in ProGuard to prevent code
shrinking, R8's static analysis will likely identify this method as dead code and remove
it during release build minification. This will cause an `AbstractMethodError` in
production when an accessibility client (like TalkBack) traverses the Compose semantics
tree, as the runtime will be unable to find the required method.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

AbstractMethodError: SemanticsModifierNode.isImportantForBounds() with sentry-compose on compose-ui 1.11+

1 participant