fix(compose): add isImportantForBounds() to SentryTagModifierNode for compose-ui 1.11+#5672
Open
tsushanth wants to merge 1 commit into
Open
Conversation
… 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 |
There was a problem hiding this comment.
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.
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.
Fixes #5662
Problem
compose-ui 1.11addedSemanticsModifierNode.isImportantForBounds()as an abstract method.SentryTagModifierNodewas compiled againstcompose-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 withcompose-ui 1.11+, the JVM cannot find the method and throws:Fix
Add
fun isImportantForBounds(): Boolean = falsetoSentryTagModifierNode.The
overridekeyword is intentionally omitted because the method is absent from thecompose-ui 1.6.xcompile-time dependency — usingoverridewould 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.SentryTagModifierNodestores only a semantic tag with no layout or visual effect, sofalseis the correct return value (it does not affect touch-bounds computation).Testing
Verified no public API changes (
./gradlew sentry-compose:apiCheckpasses —SentryTagModifierNodeis private, so no.apifile update required). The fix applies cleanly to the existingcompose-ui 1.6.xcompile target without version bumps.