Repository navigation
fix: Add GL context lock for server mode - #221
Merged
Merged
Conversation
LKasianAnsys
force-pushed
the
fix/add-gl-context-lock-for-server-mode
branch
from
November 16, 2026 19:04
a9576b7 to
4972654
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Resolves #220
Description
In SERVER mode,
remove_datasetwas causing a black canvas in the viewer, or a server crash. This is because removing an actor makes VTK make the GL context current on the calling thread (the REST thread) and leave it there. A GL context can only be current on one thread at a time, so the Trame thread could no longer make it current to render the next frame. This isn't limited toremove_dataset; e.g. turning the cross-section off (asload_statecan) does the same thing.Rather than adding inline
ReleaseCurrent()calls at each call site, this PR adds aGlContextLock, used as the scene lock in SERVER mode only. When the outermost hold of the lock ends, it callsReleaseCurrent()if the context is current on that thread, so any GL work done under the scene lock leaves the context free for the next thread. This replaces theReleaseCurrent() call inVisorRcaWindowand removes the need for one inServerRenderer.deregister_node(which would have been the other option here for theremove_datasetfix.Known limitation: This only covers GL work done while holding the scene lock, which every VTK operation touches today.