ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
142 stars 17 forks source link

Fix `GL_INVALID_OPERATION` if closing a tab via a "Do you want to save changes?" popup #793

Closed adamkewley closed 7 months ago

adamkewley commented 1 year ago

Debugging OpenGL via WSL2 with this repro:

Error message:

id = 1
message = GL_INVALID_OPERATION in glBindTexture(non-gen name)
source = GL_DEBUG_SOURCE_API
type = GL_DEBUG_TYPE_ERROR
severity = GL_DEBUG_SEVERITY_HIGH

The reason that this happens is because ImGui's texture renderer does not manage the lifetime of the texture. So the sequence of events is something like:

The solution is to either:

adamkewley commented 1 year ago

This bug has been in OSC for a couple of years now so it's non-fatal and non-blocking, but I'm documenting it here as something that is also related to the fact that ImGui is using a separate rendering backend from OSC (osc uses oscar's renderer whereas ImGui uses its own one that's packaged with ImGui).

The "hollistic" approach here is to write an oscar backend to ImGui, so that all GPU interactions go through one managed graphics API.

adamkewley commented 7 months ago

This is now fixed because OSC now uses its own ImGui backend, which includes lifetime management for any submitted texture handles.