mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

viewer.update_texture() blocks windows.is_running()

Open vikashplus opened this issue 1 year ago • 0 comments

Intro

MuJoCo advanced user

My setup

MuJoCo 3.2.4, mac os

What's happening? What did you expect?

Repeated calls to update textures window.update_texture(tex.id) blocks window.is_running()

https://github.com/user-attachments/assets/2de47075-997b-4d0c-9086-47084b1188ee

cc @saran-t

Steps for reproduction

  1. Run the code below.
  2. close the viewer()
  3. execution hangs without exit

Minimal model for reproduction

import time

from mujoco import viewer

XML = r"""
<mujoco>

    <asset>
        <texture name="tex_rgb" builtin="gradient" type="2d" mark="edge" height="480" width="640" rgb1=".3 .4 .5"/>
        <material name="tex_rgb" reflectance="0.05" texture="tex_rgb" texrepeat="1 1" texuniform="false"/>
    </asset>

    <worldbody>
        <geom type="plane" size="5 5 2" rgba="1 1 1 1" material="tex_rgb"/>
    </worldbody>
</mujoco>
"""
mj_model = mujoco.MjModel.from_xml_string(XML)
mj_data = mujoco.MjData(mj_model)
tex = mj_model.tex("tex_rgb")

window = viewer.launch_passive(
    mj_model,
    mj_data,
    show_left_ui=False,
    show_right_ui=False,
)

while window.is_running():
    mujoco.mj_step(mj_model, mj_data)
    window.update_texture(tex.id)
    window.sync()
    time.sleep(mj_model.opt.timestep)

print("Clean Exit")

Code required for reproduction

See above

Confirmations

vikashplus avatar Jan 09 '25 19:01 vikashplus