Detected a blocking function. This will cause hitches or hangs in the UI. Please switch to the async version

I didn’t use to have this message in previous version of Isaac Sim but I get it in Isaac Sim 2023.1.0. Not sure exactly how to switch to asyn??
Detected a blocking function. This will cause hitches or hangs in the UI. Please switch to the async version

also, I clicked on Run button in Script Editor and it got stuck.

(update) took a long time to finalize but colors don’t seem right?? I get an error regarding MDL button of screen.

The script is:

import os

import omni
import omni.replicator.core as rep
from omni.isaac.core.utils.nucleus import get_assets_root_path
from pxr import Gf, Usd, UsdGeom

PALLET_URL = "/Isaac/Environments/Simple_Warehouse/Props/SM_PaletteA_01.usd"
ENV_URL = "/Isaac/Environments/Simple_Warehouse/full_warehouse.usd"

assets_root_path = get_assets_root_path()
omni.usd.get_context().open_stage(assets_root_path + ENV_URL)
stage = omni.usd.get_context().get_stage()
floor_prims_paths = [prim.GetPath() for prim in stage.Traverse() if "SM_floor" in prim.GetName()]

floor_prims = []
for floor_prim_path in floor_prims_paths:
    floor_prims.append(omni.usd.get_prim_at_path(floor_prim_path))

def compute_bbox_with_cache(cache: UsdGeom.BBoxCache, prim: Usd.Prim) -> Gf.Range3d:
    bound = cache.ComputeWorldBound(prim)
    bound_range = bound.ComputeAlignedBox()
    return bound_range


bbcache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ["default", "render"])
bb = compute_bbox_with_cache(bbcache, floor_prims[0])
max_x, max_y, max_z = bb.GetMax()
min_x_arr = []
min_y_arr = []
min_z_arr = []
max_x_arr = []
max_y_arr = []
max_z_arr = []

for floor_prim in floor_prims:
    tmp_bb = compute_bbox_with_cache(bbcache, floor_prim)
    tmp_min_x, tmp_min_y, tmp_min_z = tmp_bb.GetMin()
    tmp_max_x, tmp_max_y, tmp_max_z = tmp_bb.GetMax()
    min_x_arr.append(tmp_min_x)
    min_y_arr.append(tmp_min_y)
    min_z_arr.append(tmp_min_z)
    max_x_arr.append(tmp_max_x)
    max_y_arr.append(tmp_max_y)
    max_z_arr.append(tmp_max_z)


min_x = min(min_x_arr)
min_y = min(min_y_arr)
min_z = min(min_z_arr)
max_x = max(max_x_arr)
max_y = max(max_y_arr)
max_z = max(max_z_arr)
margin = 3


camera = rep.create.camera()
render_product = rep.create.render_product(camera, resolution=(1024, 1024))

writer = rep.WriterRegistry.get("BasicWriter")
out_dir = os.path.join(os.getcwd(), "_out_scattered_pallets_warehouse")
writer.initialize(output_dir=out_dir, rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])

with rep.trigger.on_frame(num_frames=50):
    pallets = rep.create.from_usd(PALLET_URL, semantics=[("class", "pallet")], count=10)
    pallets_paths = [prim.GetPath() for prim in pallets.get_output_prims()["prims"]]
    print(f"pallets_paths: {pallets_paths}")
    with pallets:
        rep.physics.collider()
        floor_paths_as_str = [str(path) for path in floor_prims_paths]
        rep.randomizer.scatter_2d(surface_prims=floor_paths_as_str, check_for_collisions=True),
    with camera:
        rep.modify.pose(
            position=rep.distribution.uniform((min_x + margin, min_y + margin, 4), (max_x - margin, max_y - margin, 7)),
            look_at=pallets_paths,
        )

from ValueError: Unable to set target prim of type <class 'pxr.Usd.Prim'> in Isaac Sim Script Editor - #5 by ahaidu

my bad, I forgot to connect the Nucleus. However, I notice despite 48GB VRAM, it was very slow to load the factory. Is it possible to speed that up?

The async message is a warning and can be ignored, future versions will switch such blocking functions to async ones making the UI responsive while executing such tasks.

The amount of VRAM does not effect loading times. Is the loading slow after the initial one as well? If yes, was it faster in previous versions?

1 Like

no it wasn’t faster. Just thought much better specs may accelerate the app.

@ahaidu I am in the process of switching from the previous IsaacSim2022 to Isaacim2023. What I’ve noticed, aside from the blocking warning which I am also getting, is that the loading time for the simulation is much slower compared to the previous version. The complexity of the environment I am simulating is exactly the same and after having loaded the environment I didn’t notice performance degradation in the rt factor of the simulation. I am running on a RTX 3050 Laptop with 4GB of VRAM and 2048 cuda cores (which I’m aware it’s under the minimum requirements), using the 525.147.05 NVIDIA drivers. I don’t think the hardware is the issue though, since I tried the same env. on a much more powerful workstation, but with the same slow loading results.

Hi @AndrePatri - Do you have a local nucleus set up on your workstation?

Can you check with this script in the script editor if you have any difference between the two versions? I did not seem to have any. Tested under a windows laptop:

