Open adamkewley opened 3 weeks ago
Reading into this more, the bug in OpenSim Creator is subtle, but needs to be sorted:
OpenSim::Coordinate
s in a range for
loop to render the coordinate editor UI (this is usually fine)is_free_to_satisfy_constraints
) can throw an exception from OpenSim if those constraints can't be satisfiedmodel.rollback()
(the assumption being that the last not-yet-committed edit is probably the source of the exception, so roll it back to an earlier version)rollback
mechanism overwrites the edited scratch-space model with a probably-safe committed version of the model.CoordinateSet
and Coordinate
s in the scratch-space modelfor
loop in the UI now contains out-of-date data (it's looking at the pre-rollback
memory)The architectural issue here is that the UI is iterating over data that's being indirectly edited via some other mechanism (rollbacks), which wasn't being exercised before because setting a coordinate's value was usually safe (because most coordinates don't have this constraint-satisfaction thing going on).
The architectural solution is to change the core (undoable) model datastructure in OSC to not allow direct model mutation and, instead, provide an API like queueMutation(std::function<bool(OpenSim::Model&)>);
which applies all mutations after the UI has finished rendering a frame, so that there's no chance that the UI becomes inconsistent with the thing it's iterating over.
(and now I'm beginning to see why retained-mode UIs separate mutation propagation from painting :wink:)
Very specific bug:
is_free_to_satisfy_contraints
set totrue
Coordinates
panel, the UI will crashTracing the crash, it's a
nullptr
segfault. Looks like this:coordinate.getSpeed(state);
segfaultsvalue
column, which the user is editingcoordinate.setValue(state, value);
. This is usually fine for most models.free_to_satisfy_constraints
enabled,setValue
can throw an exception during aprojectQ
call in the implementationmodel.rollback()
to try and preserve the user's modelfor (Coordinate coord : coordinates) {}
rollback
, because rolling back also involves callingModel::buildSystem
etc., which will re-synthesize theOpenSim::Coordinate
s