How to use world.step() when doing standalone domain randomization

I have made a very simple standalone Python app with domain randomization, but I’m unsure about how I should be using world.step() (or some other method) when capturing the ground truth.

If I don’t add a world.step(), or only 1 or 2 calls I get this RGB ground truth with some rendering artefacts:

When I add a 3rd call it’s correct (sometimes with 2 calls it’s also correct):

How should I be using world.step() to ensure I capture the ground truth correctly? Or should I be using some other method? Full code is here:

import numpy as np
from PIL import Image
from omni.isaac.kit import SimulationApp

app = SimulationApp({"headless": True})

import omni
from omni.isaac.core import World
from omni.isaac.core.utils.prims import create_prim
from omni.isaac.synthetic_utils import SyntheticDataHelper
from omni.kit.viewport import get_default_viewport_window
import omni.isaac.dr as dr

world = World(stage_units_in_meters=0.01)

create_prim(
    "/World/Camera",
    "Camera",
    position=np.array([0.0, 0.0, 100.0])
)
create_prim(
    "/World/Light",
    "SphereLight",
    position=np.array([100, 0, 200]),
    attributes={
        "radius": 50,
        "intensity": 5e4,
        "color": (1.0, 1.0, 1.0)
    }
)
create_prim(
    "/World/Cube",
    "Cube",
    scale=np.array([10.0, 10.0, 10.0]),
    attributes={"primvars:displayColor": [(0.28, 0.65, 1.0)]},
)

dr.commands.CreateRotationComponentCommand(
    prim_paths=["/World/Cube"],
    min_range=(0.0, 0.0, 0.0),
    max_range=(0.0, 0.0, 360.0)
).do()

viewport = get_default_viewport_window()
viewport.set_active_camera("/World/Camera")
viewport.set_texture_resolution(1024, 1024)
sd_helper = SyntheticDataHelper()

sd_helper.initialize(sensor_names=["rgb"], viewport=viewport)

dr.commands.ToggleManualModeCommand().do()
dr.commands.RandomizeOnceCommand().do()
world.step()
world.step()
world.step()

ground_truth = sd_helper.get_groundtruth(
    ["rgb"],
    viewport, verify_sensor_init=True
)
image = Image.fromarray(ground_truth["rgb"])
image.save("rgb.png")

app.close()

Thanks!