In TouchDesigner, the “on cook” error typically indicates that something is wrong with how the node is being processed during cooking, even if the script appears to be functioning correctly. Cooking refers to the process of recalculating or reprocessing a node when changes occur.
To troubleshoot the “on cook” error, consider these potential issues and solutions:
Even though your script works fine, there could still be hidden errors that show up during the cooking process.
- Check for syntax errors or warnings in the script. Even minor issues, like unused variables or undefined operations, can sometimes trigger errors.
- Ensure that all functions and methods are properly defined and called, and there are no unnecessary loops or operations causing performance issues during the cooking.
The error may be caused by the script attempting to access or modify data that is not available at the time of cooking.
- Check for unresolved references to other nodes or variables. If the script depends on external nodes or data that may not be available at all times, the script could throw an error during cooking.
- Use error handling (
try/except) to handle cases where references may be undefined.
If your script performs operations that take a long time or cause recursion, this might cause cooking issues.
- Check for infinite loops or recursive operations that could be causing delays in the cooking process.
- Optimize performance by reducing the complexity of your script where possible. Ensure that resource-heavy operations are minimized.
The “on cook” error could be linked to a node being forced to cook when it doesn’t need to.
- Check the node’s cook dependencies: Make sure the nodes your script is operating on are being properly cooked and that you’re not accidentally forcing unnecessary recooks.
You can debug the cooking process by:
- Turning on the cook time monitor in TouchDesigner (
Right-click on the node > Parameters > Turn on Time Info). This will help you track the node’s cook time and identify which part of the process might be causing delays or errors.
- Use print statements to display values at various points in the script to check for unexpected behavior during cooking.
TouchDesigner often performs better with expressions or node-based methods rather than heavy Python scripts. If possible, use more TouchDesigner-native expressions for certain calculations rather than relying solely on Python scripting.
By following these troubleshooting steps, you should be able to identify what’s causing the “on cook” error and optimize the script to prevent it.
Let me know if you need further assistance or specific code debugging!