Skip to content

Update XR library snippets for the May 19 release#918

Merged
devbridie merged 14 commits into
mainfrom
jxr-io
May 19, 2026
Merged

Update XR library snippets for the May 19 release#918
devbridie merged 14 commits into
mainfrom
jxr-io

Conversation

@devbridie
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Android XR samples to align with recent API changes, including renaming 'DepthMap' to 'Depth' and 'ExrImage' to 'ImageBasedLightingAsset', and transitioning to 'SPATIAL' tracking modes. It also introduces a comprehensive set of Glimmer component samples and replaces the '.movable()' modifier with '.transformingMovable()'. Feedback identifies several issues in the 'SpatialGltfModel' sample, such as a potential null pointer exception, redundant imports, and conflicting 'LaunchedEffect' blocks that overwrite material overrides. Additionally, the reviewer noted a performance regression where material caching was removed and a duplicated documentation tag in the focus samples.

Comment on lines +71 to +72
node?.localPose =
Pose(node.localPose.translation, rotation)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Accessing node.localPose directly is unsafe because node is nullable (returned by find). This will cause a NullPointerException if the node is not found. Use a null-safe block to perform the update.

        node?.let {
            it.localPose = Pose(it.localPose.translation, rotation)
        }

Comment on lines +22 to +25
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These imports are redundant as they are already present in the file (lines 27-30). Please remove the duplicates to keep the import section clean.

// Create and apply the custom material once the session is ready and the target node is available.
LaunchedEffect(node) {
val material = pbrMaterial ?: KhronosPbrMaterial.create(
val material = KhronosPbrMaterial.create(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The material is being re-created every time this LaunchedEffect runs, bypassing the pbrMaterial cache defined at line 78. This is less efficient than the previous implementation. Consider restoring the caching logic.

Suggested change
val material = KhronosPbrMaterial.create(
val material = pbrMaterial ?: KhronosPbrMaterial.create(

}

// [START androidxr_compose_SpatialGltfModelTexture]
LaunchedEffect(node) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This LaunchedEffect conflicts with the one starting at line 81. Both effects use node as a key and call setMaterialOverride. Since they run concurrently, the second one will overwrite the first, making the base color factor set in the first block ineffective. Consider merging these snippets or clarifying their usage.


// [START xr_glimmer_focus_activity]

// [START xr_glimmer_focus_activity]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The snippet tag [START xr_glimmer_focus_activity] is duplicated (see line 32). Please remove the redundant tag to ensure correct documentation generation.

@amyZepp amyZepp marked this pull request as ready for review May 19, 2026 18:00
@amyZepp amyZepp requested a review from a team as a code owner May 19, 2026 18:00
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented May 19, 2026

Here is the summary of changes.

You are about to add 33 region tags.
You are about to delete 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Copy Markdown
Contributor

@amyZepp amyZepp left a comment

Choose a reason for hiding this comment

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

LGTM

@devbridie devbridie merged commit c2b9777 into main May 19, 2026
6 checks passed
@devbridie devbridie deleted the jxr-io branch May 19, 2026 18:36
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.

2 participants