<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Update nodes between rendering cause segmentation fault in Arnold General Rendering Forum</title>
    <link>https://forums.autodesk.com/t5/arnold-general-rendering-forum/update-nodes-between-rendering-cause-segmentation-fault/m-p/12439419#M255</link>
    <description>&lt;P&gt;When reading &lt;A href="https://help.autodesk.com/view/ARNOL/ENU/?guid=arnold_dev_guide_examples_av_Updating+and+Re_Rendering+With+Python_html" target="_blank" rel="noopener"&gt;the official example for arnold python api&lt;/A&gt;,&amp;nbsp; I notice that the example deletes all relevant nodes before replacing them with the new ones. I was wondering if it is possible to just update the parameters of those nodes between frames using `AiNodeSetXXX`? (However, a segmentation fault is generated in this process, I do not know whether this is the correct way to do so)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A minimum working example:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;ai.h&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;filesystem&amp;gt;

namespace fs = std::filesystem;

int main() {
	const fs::path ass_path = "test.ass";

	AiBegin();
	auto universe = AiUniverse();
	auto session = AiRenderSession(universe, AI_SESSION_BATCH);
	
	auto load_ass_param = AiParamValueMap();
	AiParamValueMapSetInt(load_ass_param, AtString("mask"), AI_NODE_ALL);

	AiSceneLoad (universe, ass_path.c_str(), load_ass_param);

	AiMsgInfo("Finish rendering");
	/* preprocess */

	AiRender(session);
	
	AtArray* vlist = AiArrayAllocate(8, 1, AI_TYPE_VECTOR);
    AiArraySetVec(vlist, 0, AtVector(0.200000003, -0.200000003, 0.200000003));
    AiArraySetVec(vlist, 1, AtVector(0.200000003, -0.200000003, -0.200000003));
    AiArraySetVec(vlist, 2, AtVector(-0.200000003, -0.200000003, 0.200000003));
    AiArraySetVec(vlist, 3, AtVector(-0.200000003, -0.200000003, -0.200000003));
    AiArraySetVec(vlist, 4, AtVector(0.200000003, 0.200000003, 0.200000003));
    AiArraySetVec(vlist, 5, AtVector(0.200000003, 0.200000003, -0.200000003));
    AiArraySetVec(vlist, 6, AtVector(-0.200000003, 0.200000003, 0.200000003));
    AiArraySetVec(vlist, 7, AtVector(-0.200000003, 0.200000003, -0.200000003));
	
	auto node = AiNodeLookUpByName(universe, AtString("/cube:Mesh/cube:MeshShape"));
	AiNodeSetArray(node, AtString("vlist"), vlist);
	// auto new_node = AiNodeClone(node);
	// AiNodeSetArray(new_node, AtString("vlist"), vlist);
	// AiNodeReplace(node, new_node, true);

	AiRender(session);
	AiMsgInfo("Finish rendering");

	AiRenderSessionDestroy(session);
	AiUniverseDestroy(universe);
	AiEnd();

	return 0;
} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my test.ass is:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;### exported: Wed Dec 13 14:34:47 2023
### from:     Arnold 7.2.4.1 [1fee86c4] linux x86_64 clang-15.0.7 oiio-2.4.1 osl-1.12.9 vdb-7.1.1 adlsdk-7.4.2.47 clmhub-3.1.1.43 rlm-14.2.5 optix-6.6.0 2023/10/17 03:09:19
### host app: MtoA 5.3.4.1 4d32feb2 (fix-5.3.4) Maya 2024
### user: hansljy
### render_layer: defaultRenderLayer
### bounds: -0.2 -0.2 -0.2 0.2 0.2 0.2
### meters_per_unit: 0.010000



