Skip to content

[WIP] Jetpack XR library update for July '26#978

Draft
trambui09 wants to merge 3 commits into
android:mainfrom
trambui09:tb/jxr-july26
Draft

[WIP] Jetpack XR library update for July '26#978
trambui09 wants to merge 3 commits into
android:mainfrom
trambui09:tb/jxr-july26

Conversation

@trambui09

Copy link
Copy Markdown
Contributor

Jetpack XR library update for July '26

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

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.

Code Review

This pull request updates various XR and Compose components, including replacing AnchorEntity with AnchorSpace, migrating from transformingMovable/transformingResizable to movable/resizable, updating Card usages to ActionCard, and adopting new animation APIs. Critical feedback includes fixing a runtime ClassCastException in Hands.kt caused by an incorrect this cast inside a coroutine builder, and resolving a scaling issue in SceneCoreEntity.kt where layout dimensions are passed directly as meters instead of being converted using virtualPixelDensity.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread xr/src/main/java/com/example/xr/arcore/Hands.kt Outdated
Comment on lines 59 to 62
val extents = FloatSize2d(
Meter.fromPixel(size.width.toFloat(), density).toM(),
Meter.fromPixel(size.height.toFloat(), density).toM(),
size.width.toFloat(),
size.height.toFloat()
)

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

The size parameter in onLayoutSizeChanged represents the layout dimensions in pixels (or virtual pixels). Directly passing size.width.toFloat() and size.height.toFloat() to FloatSize2d without converting them to meters will result in an extremely large quad (e.g., hundreds or thousands of meters wide/high). You should use the virtualPixelDensity retrieved on line 37 to perform the conversion from pixels to meters.

Suggested change
val extents = FloatSize2d(
Meter.fromPixel(size.width.toFloat(), density).toM(),
Meter.fromPixel(size.height.toFloat(), density).toM(),
size.width.toFloat(),
size.height.toFloat()
)
val extents = FloatSize2d(
virtualPixelDensity.pxToMeters(size.width.toFloat()),
virtualPixelDensity.pxToMeters(size.height.toFloat())
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The suggest didn't work due to the unresolved reference pxToMeters

@trambui09 trambui09 marked this pull request as ready for review July 9, 2026 22:02
@trambui09 trambui09 requested review from a team as code owners July 9, 2026 22:02
Comment thread gradle.properties
# Use an AndroidX snapshot build.
# https://androidx.dev/snapshots/builds
# snapshotVersion=14793336
snapshotVersion=15770982

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.

I forget, if we set a snapshot version, does this have impact on other teams?

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.

If other teams were relying on an older snapshot release and the API changing between the publication of a snippet but that's extremely rare. Once the release is ready, we don't really change it, we upgrade the version number. I would say if we uncomment this line, it should be commented back within 2 weeks (Jetpack release cycle)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The intention is that the PR author reverts the change to this file - this change is to help XR team members synchronize on the same snapshot version. When Jetpack goes live, we revert the change to snapshotVersion and merge into main.

import androidx.xr.runtime.Session
import androidx.xr.runtime.SessionConfigureSuccess
import androidx.xr.runtime.math.Pose
import androidx.xr.scenecore.AnchorEntity

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.

Just to confirm that we are handling this name change properly - is this a breaking change or is AnchorEntity still available and marked as depracated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a breaking change. Any code using the old AnchorEntity class will need to be updated to use AnchorSpace.

session.configure(config)

lifecycleScope.launch {
val session = (Session.create(context = this@GenerateHandJointData) as SessionCreateSuccess).session

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.

Just for my own understanding, what does the syntax of @GenerateHandJointData do here?

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.

this refers to lifecycleScope given that it's within its block. By putting @GenerateHandJointData, you go one level higher, which is an Activity and it's castable as a `Context

SubspaceModifier
.height(824.dp)
.width(1400.dp)
.transformingResizable()

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.

Same question here - how is this deprecation being handled?

Do we have enough changes that we should think about doing a migration guide? Or perhaps a few things we should highlight in the Beta Blog post in August?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think @amyZepp would be a good person to make that call. What do you think Amy?

Meter.fromPixel(size.width.toFloat(), density).toM(),
Meter.fromPixel(size.height.toFloat(), density).toM(),
size.width.toFloat(),
size.height.toFloat()

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.

is the data we are returning from these values fundamentally different now?

I am trying to understand if we have a sneaky breaking change that might be hard to detect and leading to bugs.

}
} else if (isVisualUiSupported) {
Card(
ActionCard(

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.

This is an interesting API change. Same concerns re depracation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the glimmer Card composable has an action parameter, it is a breaking change (which it is in this case). The glimmer Card composable still exists.

@vad710 vad710 left a comment

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.

LGTM - left several comments/questions about how we are handling the breaking change and how we might best set developers for success to navigate these changes.

session.configure(config)

lifecycleScope.launch {
val session = (Session.create(context = this@GenerateHandJointData) as SessionCreateSuccess).session

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.

this refers to lifecycleScope given that it's within its block. By putting @GenerateHandJointData, you go one level higher, which is an Activity and it's castable as a `Context

Comment thread gradle.properties
# Use an AndroidX snapshot build.
# https://androidx.dev/snapshots/builds
# snapshotVersion=14793336
snapshotVersion=15770982

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.

If other teams were relying on an older snapshot release and the API changing between the publication of a snippet but that's extremely rare. Once the release is ready, we don't really change it, we upgrade the version number. I would say if we uncomment this line, it should be commented back within 2 weeks (Jetpack release cycle)

@devbridie devbridie marked this pull request as draft July 10, 2026 13:13
@devbridie

Copy link
Copy Markdown
Member

Moved the PR back to Draft status due to snapshotVersion change - that change is not meant to land in main.

@trambui09 trambui09 changed the title Jetpack XR library update for July '26 [WIP] Jetpack XR library update for July '26 Jul 10, 2026
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.

5 participants