Hi, I’m developing a ArResolver subclass that also implements contexts. Part of our implementation handles “querystring” like arguments:
scheme:/asset+foo=bar
The arguments are a cue to our asset system on how to resolve “asset”. Things work well if you explicitly bind an ArResolverContext up front:
from pxr import Ar, Usd
uri = "scheme:/asset+foo=bar"
ctx = Ar.CreateDefaultContextForAsset(uri)
with Ar.ResolverContextBinder(ctx):
Usd.Stage.Open(uri)
In this mode, our custom ArResolverContext gets created and knows about the “foo=bar” setting. The ArResolver can reference it and works great.
However, things work differently when I don’t bind the resolver context:
Usd.Stage.Open(uri)
If I trace through the calls, what I see is:
_CreateIdentifier('scheme:/asset+foo=bar', '')
_Resolve('scheme:/asset+foo=bar', '')
_IsContextDependentPath('scheme:/asset+foo=bar')
_GetAssetInfo('scheme:/asset+foo=bar', '<resolved path here>')
_IsContextDependentPath('scheme:/asset+foo=bar')
_GetModificationTimestamp('scheme:/asset+foo=bar', '<resolved path here>')
_CreateDefaultContextForAsset('<resolved path here>')
Where I think things go wrong are that final _CreateDefaultContextForAsset()
. At this point I’ve lost the “foo=bar” setting unless I store it globally in one of the prior steps.
I can see this above behavior in usdcat for example, but not usdview. DCC plugins like Maya and Katana seem to behave like they are calling Usd.Stage.Open()
too, with no context bound.
I traced that _CreateDefaultContextForAsset()
call to the _CreatePathResolverContext()
function.
Cheekily, I modified my asset resolver to set the repoPath
in _GetAssetInfo()
to the assetPath
I’m given there. This works more like I expected it to, but I realize I shouldn’t be doing that since it’s deprecated.
Is it generally expected studios should always be binding a resolver context if they are writing a custom resolver? Is there a way I should be implementing my resolver or initializing my DCC runtime to handle this better?
I’m curious how practically that works in apps like Maya and Katana. In Houdini, I know there are special fields for initializing a resolver context.