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

[al] Invalid Prims Validation in UsdImagingMaterialAdapter::GetMaterialResource() #2930

Conversation

NickWu
Copy link

@NickWu NickWu commented Feb 2, 2024

Description of Change(s)

We came crossed this issue in our pipeline where there is a possibility that the UsdPrim passed in to UsdImagingMaterialAdapter::GetMaterialResource() could be invalid so we'd like to propose a prim validation check here.

Fixes Issue(s)

  • crashes in maya when displaying textures in the viewport.

  • I have verified that all unit tests pass with the proposed changes

  • I have submitted a signed Contributor License Agreement

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-9240

@FlorianZ
Copy link
Contributor

FlorianZ commented Mar 1, 2024

Hi @NickWu. Good find! Our theory is that if prim is invalid, material should be invalid, too, but then we "dereference" the prim in generating the TF_RUNTIME_ERROR. We might not accept the PR as is, but will take a look internally! Thanks again!

@NickWu
Copy link
Author

NickWu commented Mar 1, 2024

Hi @NickWu. Good find! Our theory is that if prim is invalid, material should be invalid, too, but then we "dereference" the prim in generating the TF_RUNTIME_ERROR. We might not accept the PR as is, but will take a look internally! Thanks again!

No worries!

@tcauchois
Copy link
Contributor

Hey Nick,

In our current usage of this function, I'd consider it an error for this function to be passed a null prim. If I replace the early out with an error and an early out, you'd get an error message but no crash. Would that solve your issue?

Thanks!
Tom

@NickWu
Copy link
Author

NickWu commented Mar 14, 2024

Hey Nick,

In our current usage of this function, I'd consider it an error for this function to be passed a null prim. If I replace the early out with an error and an early out, you'd get an error message but no crash. Would that solve your issue?

Thanks! Tom

Hey @tcauchois , I'll give it a try and get back to you. Thank you for the suggestion.

@NickWu
Copy link
Author

NickWu commented Mar 15, 2024

Hi @tcauchois , I tested it and it worked fine to me. I have updated the code based on your suggestion.

@NickWu
Copy link
Author

NickWu commented Mar 15, 2024

and get back to you. Thank you for the suggestion.

Hey @tcauchois , I think I might have misunderstood what you meant. I think you meant we only issue an error and early out in the case of a null prim and keep the _GetSceneMaterialsEnabled() check a simple early out?

if (!prim) {
    TF_RUNTIME_ERROR("Received prim is null.");
    return VtValue();
}

if (!_GetSceneMaterialsEnabled()) {
    return VtValue();
}

@jesschimein
Copy link
Contributor

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tcauchois
Copy link
Contributor

Yeah exactly, the code in your comment was what I had in mind. But if the current PR works for you, the code in your comment should as well. Thanks!

@tcauchois
Copy link
Contributor

Hi Nick, could you update your PR with the code proposed above? Thanks!

@NickWu
Copy link
Author

NickWu commented Mar 28, 2024

Hi Nick, could you update your PR with the code proposed above? Thanks!

Sure thing. I'll update it. Thanks!

@NickWu
Copy link
Author

NickWu commented Apr 2, 2024

Hi Nick, could you update your PR with the code proposed above? Thanks!

Sure thing. I'll update it. Thanks!

Hi @tcauchois , I have updated the code.

@jesschimein
Copy link
Contributor

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pixar-oss pixar-oss merged commit 1b7ef3b into PixarAnimationStudios:dev Apr 20, 2024
3 of 5 checks passed
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

Successfully merging this pull request may close these issues.

5 participants