NodeDef Lookup Order is OS Dependent
When selecting a nodedef, the following cache is used:
std::unordered_multimap<string, NodeDefPtr> nodeDefMap;
Looking up the first matching nodedef in this cache is unfortunately OS dependent. Why? The unordered_multimap has no strict rules associated with the order of identical keys and it looks like Linux adds keys to the front while Windows adds to the back when the keys are the same. As a result lookups are OS dependent.
Recommendation:
Change to: unordered_map<std::string, std::vector<NodeDefPtr>> to maintain the declaration order found in the library.
This is a great catch, @feldstj, and it sounds very worthwhile to fix this.
For developers who are less familiar with this area of the code, here's a link to the unordered multimap that you're referencing in this issue:
https://github.com/AcademySoftwareFoundation/MaterialX/blob/36be87205ee01e6f81dc26b8fe7c79ba5d6c840b/source/MaterialXCore/Document.cpp#L158
If you have the bandwidth, feel free to propose a pull request with the fix you describe above; otherwise, we'll plan to take a look at this on our side.
Hey @jstone-lucasfilm, unfortunately I'm pretty swamped at the moment. If one of you guys could look into it, I'd really appreciate it. Thanks.
Thanks for this recommendation, @feldstj, and this has now been addressed in #1753.