mitsuba-renderer/mitsuba3

[Bug] `mis_compensation` set true in envmap plugin exit the program

Start1er opened this issue · 5 comments

Hi:
I use your plugin envmap in my scene but the variance are very high, so I'm here to ask for help that how to use your envmap parameter mis_compensation the link https://mitsuba.readthedocs.io/en/stable/src/generated/plugins_emitters.html#:~:text=State%20parameters-,mis_compensation,-boolean which can use MIS to sample the light. I try to achieve in scene_params['env.mis_compensation'], but this seems not be a params can be achieved. I also try to specify in scene dict like the following:
'env': { 'type': 'envmap', 'scale':1, 'filename': './scene/texture/black_image.png', 'mis_compensation': True, },
it faied and program exit.
would you like to kindly help me how to use MIS in envmap or how to reduce the high variance when the envmap caused?

[ bug for envmap plugin ]

platform: Unbuntu 20.04

mitsuba version latest 3.5.2

I debug for this plugin and now I find the problem, it was a bug, and the following was my scene_dict:

scene_dict = {
    'type': 'scene',
    'integrator': {
        'type': prb_projective,
    },

    'env': {
        'type': 'envmap',
        'scale':1,
        'filename': './scene/texture/black_image.png',
        'mis_compensation': True,
    },
    'shape': {
        'type': 'obj',
        'filename': "anything.obj",
            'bsdf': {
                'type': 'principled',
                'base_color': {
                    'type': 'bitmap',
                    'filename': './scene/texture/BRDF_resize/white_image.png',
                    'raw': False
                },
                'roughness': {
                    'type': 'bitmap',
                    'filename': './scene/texture/BRDF_resize/black_image.png',
                    'raw': True
                },
                'metallic': {
                    'type': 'bitmap',
                    'filename': './scene/texture/BRDF_resize/black_image.png',
                    'raw': True
                },
                'anisotropic':{
                    'type': 'bitmap',
                    'filename': './scene/texture/BRDF_resize/black_image.png',
                    'raw': True
                }
            }
        # }
    },

}

and when I run scene= mi.load_dict(scene_dict)
the bug arises in Ubuntu20.04 "Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)".
However, when I change the 'mis_compensation': True into False. It works actually but full of variance.
So I'm here to ask for help about this bug, seems like I can not change the params to do Multiple Inportance Sampling in envmap. But why it happened. I am troubled with its desired. Maybe this plugin I use it in a wrong way? Any response would be appreatiate.

Hi:
I try to debug mi.load_dict(scene), with the mis_compensation was setting to be true, use faulthander output the information in the following, it could help me debug how this plugin can not use mis_compensation. Note that this time I test in window laptop, also the same bug.
I might need help 😭

Windows fatal exception: access violation
Thread 0x00006740 (most recent call first):
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1004 in source_to_code
  File "<frozen importlib._bootstrap_external>", line 1074 in get_code
  File "<frozen importlib._bootstrap_external>", line 936 in exec_module
  File "<frozen importlib._bootstrap>", line 621 in _exec
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\importlib\__init__.py", line 169 in reload
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\mitsuba/python\ad\integrators\__init__.py", line 15 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 621 in _exec
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\importlib\__init__.py", line 169 in reload
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\mitsuba\__init__.py", line 315 in set_variant
Thread 0x000049a4 (most recent call first):
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 324 in wait
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 622 in wait
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\tqdm\_monitor.py", line 60 in run
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 1038 in _bootstrap_inner
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 995 in _bootstrap
Thread 0x000021f0 (most recent call first):
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 320 in wait
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_io.py", line 40 in read
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_transport.py", line 27 in read_request
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_transport.py", line 215 in read
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\transport\buffered\__init__.py", line 41 in _read
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\transport\base.py", line 12 in readall
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\transport\base.py", line 60 in read
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 168 in read_message_begin
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\protocol\binary.py", line 386 in read_message_begin
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 271 in process_in
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 315 in process
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_server.py", line 34 in handle
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 975 in run
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 1038 in _bootstrap_inner
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 995 in _bootstrap
Thread 0x00002010 (most recent call first):
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 320 in wait
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 622 in wait
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\history.py", line 903 in run
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\history.py", line 61 in only_when_enabled
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\decorator.py", line 232 in fun
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 1038 in _bootstrap_inner
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 995 in _bootstrap
Thread 0x00006b54 (most recent call first):
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_io.py", line 110 in readall
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_transport.py", line 45 in _read_frame
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_transport.py", line 37 in _read_and_dispatch_next_frame
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_comm\pydev_transport.py", line 64 in _read_forever
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 975 in run
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 1038 in _bootstrap_inner
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\threading.py", line 995 in _bootstrap
Thread 0x00001de8 (most recent call first):
  File "test.py", line 174 in <module>
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18 in execfile
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197 in runfile
  File "<ipython-input-2-d388c9517942>", line 1 in <module>
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\interactiveshell.py", line 3577 in run_code
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\interactiveshell.py", line 3517 in run_ast_nodes
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\interactiveshell.py", line 3334 in run_cell_async
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\async_helpers.py", line 128 in _pseudo_sync_runner
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\interactiveshell.py", line 3130 in _run_cell
  File "C:\Users\jj\anaconda3\envs\mitsuba\Lib\site-packages\IPython\core\interactiveshell.py", line 3075 in run_cell
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 438 in add_exec
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_ipython_console.py", line 34 in do_add_exec
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_code_executor.py", line 109 in add_exec
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\pydevconsole.py", line 287 in process_exec_queue
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\pydevconsole.py", line 498 in start_client
  File "C:\Program Files\JetBrains\PyCharm 2024.1.2\plugins\python\helpers\pydev\pydevconsole.py", line 570 in <module>
Process finished with exit code -1073741819 (0xC0000005)



Hi @Start1er

I'm unable to reproduce this, I've tried many different variations of the script you've provided. The only oddity that comes to mind is the following line 'type': prb_projective,, it should be 'type': 'prb_projective',. Could you provide us with a complete minimal reproducer?

I think you will have to compile mitsuba yourself in Debug mode to figure what is causing the error.

Hi @njroussel :
Thanks for your patient answers, your are right, in debug mode where I find was the envmap res was high which might cause the memory access error, downsampling the envmap will work! Not a bug, just the computation was high when in high res envmap using mis_compensation = true ! Debugging such a large framework is hard for me, but after I find the reason, I'm proud of myself. 😂 Now maybe I'm not an API loader. Anyway thanks for your suggestion!

🎉 congratulations

I'm surprised you didn't get a more explicit error message, though.