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

usdGenSchema collapses the authority component of URI asset paths when the associated path resolver is not registered #2480

Closed
nvmkuruc opened this issue Jun 7, 2023 · 1 comment

Comments

@nvmkuruc
Copy link
Collaborator

nvmkuruc commented Jun 7, 2023

Description of Issue

Consider the following schema.usda.

#usda 1.0
(
    subLayers = [
        @usd/schema.usda@
    ]
)

over "GLOBAL" (
    customData = {
        string libraryName = "mySchema"
        string libraryPath = "./"
        string libraryPrefix = "MySchema"
        bool skipCodeGeneration = true
    }
)
{
}

class "MyAPI"
(
    customData = {
        token apiSchemaType = "singleApply"
        string className = "MyAPI"
    }
    doc = "A test asset reference."
    inherits = </APISchemaBase>
)
{
    asset myApi:assetReference= @omni://1.2.3.4/path/to/file.txt@) (
        doc = """"""
    )
}

usdGenSchema uses UsdStage::Flatten and will try to anchor all asset paths. If an asset path refers to a URI resolver that isn't registered, the default resolver will treat the path like a file path and "normalize" away the //. For URIs, this effectively shifts the "authority" component into the "path" component of identifier.

There may be practical reasons why during usdGenSchema the asset and resolver may not be available. usdGenSchema depending on the availability of the resources required to run the resolvers used by attribute values may be unexpected.

If I suppress running SdfComputeAssetPathRelativeToLayer just for the omni: URI prefix in _AnchorAssetPathRelativeToLayer, the // is preserved.

Curiously, if I try to take advantage of "anchored paths" in my schema.usda file, it effectively resolves relative to the source directory. It doesn't seem like there's a use case for for the current anchoring behavior in usdGenSchema.

Steps to Reproduce

  1. Save the above layer to schema.usda
  2. Run the following code
>>> from pxr import Usd
>>> Usd.Stage.Open("./schema.usda").Flatten().ExportToString()
  1. You should see // collapsed into / for myApi:assetReference, effectively erasing the "authority" component.

System Information (OS, Hardware)

Observed on both Linux and Windows

Package Versions

Build Flags

--tests -no-imaging --no-materialx

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-8410

aaye pushed a commit to aaye/OpenUSD that referenced this issue Sep 24, 2023
…esolver is not registered to the resolver for the anchor layer. This can result in the path being modified by a resolver that does not have knowledge of how to deal with the particular path such as a layer loaded from disk referencing an asset located on a web server. This change adds an additional check to the path anchoring code used during USD stage flattening. In the case where an asset path has the same identifier created in both the non-anchored and anchored case, we will assume that this is an 'absolute' path and return it as is to avoid modification by the layer's resolver.

Fixes PixarAnimationStudios#2480

(Internal change: 2286000)
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

2 participants