This might not necessarily be a bug, but may be a feature request. I apologize in advance for being very unprofessional here. I don't think my problem is necessarily relevant to the way I build Blender of the system hardware I use. I've seen the same problem over and over on different systems. Anyways, I compile Blender from source as follow on a freshly-installed Ubuntu:
Here's how I set up Ubuntu after installing it:
apt-get -y update && apt-get -y install locales \ make \ dpkg \ wget \ bzip2 \ libglib2.0-0 \ libxext6 \ libsm6 \ libxrender1 \ g++ \ gcc \ xvfb \ libyaml-cpp-dev \ git \ cmake \ vim \ curl \ ca-certificates \ software-properties-common \ python3 \ python3-pip
git clone https://git.blender.org/blender.git cd blender git checkout 8ef39d5c882896bd75e0d4d17fb3e3d4710fc768 # Blender 2.79 git submodule update --init --recursive git submodule foreach git checkout master git submodule foreach git pull --rebase origin master blender/build_files/build_environment/install_deps.sh --source=/blender-git/ PPATH="$(which python3)" cmake blender \ -DCMAKE_INSTALL_PREFIX=/usr/lib/python3/dist-packages \ -DWITH_INSTALL_PORTABLE=OFF \ -DWITH_PYTHON_INSTALL=OFF \ -DWITH_PYTHON_MODULE=ON \ -DPYTHON_SITE_PACKAGES=/usr/lib/python3/dist-packages \ -DPYTHON_VERSION=3.5 \ -DWITH_OPENAL=ON \ -DWITH_CODEC_AVI=ON \ -DWITH_MOD_OCEANSIM=ON \ -DWITH_CODEC_FFMPEG=ON \ -DWITH_SYSTEM_GLEW=ON \ -DWITH_FFTW3=ON \ -DWITH_OPENCOLORIO=ON \ -DWITH_GAMEENGINE=OFF \ -DWITH_PLAYER=OFF make -j 7 make install
I want to do a very simple thing but it seems that it's becoming very complicated to do it. I have described what my problem is here. I do not necessarily want to simulate clicking but it turns out that I cannot update the contents of 'Viewer Node' image block. Finally, I thought the best way would be to automatically have backdrop enabled. So I followed the instructions given here by Sebastian Koch thinking that I should be able to dynamically add/remove view nodes and update the contents of the image block automatically. Although I could access to the pixels, but But this does not happen!
I wrote the right code to do exactly what I show in this video but the pixels in "Viewer Node" image block do not get updated, as they do in the video. Not only that, I tried activating newly-added Viewer nodes manually (as described here) but I am still unsuccessful in updating the pixels in the image block. I also tried removing the image block in Python and then continue adding new Viewer nodes. But from the time I remove the image block its contents will always be zero even if I redo the rendering.
The only way I could successfully update the contents of the image block was after, first, I followed Sebastian Koch's solution and then wrote some code to remove/add all nodes and their links to get either depth map or surface Normals and did the rendering again. But the whole point of me trying to store pixels into Numpy arrays was to avoid doing re-rendering to get around the IO overhead. I could have instead stored two files (for both depth map and Normal maps) throught two Output nodes with rendering only once.
First, if this behavior does not look like a bug, I would appreciate the community provide me an easy solution to do what I want. Second, It would be great if you can improve Blender's Python API and add ways of easily accessing rendering results in memory so that people like me who want to do millions of rendering do not need to deal with the delays cause by IO to transfer rendering results from memory to hard drive and can easily store the results into Numpy arrays and store them on disk in chunks.