CesiumGS / cesium-omniverse

Bringing the 3D geospatial ecosystem to Omniverse
https://cesium.com/platform/cesium-for-omniverse/
Apache License 2.0
58 stars 7 forks source link

Reload application when extension is added for the first time #151

Closed lilleyse closed 1 year ago

lilleyse commented 1 year ago

Is it possible for an extension to prompt the user to reload the application when enabled for the first time? Our extension needs to be able to register some custom USD plugins at startup.

Similar to what you might see in VS Code:

image

lilleyse commented 1 year ago

One solution that was proposed:

def on_click():
    omni.kit.app.get_app().post_quit()
    run_process(sys.argv)

ui.Button(
    "RESTART APP",
    style_type_name_override="ExtensionDescription.RestartButton",
    clicked_fn=on_click,
    width=100,
    height=30,
)

From what I can tell, they are reacting to a on-click event to call post_quit on the app object and then immediately call run_process with the system arguments. This has an interesting effect; in essences it tells the current running kit application to shutdown and then in tandem (note, not necessarily in parallel), it starts a new process with the system arguments.

lilleyse commented 1 year ago

I tested this again today. No surprise, our extension still requires a reload after first install. It loads tiles but can't load their textures. Prim updates don't work either. But it could be worse, at least it doesn't crash.

lilleyse commented 1 year ago

The physics extension in https://github.com/NVIDIA-Omniverse/kit-extension-template-cpp prevents you from enabling the extension until the application is restarted. Maybe that's what we should do too.

https://user-images.githubusercontent.com/915398/231169098-bfdf1368-50d2-4b1e-8efb-7815b723ec03.mp4

corybarr commented 1 year ago

The physics extension in https://github.com/NVIDIA-Omniverse/kit-extension-template-cpp prevents you from enabling the extension until the application is restarted. Maybe that's what we should do too.

physics-restart.mp4

This solution seems best. It makes the experience of having to reload the Cesium extension consistent with the rest of the Omniverse extensions. And any UX change to reloading extensions will also apply to the Cesium extension.