-
-
Notifications
You must be signed in to change notification settings - Fork 468
Support apps compiled against Jetpack Compose 1.10 #5189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
72a523b
Compile against JPC 1.10
markushi c863646
Format code
getsentry-bot 7400d9c
Fix click/scroll target detection
markushi e51aca5
Merge branch 'markushi/fix/compose-110-api-changes' of github.com:get…
markushi 0e2a446
Update Changelog
markushi d9d89d9
Move changes into replay module
markushi 339c0cd
Switch to reflection
markushi 018df71
Fix Changelog
markushi 66db017
Improve LayoutNode iteration
markushi 18a13f4
Fix tag propagation
markushi 994b7b2
Add tests
markushi 3559ed4
Address PR feedback
markushi f7cca22
Merge branch 'main' into markushi/fix/compose-110-api-changes
markushi ee7eff5
Format code
getsentry-bot f188f6c
Update CHANGELOG for Jetpack Compose and SDK version
markushi 38865c2
Merge branch 'main' into markushi/fix/compose-110-api-changes
markushi 00f2c99
Merge branch 'markushi/fix/compose-110-api-changes' of github.com:get…
markushi 745e707
return first tag instead of last one
markushi 19d21a3
Fix exception propagation
markushi fa61cae
Return first non-null tag
markushi cea378d
Allow nullable semantics in case there are really none
markushi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryLayoutNodeHelper.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| @file:Suppress( | ||
| "INVISIBLE_MEMBER", | ||
| "INVISIBLE_REFERENCE", | ||
| "EXPOSED_PARAMETER_TYPE", | ||
| "EXPOSED_RETURN_TYPE", | ||
| "EXPOSED_FUNCTION_RETURN_TYPE", | ||
| ) | ||
|
|
||
| package io.sentry.compose | ||
|
|
||
| import androidx.compose.ui.node.LayoutNode | ||
| import org.jetbrains.annotations.ApiStatus | ||
|
|
||
| /** | ||
| * Provides access to internal LayoutNode members that are subject to Kotlin name-mangling. | ||
| * | ||
| * LayoutNode.children and LayoutNode.outerCoordinator are Kotlin `internal`, so their getters are | ||
| * mangled with the module name: getChildren$ui_release() in Compose < 1.10 vs getChildren$ui() in | ||
| * Compose >= 1.10. This class detects the version on first use and delegates to the correct | ||
| * accessor. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public object SentryLayoutNodeHelper { | ||
| @Volatile private var compose110Helper: Compose110Helper? = null | ||
| @Volatile private var useCompose110: Boolean? = null | ||
|
|
||
| private fun getHelper(): Compose110Helper { | ||
| compose110Helper?.let { | ||
| return it | ||
| } | ||
| val helper = Compose110Helper() | ||
| compose110Helper = helper | ||
| return helper | ||
| } | ||
|
|
||
| public fun getChildren(node: LayoutNode): List<LayoutNode> { | ||
| return if (useCompose110 == false) { | ||
| node.children | ||
| } else { | ||
| try { | ||
| getHelper().getChildren(node).also { useCompose110 = true } | ||
| } catch (_: NoSuchMethodError) { | ||
| useCompose110 = false | ||
| node.children | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public fun isTransparent(node: LayoutNode): Boolean { | ||
| return if (useCompose110 == false) { | ||
| node.outerCoordinator.isTransparent() | ||
| } else { | ||
| try { | ||
| getHelper().getOuterCoordinator(node).isTransparent().also { useCompose110 = true } | ||
| } catch (_: NoSuchMethodError) { | ||
| useCompose110 = false | ||
| node.outerCoordinator.isTransparent() | ||
| } | ||
| } | ||
| } | ||
| } |
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
23 changes: 23 additions & 0 deletions
23
sentry-compose/src/compose110/kotlin/io/sentry/compose/Compose110Helper.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| @file:Suppress( | ||
| "INVISIBLE_MEMBER", | ||
| "INVISIBLE_REFERENCE", | ||
| "EXPOSED_PARAMETER_TYPE", | ||
| "EXPOSED_RETURN_TYPE", | ||
| "EXPOSED_FUNCTION_RETURN_TYPE", | ||
| ) | ||
|
|
||
| package io.sentry.compose | ||
|
|
||
| import androidx.compose.ui.node.LayoutNode | ||
| import androidx.compose.ui.node.NodeCoordinator | ||
|
|
||
| /** | ||
| * Compiled against Compose >= 1.10 where internal LayoutNode accessors are mangled with the module | ||
| * name "ui" (e.g. getChildren$ui(), getOuterCoordinator$ui()) instead of "ui_release" used in | ||
| * earlier versions. | ||
| */ | ||
| public class Compose110Helper { | ||
| public fun getChildren(node: LayoutNode): List<LayoutNode> = node.children | ||
|
|
||
| public fun getOuterCoordinator(node: LayoutNode): NodeCoordinator = node.outerCoordinator | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.