isl-org / isl-org/Open3D

post_to_main_thread() delay

Open
#3,532 0 comments 0 reactions 1 assignee Claimed by @errissa View on GitHub
callback ui visualization
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

**Describe the bug**
Callbacks posted with `Application.post_to_main_thread()` are queued until the main thread is idle.

I want to react continuously to mouse move events but I only get updates when I stop moving the mouse.

**To Reproduce**
I started from https://github.com/intel-isl/Open3D/blob/master/examples/python/gui/mouse-and-point-coord.py
Here is a minimal example to reproduce the problem:
```python
import open3d.visualization.gui as gui
import open3d.visualization.rendering as rendering

def in_main():
print('in_main')

def render_callback(depth_image):
print('render_callback')
gui.Application.instance.post_to_main_thread(window, in_main)

def on_mouse(event):
print('on_mouse')
scene_widget.scene.scene.render_to_depth_image(render_callback)
return gui.Widget.EventCallbackResult.HANDLED

gui.Application.instance.initialize()
window = gui.Application.instance.create_window("Test", 100, 100)
scene_widget = gui.SceneWidget()
scene_widget.scene = rendering.Open3DScene(window.renderer)
window.add_child(scene_widget)
scene_widget.set_on_mouse(on_mouse)
gui.Application.instance.run()
```

The output is
```
on_mouse
render_callback
on_mouse
render_callback
on_mouse
render_callback
in_main
in_main
in_main
```

**Expected behavior**
I would expect posted callbacks to be called sooner, e.g.
```
on_mouse
render_callback
in_main
on_mouse
render_callback
in_main
on_mouse
render_callback
in_main
```

**Environment (please complete the following information):**

- Operating system: Windows 10 64-bit
- Python version: Python 3.8.8
- Open3D version: open3d-0.13.0-cp38-cp38-win_amd64
- Is this remote workstation?: no
- How did you install Open3D?: pip

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.