-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
usdValidation: usdUtils: CompressionValidator #3449
base: dev
Are you sure you want to change the base?
usdValidation: usdUtils: CompressionValidator #3449
Conversation
@@ -97,12 +98,55 @@ _PackageEncapsulationValidator(const UsdStagePtr &usdStage) | |||
return errors; | |||
} | |||
|
|||
static UsdValidationErrorVector | |||
_CompressionValidator(const UsdStagePtr& usdStage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tallytalwar I've come across something in this validator that's not clear to me.
My expectation from reading the description from the existing CompressionChecker is that this test should make sure that files within the USDZ file itself were not compressed. So I've created a sample file like this (in this repo as compressedUsdaInside.usdz). However this file fails here, before it can get to the usdchecker code.
If I try a different approach of compressing the usdz itself, it also fails early here.
Do you know how to reproduce the nicer errors from usdchecker itself? (Similar situation with ByteAlignmentChecker as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why its failing on parsing the "compressed" "usda" file is because I think usda extension makes it load the usda file plugin, which when parsing tries to see if the file header has the usda magic cookie and if not it fails. If you stick with this approach only maybe use a different extension for this file.
- usdz is an archival format, so the code checks if it has any compression on it or not.
Maybe add a compressed asset to usdz file like a compressed jpeg/png?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried compressing a jpg and adding it to the usdz, and I've tried including a zip file as an asset and then including it in the usdz as well. I'm still unable to trigger the CompressionChecker in the existing complianceChecker.py
usdchecker version
Filed as internal issue #USD-10492 |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic is fine, but I was thinking we can split this up into a UsdzPackageValidator and a UsdzRootPackageValidator with appropriate keywords.
Both validators are stage level validators:
- RootPackageValidator: will do compression error logic, byle alignment logic and extension validation logic just for the rootLayer, if the rootLayer is a package.
- UsdzPackageValidator: will do all the same validation checks for all packages found in the stage.
A lot of the actual validation code itself can be shared between the 2 validator methods.
This way we can do this: https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/usdValidation/bin/usdchecker/usdchecker.cpp#L572-L575
Let me know what you think about this and feel free to ping on aswf slack if you want to discuss this more?
Thanks
if (!zipFile) | ||
{ | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move this check above doing the ArSplitPackageRelativePathOuter
rootLayer, SdfPath(fileName)) | ||
}, | ||
TfStringPrintf( | ||
("File '%s' in package '%s' has " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra "()" here? TfStringPrintf(("File .... instead of TfStringPrintf("File..
b325222
to
14c4f8f
Compare
- removed unnecessary parenthesis on error messages - move early exit condition earlier
- update the validation logic to always check for both compression & byteAlignment, either only at the root level or at all levels
- added a test to test a referenced usdz file that has internal byte alignment and compression errors - added example test usd files
55acc80
to
8229bd9
Compare
_GetUsdzPackageErrors(const SdfLayerHandle &rootLayer) | ||
{ | ||
const UsdZipFile zipFile = UsdZipFile::Open(rootLayer->GetRealPath().c_str()); | ||
if (!zipFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tallytalwar I noticed testing locally that when passing a .usda file in here, this if statement does not filter out the .usda layer, which I anticipated that it would. All of the errors are still coming back correctly but I wanted to ask if there was some other condition to put here to exit out early as I couldn't find something on the UsdZipFile class that was applicable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looks like from the code it works even if the layer is a usda layer, as it goes through ArAsset. I will confirm internally if thats anticipated.
// Verify internal compression and byte misalignment errors occur | ||
TF_AXIOM(errors.size() == 3); | ||
|
||
const std::string fullErrorPath = ArchGetCwd() + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tallytalwar Two things about this line.
- It seems in the validator itself, if I pass in a root level myFile.usdz, the
ArSplitPackageRelativePathOuter
will get the package path that i want, as in, onlymyFile.usdz
however passing inparentFile.usda
that referencesmyFile.usdz
the error message has the full real path in the error message - If the above is okay as is, I wanted to join these paths here in a platform agnostic way and I thought there was some library function to join these paths so it would work everywhere as this as written seems it's the wrong direction for Windows, and it seemed wrong to write some helper function here to deal with the correct slashes. I did find other tests that used only this slash, but let me know if this should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I fully understand, 1.
But for 2, there is: https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/base/tf/stringUtils.h#L677-L689 which you can use to do a platform agnostic way of concatenating paths, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To rephrase 1, this line: https://github.com/PixarAnimationStudios/OpenUSD/pull/3449/files#diff-d9adee7401f280af5ec4cc8aa666b4fb0d767ea269bedc2750dcc333503af6aaR156 behaves differently whether it's the root package or an internal package.
- When it's a root package the value will be : "rootPackage.usdz" (or whatever the name of the file is)
- When it's an internal package the value will be : "/fully/qualified/path/of/package/internalPackage.usdz" (where this is the path on disk or would be the path on disk of the internal package.
I think this is less of an issue now that you've reminded me of 2. (Thanks!) but I wanted to point it out as the error messages are different in these cases where sometimes the fully qualified path is there and other times it's not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, yeah I think I can reason about that (will also confirm internally), but the reference path to internal package gets fully resolved relative to its referenced location, in order to locate the asset, and that causes the paths to be absolute.
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just couple of more small notes to be addressed; will sync in when done. Thanks Andy
- don't unnecessarily capture assets & unresolvedPaths for this validator - fixed a missing const
Description of Change(s)
Link to proposal (if applicable)
Fixes Issue(s)
Note: This PR is a replacement for #3400
Checklist
[X] I have created this PR based on the dev branch
[X] I have followed the coding conventions
[X] I have added unit tests that exercise this functionality (Reference:
testing guidelines)
[X] I have verified that all unit tests pass with the proposed changes
[X] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)