[WIP] Jetpack XR library update for July '26#978
Conversation
There was a problem hiding this comment.
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.
| val extents = FloatSize2d( | ||
| Meter.fromPixel(size.width.toFloat(), density).toM(), | ||
| Meter.fromPixel(size.height.toFloat(), density).toM(), | ||
| size.width.toFloat(), | ||
| size.height.toFloat() | ||
| ) |
There was a problem hiding this comment.
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.
| 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()) | |
| ) |
There was a problem hiding this comment.
The suggest didn't work due to the unresolved reference pxToMeters
| # Use an AndroidX snapshot build. | ||
| # https://androidx.dev/snapshots/builds | ||
| # snapshotVersion=14793336 | ||
| snapshotVersion=15770982 |
There was a problem hiding this comment.
I forget, if we set a snapshot version, does this have impact on other teams?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Just for my own understanding, what does the syntax of @GenerateHandJointData do here?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
This is an interesting API change. Same concerns re depracation.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| # Use an AndroidX snapshot build. | ||
| # https://androidx.dev/snapshots/builds | ||
| # snapshotVersion=14793336 | ||
| snapshotVersion=15770982 |
There was a problem hiding this comment.
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)
|
Moved the PR back to Draft status due to |
Jetpack XR library update for July '26