import asyncio
import time
import omni.kit.app
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import create_new_stage_async, open_stage_async

ENV = "/Isaac/Environments/Simple_Warehouse/full_warehouse.usd"
NUM_RUNS = 5

async def run_open_stage_async(num):
    assets_root_path = get_assets_root_path()
    for i in range(num):
        start_time = time.time()
        await create_new_stage_async()
        await open_stage_async(assets_root_path + ENV)
        for _ in range(10):
            await omni.kit.app.get_app().next_update_async()

        print(f"[{i}] Stage opened in: {time.time() - start_time} seconds..")

asyncio.ensure_future(run_open_stage_async(NUM_RUNS))

Results:

2023.1.0:
[0] Stage opened in: 35.077611446380615 seconds..
[1] Stage opened in: 24.954912662506104 seconds..
[2] Stage opened in: 25.34042978286743 seconds..
[3] Stage opened in: 24.800984144210815 seconds..
[4] Stage opened in: 24.431441068649292 seconds..


2022.2.1:
[0] Stage opened in: 35.8921856880188 seconds..
[1] Stage opened in: 26.742398738861084 seconds..
[2] Stage opened in: 26.188152074813843 seconds..
[3] Stage opened in: 26.192384004592896 seconds..
[4] Stage opened in: 26.39604663848877 seconds..

@rthaker I don’t. Should I? How do I set it up?

@ahaidu I’ll try and let you know.
By script editor what do you mean? Can’t I just run it as a normal python script?
Consider that right now I am running in a personal conda env with python 3.10 and I simply source Isaac’s setup_conda_env.sh on top of it. With 2022 I used to do the same. Don’t know if this can cause issues.
Btw, I am running on ubuntu 20.04 and a laptop RTX3050 GPU

1 Like

Here is a short intro on how you can run python code directly in the script editor:

Here is the standalone app version as well:

import time
from omni.isaac.kit import SimulationApp

simulation_app = SimulationApp(launch_config={"headless": False})

from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import create_new_stage, open_stage

ENV = "/Isaac/Environments/Simple_Warehouse/full_warehouse.usd"
NUM_RUNS = 5

def run_open_stage(num):
    assets_root_path = get_assets_root_path()
    for i in range(num):
        start_time = time.time()
        create_new_stage()
        open_stage(assets_root_path + ENV)
        for _ in range(10):
            simulation_app.update()
        print(f"[{i}] Stage opened in: {time.time() - start_time} seconds..")

run_open_stage(NUM_RUNS)

while simulation_app.is_running():
    simulation_app.update()
simulation_app.close()

@ahaidu I run the test and I don’t see relevant differences in the printed scene loading times (around 25/26 s).
I think the delay I am seeing is related to something different.
My script blocks and stays a lot of time on this output

2023-11-06 14:10:19 [36,807ms] [Warning] [omni.client.python] Detected a blocking function. This will cause hitches or hangs in the UI. Please switch to the async version:
  File "/home/username/LRhcExamples/lrhc_examples/scripts/play.py", line 93, in <module>
  File "/home/username/LRhcExamples/lrhc_examples/envs/lrhcenv.py", line 36, in set_task
  File "/home/username/OmniRoboGym/omni_robo_gym/gym/omni_vect_env/vec_envs.py", line 254, in set_task
  File "/home/username/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/world/world.py", line 276, in reset
  File "/home/username/OmniRoboGym/omni_robo_gym/tasks/custom_task.py", line 780, in set_up_scene
  File "/home/username/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/scenes/scene.py", line 225, in add_default_ground_plane
  File "/home/username/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/utils/nucleus.py", line 504, in get_assets_root_path
  File "/home/username/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/utils/nucleus.py", line 191, in check_server
  File "/home/username/.local/share/ov/pkg/isaac_sim-2023.1.0/kit/extscore/omni.client/omni/client/__init__.py", line 161, in stat

which does not happen with isaac2022

Hi here is an explanation from github about the blocking function issue

I found a solution without requiring the installation of a local nucleus server
You should have the omniverse cache installed

you can edit this file
/home/*/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/utils/nucleus.py
change lines 178 to 198 which is the check server function to below

def check_server(server: str, path: str) -> bool:
    """Check a specific server for a path

    Args:
        server (str): Name of Nucleus server
        path (str): Path to search

    Returns:
        bool: True if folder is found
    """
    carb.log_info("Checking path: {}{}".format(server, path))
    # Increase hang detection timeout
    if "localhost" not in server:
        omni.client.set_hang_detection_time_ms(10000)
        result, _ = omni.client.stat("{}{}".format(server, path))
        if result == Result.OK:
            carb.log_info("Success: {}{}".format(server, path))
            return True
    carb.log_info("Failure: {}{} not accessible".format(server, path))
    return False

For Clarity see the side by side comparison

Isaac Sim 2023.1.0 now loads in 10 seconds on my system with no nucleus local server needed

2 Likes

Thanks a lot @sujitvasanth, this solves the issue for me.

1 Like

very glad to help!.. they seem to have aysncio in the pipeline for the next version so will not be needed once that is in place

I have encountered similar problems in the version of isaac_sim-2023.1.0-hotfix.1, and I have tried the methods mentioned above. But the loading time is still very long.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.