Stage_preview extension crash in Code 2022.2.0

I need a method to show preview of some random asset, so I found the extension: omni.kit.viewport.stage_preview. But here I have encounter an crash problem. You can reproduce the crash by steps below:

  1. Right click an model asset in content browser - preview. Now a new stage preview window show up and everything looks great;
  2. Close the preview window, and get a new stage, by menu bar - File - New;
  3. Open a preview window just like step 1 again, and this time, the process hang and crash after seconds.

I’m using Create 2022.2.2 as the backend of my Kit app, the example code is extracted from Code 2022.2.0, and this crash can be reproduced in Code too.
I guess because this stage_preview extension has some trouble in practice so it’s not produced in Create. If that so, is there some other way to achive the purpose, to show an independent viewport windwo for some random model asset?

Thanks for reporting - I’m checking with dev team.

Have you signed up for the Omniverse Insider program? Log in | NVIDIA Developer


P.S. Fall GTC 2022 Sessions are now available for free viewing: GTC 2022: #1 AI Conference

P.P.S. Share your work in Omniverse! Submit to the Omniverse Gallery Page! Omniverse Gallery Submissions | NVIDIA

he / him | LinkedIn | Discord ID: Prof E#2041
Community Engagement for Omniverse: " A New Era of Digital Twins & Virtual Worlds with NVIDIA Omniverse" Video
What is NVIDIA Omniverse? Video | Check out the “Meet the Omnivore” blog series here

Omniverse Resources:
Omniverse | Documentation | Tech Requirements | Videos | Twitter | Discord | Twitch

The Omniverse documentation site has more info and links to all tutorial videos (under the “Learning and Feedback” category on left nav bar): Omniverse Platform Overview — Omniverse Developer documentation

PLEASE NOTE: If you are reporting a bug/issue, please provide OS, GPU, GPU Driver, the version of the app, and full log file (if applicable). For crashes, please zip and provide a link to your logs → C:\Users\ [YOUR NAME] \ .nvidia-omniverse\logs

Hi @staticon. The Stage Preview is just a sample extension and may not handle every edge case. It’s common that you need to handle refreshing your references to USD stages and contexts when a new stage is opened. I’ve gone ahead and logged the bug in case there is something else going on here. (OM-66136)

Thanks a lot! I’ll go take a try and follow your advice.

Hi @mati-nvidia . I have tried some attemption. Each time when init an new preview window, give it a new usd_context_name, like using uuid(). By this way, it can fix the crash issue after recreate a new viewport. BUT I didn’t find a proper method to release the resource on closing the preview windows, hence after 5 (only in my cases) more creation of these preview window, KIT crashed at last, and here is the reported error:

def destroy(self):
        if self.__usd_context:
            # We can't fully tear down everything yet, so just clear out any active stage
            # self.__usd_context = None
            # omni.usd.destroy_context(self.__usd_context_name)

If I uncomment the line # omni.usd.destroy_context(self.__usd_context_name), KIT crashed at this point anyway.
So is there some proper way to release the usd_context? Some specific codes would be much appreciated, thanks!