options
{
 AA_samples 3
 AA_seed 300
 outputs "RGBA RGBA defaultArnoldFilter/gaussian_filter defaultArnoldDriver/driver_exr.RGBA"
 xres 960
 yres 540
 texture_per_file_stats on
 texture_searchpath "/home/hansljy/maya/projects/textures/sourceimages"
 texture_automip off
 camera "/persp/perspShape"
 color_manager "defaultColorMgtGlobals"
 meters_per_unit 0.xxx-xxxxxxxx
 frame 300
 procedural_searchpath "/home/hansljy/maya/projects/textures/"
 GI_diffuse_depth 1
 GI_specular_depth 1
 GI_transmission_depth 8
 declare render_layer constant STRING
 render_layer "defaultRenderLayer"
 enable_dependency_graph true
}

gaussian_filter
{
 name defaultArnoldFilter/gaussian_filter
}

driver_exr
{
 name defaultArnoldDriver/driver_exr.RGBA
 filename "/home/hansljy/maya/projects/textures/images/untitled.exr"
 color_space ""
}

color_manager_ocio
{
 name defaultColorMgtGlobals
 config "/usr/autodesk/maya/resources/OCIO-configs/Maya2022-default/config.ocio"
 color_space_linear "ACEScg"
}

persp_camera
{
 name /persp/perspShape
 matrix
 0.719401479 0.694594502 0 0
 -0.320911646 0.332372785 0.886873186 0
 0.616017222 -0.638017893 0.462012947 0
 6.23699188 -6.45974159 4.67774391 1
 near_clip 0.100000001
 far_clip 10000
 shutter_start 0
 shutter_end 0
 shutter_type "box"
 rolling_shutter "off"
 rolling_shutter_duration 0
 motion_start 0
 motion_end 0
 exposure 0
 fov 54.4322243
 uv_remap 0 0 0 1
 declare dcc_name constant STRING
 dcc_name "perspShape"
}

polymesh
{
 name /cube:Mesh/cube:MeshShape
 visibility 255
 sidedness 255
 matrix
 1 0 0 0
 0 1 0 0
 0 0 1 0
 0 0 0 1
 shader "standardSurface1"
 id 3745223389
 nsides 12 1 UINT
  3 3 3 3 3 3 3 3 3 3 3 3
 vidxs 36 1 UINT
  4 2 0 2 7 3 6 5 7 1 7 5 0 3 1 4 1 5 4 6 2 2 6 7 6 4 5 1 3 7 0 2 3 4 0 1
 nidxs 36 1 UINT
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  31 32 33 34 35
 vlist 8 1 VECTOR
0.200000003 -0.200000003 0.200000003 0.200000003 -0.200000003 -0.200000003 -0.200000003 -0.200000003 0.200000003
  -0.200000003 -0.200000003 -0.200000003 0.200000003 0.200000003 0.200000003 0.200000003 0.200000003 -0.200000003
  -0.200000003 0.200000003 0.200000003 -0.200000003 0.200000003 -0.200000003
 nlist 36 1 VECTOR
  0 0 1 0 0 1 0 0 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0 0 1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0
  0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0
  0 1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0
 smoothing on
 disp_padding 0
 disp_height 1
 disp_zero_value 0
 disp_autobump off
 autobump_visibility 1
 step_size 0
 volume_padding 0
 declare dcc_name constant STRING
 dcc_name "cube:MeshShape"
}

