Cached playback is a new feature that is available in Maya 2019, and it’s a major performance upgrade from previous releases. However, sometimes with new features, you may run into some issues while developing your plugins.
Our engineers are actively working on building the Cached Playback API in C++ and Python which will make it easier to deal with the common issues that plugin developers are running into, and you will see those improvements in the future.
Here are a couple of common problems and how to handle them.
Unsupported Nodes
One of the limitations to the cached playback is the list of unsupported nodes. If your scene contains any unsupported nodes, it will trigger Safe Mode which will disable caching for you and notifies you automatically. Unfortunately, this only applies to built-in nodes in Maya. For custom node plugins that are unsupported and does not interact well with cached playback, you have to do the inconvenient work by manually disabling the cache and printing your own message.
The workaround for this issue is to have your plugin disable caching by executing the following command when the plugin gets loaded or when plugin node gets created. Then print your own warning message.
cmds.evaluator(name=’cache’, enable=0)
NOTE: Unlike Safe Mode, this workaround does not prevent the user from enabling cached playback again. So be aware that the user can still manually turn on cached playback and possibly corrupting the entire scene.
Shape Nodes Not Caching
If you are developing a custom shape node, you may encounter an issue where your node isn’t caching by default when cached playback is enabled. This is an expected behavior for now.
The workaround requires you to use the cacheEvaluator MEL/Python command to control caching configuration. Even though the C++/Python API is not out yet, the cacheEvaluator command encapsulates the API for cached playback. Using this command, you can configure the caching rules and add your custom shape node to support caching.
cmds.cacheEvaluator(
newFiler=’nodeTypes’,
newFilterParam=’types=+myCustomType’,
newAction=’enableEvaluationCache’
)
NOTE: This command must be re-executed every time the scene reopens, caching type changes, caching turns on and off, and caching rule resets.
To make it easier for your users, there is a hack that can make it more permanent so that the user does not have to configure the caching rules themselves. Have your plugin edit the caching rules using the follow code when the plugin gets loaded. This way, your plugin will support caching right out of the box.
import maya.plugin.evaluator.CacheEvaluatorManager
# Define a new rule to enable Evaluation Cache on a custom node type.
new_rule_to_add = {
"newFilter": "nodeTypes",
"newFilterParam": "types=+myCustomType",
"newAction": "enableEvaluationCache"
}
# Add this rule to the built-in caching mode.
maya.plugin.evaluator.CacheEvaluatorManager.CACHE_STANDARD_MODE_EVAL.insert(0, new_rule_to_add)
The default built-in caching modes used by Maya are defined in Python\Lib\site-packages\maya\plugin\evaluator\CacheEvaluatorManager.py. They are:
- CACHE_STANDARD_MODE_VP2_HW
- CACHE_STANDARD_MODE_VP2_SW
- CACHE_STANDARD_MODE_EVAL
Hopefully these common issues can be resolved and improved when the Cached Playback API becomes available. For more information and details, you can check out the Cached Playback whitepaper.
Comments
You can follow this conversation by subscribing to the comment feed for this post.