Error Creating UI Container after Kit 108 update

I would create scene views using the following code snippet:

from omni.ui import scene as sc
from omni import ui

from pxr import Gf, Sdf, Usd, UsdGeom

from omni.kit.scene_view.xr_utils.ui_container import UiContainer
from omni.kit.scene_view.xr_utils.manipulator_components.widget_component import WidgetComponent
from omni.kit.scene_view.xr_utils.spatial_source import SpatialSource

class TestWidget(ui.Widget):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # Frame container for this widget
        self._root_widget = ui.ZStack()
        self.build()

    def build(self):
        self._root_widget.clear()
        with self._root_widget:
            ui.Rectangle(style={
                "background_color": ui.color("#292929"),
                "border_color": ui.color(0.7),
                "border_width": 2,
                "border_radius": 4,
            })
            with ui.VStack(style={"margin": 8}):
                with ui.VStack(style={"margin": 0}):
                    ui.Label("Hello, Omniverse!")

widget_component = WidgetComponent(
    TestWidget,
    width=400,
    height=400,
    resolution_scale=4.0,
    unit_to_pixel_scale=2.0,
    update_policy=sc.Widget.UpdatePolicy.ALWAYS,
    construct_callback=None,
    widget_kwargs={}
)

widget_container = UiContainer(
    widget_component,
    space_stack=[
        SpatialSource.new_translation_source(Gf.Vec3d(0, 0, 0)),
        SpatialSource.new_rotation_source(
            Gf.Vec3d(90, 0, 0))
    ])

After Kit 108, it appears UiContainer now takes a omni.ui.scene.SceneView type instead of ui.Widget type (if I read it correctly). However, simply changing TestWidget to inherit from omni.ui.scene.SceneView causes the TestWidget instance to be rendered on top of the viewport. How should this be set up now?

Are there any release notes on the scene_view XR utils extensions?

PS. The code above would work with Kit 107 when using the following imports instead:

from omni.kit.xr.scene_view.utils.ui_container import UiContainer
from omni.kit.xr.scene_view.utils.manipulator_components.widget_component import WidgetComponent
from omni.kit.xr.scene_view.utils.spatial_source import SpatialSource

Hi , any updates on running xr ui in kit 108+

Just tried with Kit 109, but the issue is still there.

Any advice @Richard3D ?

Yes, the behavior changed in Kit 108: UiContainer now expects a scene-view–style object rather than a plain ui.Widget , and if you just subclass SceneView and attach it to the UI hierarchy, it will draw as a 2D overlay.

How to set it up in Kit 108

The intended pattern is:

  1. Create a SceneView that contains your 3D/UI content, but do not attach it directly to a normal UI frame.
  2. Let WidgetComponent + UiContainer own and place that SceneView in the XR scene.

A minimal adaptation looks like this:

python

import omni.ui as ui
import omni.ui.scene as sc
from pxr import Gf

from omni.kit.scene_view.xr_utils.ui_container import UiContainer
from omni.kit.scene_view.xr_utils.manipulator_components.widget_component import WidgetComponent
from omni.kit.scene_view.xr_utils.spatial_source import SpatialSource


class TestSceneView(sc.SceneView):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # Build scene content into self.scene, not a top-level ui.Widget
        with self.scene:
            # Example: a simple quad with UI drawn via scene primitives
            sc.Rectangle(width=1.0, height=1.0, color=ui.color(0.2, 0.2, 0.2, 1.0))
            sc.Text("Hello, Omniverse!", alignment=ui.Alignment.CENTER)


# Build a component that creates/owns the SceneView
widget_component = WidgetComponent(
    TestSceneView,
    width=400,
    height=400,
    resolution_scale=4.0,
    unit_to_pixel_scale=2.0,
    update_policy=sc.Widget.UpdatePolicy.ALWAYS,
    construct_callback=None,
    widget_kwargs={}
)

# Attach to 3D/XR space via UiContainer
widget_container = UiContainer(
    widget_component,
    space_stack=[
        SpatialSource.new_translation_source(Gf.Vec3d(0, 0, 0)),
        SpatialSource.new_rotation_source(Gf.Vec3d(90, 0, 0)),
    ],
)

Hello Richard, thanks for the additional information. Unfortunately, the provided code does not work because UiContainer now takes a new argument “scene_view_type”. Passing the WidgetComponent alone does not work. I did try the following:

widget_component = WidgetComponent(
    TestSceneView,
    width=400,
    height=400,
    resolution_scale=4.0,
    unit_to_pixel_scale=2.0,
    update_policy=sc.Widget.UpdatePolicy.ALWAYS,
    construct_callback=None,
    widget_kwargs={},
)

self._widget_container = UiContainer(
    TestSceneView,
    widget_component,
    space_stack=[
        SpatialSource.new_translation_source(Gf.Vec3d(0, 0, 0)),
        SpatialSource.new_rotation_source(Gf.Vec3d(90, 0, 0)),
    ],
)

Although this works, the view is being created twice (you can see the second tiny label)!

If you do not use the widget_component, as such:

self._widget_container = UiContainer(
    TestSceneView,
    space_stack=[
        SpatialSource.new_translation_source(Gf.Vec3d(0, 0, 0)),
        SpatialSource.new_rotation_source(Gf.Vec3d(90, 0, 0)),
    ],
)

Then, you get one the tiny one:

Also, you defined the rectangle and label using sc.Rectangle and sc.Label, does that mean everywhere it was ui. has to be changed to sc.???

Let me ask one of our XR engineers and get back to you.

Just a quick update, I have tried Kit 109.0.2 and things appear to be the same.

I have tried with Kit 110.0 and no changes. Any updates from the devs @Richard3D ?

One thing I did try was to pass the sc.SceneView type directly to the UiContainer, which sort of worked and I am able to see the scene views in the scene, but these are not visualized in VR. Which makes sense because, if I understand correctly, sc.SceneView instances are rendered on top of the viewport.


widget_component = WidgetComponent(
            self._widget_class,
            width=size[0],
            height=size[1],
            resolution_scale=resolution_scale,
            unit_to_pixel_scale=unit_to_pixel,
            update_policy=sc.Widget.UpdatePolicy.ALWAYS,
            construct_callback=self.__capture_widget,
            widget_kwargs=widget_args
        )

self._widget_container = UiContainer(
            sc.SceneView,           # Gave the base SceneView class.
            widget_component,
            space_stack=[
                SpatialSource.new_translation_source(Gf.Vec3d(position[0], position[1], position[2])),
                SpatialSource.new_rotation_source(
                    Gf.Vec3d(math.radians(orientation[0]), math.radians(orientation[1]), math.radians(orientation[2])))
            ])

Any updated examples anywhere on how are scene views to be created for VR experiences now?

Let me ask our engineers again.

Hi! I’m Scott, one of the developers on that system.

Thank you for your patience on this issue, and sorry about the documentation and examples not being up to date.

We have an XR-specific XRSceneView in omni.kit.scene_view.xr. You should be able to drop-in replace any sc.SceneView objects with XRSceneView and that will trigger the rendering path that uses in-stage objects and materials that will show up in VR.


Here is a quick example:

from omni import ui
from omni.kit.scene_view.xr import XRSceneView
from omni.kit.scene_view.xr_utils import WidgetComponent, UiContainer


class _TestWidget(ui.Widget):
    def __init__(self, text: str | None = None, style: dict[str, Any] | None = None):
        super().__init__()
        if text is None:
            text = "UI\nContainer\nTest"

        if style is None:
            style = {"font_size": 48}

        self._text = text
        self._style = style
        self._build_ui()

    def _build_ui(self):
        self._widget = ui.VStack()
        with self._widget:
            ui.Label(self._text, style=self._style)

def show_test_ui():
    widget_component = WidgetComponent(_TestWidget)
    container = UiContainer(XRSceneView, widget_component)

Looks like you’re already handling the arguments to WidgetComponent correctly, so I think the only change you need is the XRSceneView.


BTW, there’s a known issue in 109 and 110 where sometimes the UI textures won’t always show up (they are just a white rectangle), but usually hiding/deleting and re-showing them fixes this.

There are also some stability issues we know of around multi-GPU, so for now we recomment using single-GPU (multi-GPU mode can be disabled in Kit settings if necessary, but if you only have a single GPU, then this won’t affect you).

The fixes for both issues are already in the pipe to be released in the near future.


Let me know how the system works out for you with these changes!

Hello @SourcererScott ,

Thank you for the example! Quite a simple resolution and worked just fine. I did see the white rectangle issue, but at least I am able to re-activate our VR UI features. Looking forward to the future XR features and updates!

Great, I am glad you got it working.