standard_surface
{
 name standardSurface1
 base_color 0.400000006 0.400000006 0.400000006
 specular_roughness 0.5
 transmit_aovs on
 normal 1 1 1
 tangent 1 1 1
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program will crash on the second render call:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;00:00:00   129MB         | [ass] loading test.ass ...
00:00:00   129MB         | [ass] read 3212 bytes, 7 nodes in 0:00.00
00:00:00   129MB         | Finish rendering
00:00:00   227MB         | parameter vlist on /cube:Mesh/cube:MeshShape was modified - reinitializing node
[1]    138736 segmentation fault (core dumped)  ./test&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 13 Dec 2023 21:55:43 GMT</pubDate>
    <dc:creator>u6046121</dc:creator>
    <dc:date>2023-12-13T21:55:43Z</dc:date>
    <item>
      <title>Update nodes between rendering cause segmentation fault</title>
      <link>https://forums.autodesk.com/t5/arnold-general-rendering-forum/update-nodes-between-rendering-cause-segmentation-fault/m-p/12439419#M255</link>
      <description>&lt;P&gt;When reading &lt;A href="https://help.autodesk.com/view/ARNOL/ENU/?guid=arnold_dev_guide_examples_av_Updating+and+Re_Rendering+With+Python_html" target="_blank" rel="noopener"&gt;the official example for arnold python api&lt;/A&gt;,&amp;nbsp; I notice that the example deletes all relevant nodes before replacing them with the new ones. I was wondering if it is possible to just update the parameters of those nodes between frames using `AiNodeSetXXX`? (However, a segmentation fault is generated in this process, I do not know whether this is the correct way to do so)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A minimum working example:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;ai.h&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;filesystem&amp;gt;

namespace fs = std::filesystem;

int main() {
	const fs::path ass_path = "test.ass";

	AiBegin();
	auto universe = AiUniverse();
	auto session = AiRenderSession(universe, AI_SESSION_BATCH);
	
	auto load_ass_param = AiParamValueMap();
	AiParamValueMapSetInt(load_ass_param, AtString("mask"), AI_NODE_ALL);

	AiSceneLoad (universe, ass_path.c_str(), load_ass_param);

	AiMsgInfo("Finish rendering");
	/* preprocess */

	AiRender(session);
	
	AtArray* vlist = AiArrayAllocate(8, 1, AI_TYPE_VECTOR);
    AiArraySetVec(vlist, 0, AtVector(0.200000003, -0.200000003, 0.200000003));
    AiArraySetVec(vlist, 1, AtVector(0.200000003, -0.200000003, -0.200000003));
    AiArraySetVec(vlist, 2, AtVector(-0.200000003, -0.200000003, 0.200000003));
    AiArraySetVec(vlist, 3, AtVector(-0.200000003, -0.200000003, -0.200000003));
    AiArraySetVec(vlist, 4, AtVector(0.200000003, 0.200000003, 0.200000003));
    AiArraySetVec(vlist, 5, AtVector(0.200000003, 0.200000003, -0.200000003));
    AiArraySetVec(vlist, 6, AtVector(-0.200000003, 0.200000003, 0.200000003));
    AiArraySetVec(vlist, 7, AtVector(-0.200000003, 0.200000003, -0.200000003));
	
	auto node = AiNodeLookUpByName(universe, AtString("/cube:Mesh/cube:MeshShape"));
	AiNodeSetArray(node, AtString("vlist"), vlist);
	// auto new_node = AiNodeClone(node);
	// AiNodeSetArray(new_node, AtString("vlist"), vlist);
	// AiNodeReplace(node, new_node, true);

	AiRender(session);
	AiMsgInfo("Finish rendering");

	AiRenderSessionDestroy(session);
	AiUniverseDestroy(universe);
	AiEnd();

	return 0;
} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my test.ass is:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;### exported: Wed Dec 13 14:34:47 2023
### from:     Arnold 7.2.4.1 [1fee86c4] linux x86_64 clang-15.0.7 oiio-2.4.1 osl-1.12.9 vdb-7.1.1 adlsdk-7.4.2.47 clmhub-3.1.1.43 rlm-14.2.5 optix-6.6.0 2023/10/17 03:09:19
### host app: MtoA 5.3.4.1 4d32feb2 (fix-5.3.4) Maya 2024
### user: hansljy
### render_layer: defaultRenderLayer
### bounds: -0.2 -0.2 -0.2 0.2 0.2 0.2
### meters_per_unit: 0.010000



options
{
 AA_samples 3
 AA_seed 300
 outputs "RGBA RGBA defaultArnoldFilter/gaussian_filter defaultArnoldDriver/driver_exr.RGBA"
 xres 960
 yres 540
 texture_per_file_stats on
 texture_searchpath "/home/hansljy/maya/projects/textures/sourceimages"
 texture_automip off
 camera "/persp/perspShape"
 color_manager "defaultColorMgtGlobals"
 meters_per_unit 0.xxx-xxxxxxxx
 frame 300
 procedural_searchpath "/home/hansljy/maya/projects/textures/"
 GI_diffuse_depth 1
 GI_specular_depth 1
 GI_transmission_depth 8
 declare render_layer constant STRING
 render_layer "defaultRenderLayer"
 enable_dependency_graph true
}

gaussian_filter
{
 name defaultArnoldFilter/gaussian_filter
}

driver_exr
{
 name defaultArnoldDriver/driver_exr.RGBA
 filename "/home/hansljy/maya/projects/textures/images/untitled.exr"
 color_space ""
}

color_manager_ocio
{
 name defaultColorMgtGlobals
 config "/usr/autodesk/maya/resources/OCIO-configs/Maya2022-default/config.ocio"
 color_space_linear "ACEScg"
}

persp_camera
{
 name /persp/perspShape
 matrix
 0.719401479 0.694594502 0 0
 -0.320911646 0.332372785 0.886873186 0
 0.616017222 -0.638017893 0.462012947 0
 6.23699188 -6.45974159 4.67774391 1
 near_clip 0.100000001
 far_clip 10000
 shutter_start 0
 shutter_end 0
 shutter_type "box"
 rolling_shutter "off"
 rolling_shutter_duration 0
 motion_start 0
 motion_end 0
 exposure 0
 fov 54.4322243
 uv_remap 0 0 0 1
 declare dcc_name constant STRING
 dcc_name "perspShape"
}

polymesh
{
 name /cube:Mesh/cube:MeshShape
 visibility 255
 sidedness 255
 matrix
 1 0 0 0
 0 1 0 0
 0 0 1 0
 0 0 0 1
 shader "standardSurface1"
 id 3745223389
 nsides 12 1 UINT
  3 3 3 3 3 3 3 3 3 3 3 3
 vidxs 36 1 UINT
  4 2 0 2 7 3 6 5 7 1 7 5 0 3 1 4 1 5 4 6 2 2 6 7 6 4 5 1 3 7 0 2 3 4 0 1
 nidxs 36 1 UINT
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  31 32 33 34 35
 vlist 8 1 VECTOR
0.200000003 -0.200000003 0.200000003 0.200000003 -0.200000003 -0.200000003 -0.200000003 -0.200000003 0.200000003
  -0.200000003 -0.200000003 -0.200000003 0.200000003 0.200000003 0.200000003 0.200000003 0.200000003 -0.200000003
  -0.200000003 0.200000003 0.200000003 -0.200000003 0.200000003 -0.200000003
 nlist 36 1 VECTOR
  0 0 1 0 0 1 0 0 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0 0 1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0
  0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0
  0 1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0
 smoothing on
 disp_padding 0
 disp_height 1
 disp_zero_value 0
 disp_autobump off
 autobump_visibility 1
 step_size 0
 volume_padding 0
 declare dcc_name constant STRING
 dcc_name "cube:MeshShape"
}

standard_surface
{
 name standardSurface1
 base_color 0.400000006 0.400000006 0.400000006
 specular_roughness 0.5
 transmit_aovs on
 normal 1 1 1
 tangent 1 1 1
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The program will crash on the second render call:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;00:00:00   129MB         | [ass] loading test.ass ...
00:00:00   129MB         | [ass] read 3212 bytes, 7 nodes in 0:00.00
00:00:00   129MB         | Finish rendering
00:00:00   227MB         | parameter vlist on /cube:Mesh/cube:MeshShape was modified - reinitializing node
[1]    138736 segmentation fault (core dumped)  ./test&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 21:55:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/arnold-general-rendering-forum/update-nodes-between-rendering-cause-segmentation-fault/m-p/12439419#M255</guid>
      <dc:creator>u6046121</dc:creator>
      <dc:date>2023-12-13T21:55:43Z</dc:date>
    </item>
  </channel>
</rss>

