Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding lock for Viser Element callbacks #3067

Merged
merged 8 commits into from
Apr 26, 2024

Conversation

Satvik1701
Copy link
Contributor

I added a wrapper around the viser element callback so the render thread is blocked while the callback is called to avoid crashing. I also added a lock in run_viewer.py so this issue is addressed for both ns-train and ns-viewer.

Test: I added time.sleep() in the callback and confirmed the render thread was blocked.

@jb-ye
Copy link
Collaborator

jb-ye commented Apr 11, 2024

What kinds of crash did you see? I also experienced crashes (#3064 ) in the viser viewer.

@kerrj
Copy link
Collaborator

kerrj commented Apr 11, 2024

This PR fixes a bug with a race condition in custom viewer element callbacks (eg a ViewerButton which renders the current view), previously this might clash with the standard rendering thread and crash the callback or main renderer.

Copy link
Collaborator

@kerrj kerrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@@ -209,12 +211,19 @@ def __init__(
# Keep track of the pointers to generated GUI folders, because each generated folder holds a unique ID.
viewer_gui_folders = dict()

def prev_cb_wrapper(prev_cb):
def cb_lock(element):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a docstring describing why this is being done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and maybe explain the logic a bit since functors can be confusing

@kerrj kerrj merged commit 3f39546 into nerfstudio-project:main Apr 26, 2024
2 checks passed
Michael-Spleenlab pushed a commit to Michael-Spleenlab/nerfstudio that referenced this pull request Apr 26, 2024
* add callback lock, prepare for testing

Co-authored-by: Justin Kerr <justin.g.kerr@gmail.com>
@jb-ye
Copy link
Collaborator

jb-ye commented Apr 30, 2024

@kerrj I found this PR impacts the experience of ns-viewer when training gaussian splatting. The delay when I rotate the scene is so long that basically disallow me to interact with the scene. Do you observe similar issue?

@kerrj
Copy link
Collaborator

kerrj commented May 1, 2024

That's odd I don't notice any difference. In fact it shouldn't affect things since the only code that was added to the lock was viser element callbacks, which splatfacto doesn't have any of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants