Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a sublayer in hydra scene index mode causes a crash when rendering AOV buffers #3471

Open
marktucker opened this issue Dec 19, 2024 · 4 comments

Comments

@marktucker
Copy link
Contributor

Description of Issue

When in scene index mode, adding a non-empty sublayer causes hydra to invalidate and resync every prim on the stage. This is done by HdSceneIndexAdapterSceneDelegate::PrimsRemoved, which gets called with "/". This triggers a call to HdRenderIndex::_Clear, which clears all prims. Critically this include the HdRenderBuffer bprims. But HdxTaskController is responsible for creating and destroying HdRendreBuffer brpims, normally. So at this point HdxTaskController is holding onto pointers to deleted HdRenderBuffers. Future viewport updates inevitably call functions on these deleted objects and usdview crashes.

Note that the HdRenderBuffers do get recreated as part of the SyncAll call. While this means it might be possible to update the HdxTaskController to point to these new objects (or for HdxTaskController to not hold these pointers in the first place and instead always go to the render index to find the current incarnation of the HdRenderBuffer for each AOV), I think it would be better if the HdRenderBuffers are never deleted, as there's no way to know how expensive this deletion/creation may be.

When not in scene index mode, there is no code path with calls HdPrimIndex::_Clear, and the only place HdRenderBuffers get deleted is from HdxTaskController, so legacy hydra mode never crashes in this situation.

Steps to Reproduce

  1. Set USDIMAGINGGL_ENGINE_ENABLE_SCENE_INDEX=1
  2. Start usdview --renderer Embree cube.usda:
    cube.zip
  3. In the Interpreter window, run:
l = Sdf.Layer.CreateAnonymous()
p = Sdf.CreatePrimInLayer(l, '/sphere')
p.specifier = Sdf.SpecifierDef
p.typeName = 'Sphere'
usdviewApi.stage.GetRootLayer().subLayerPaths = [l.identifier]
  1. usdview crashes.

System Information (OS, Hardware)

Tested on Windows and Linux

Package Versions

Verified on dev branch as of Dec 18, 2024 (270278a)

Build Flags

Build with Embree and usdview. Though any renderer that creates HdRenderBuffers for AOVs will crash.

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10523

(This is an automated message. See here for more information.)

@tcauchois
Copy link
Contributor

Eep! It's too late to get a fix for this in 25.02 but we'll look at it right away. There might be a fix we can do in the merging scene index, or some sequencing change in HdxTaskController.

@unhyperbolic
Copy link
Member

Are you sure the problem is with the render buffer and not with the tasks? Render buffer go through emulation, but the tasks do not quite.

@marktucker
Copy link
Contributor Author

I'm quite sure the crash is because the render buffer is getting destroyed while the task controller still holds a pointer to the deleted object. I have no opinion on whether this indicates a problem with the render buffer handling or with the task handling.

I also think (just an opinion) that regardless of the root cause of the crash, it is wrong to delete the render buffers and recreate them just because there is a change to the "/" prim. You could argue that this is a separate bug, but I didn't want to presume what the solution to the crash would be, so I left it as part of this issue.

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

No branches or pull requests

4 participants