ComputationalBiomechanicsLab / opensim-creator

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

Not opening/crashing on latest MacOS #811

Closed SAI-sentinal-ai closed 7 months ago

SAI-sentinal-ai commented 7 months ago

Hi, thanks for all you work on this. I was using OSC up until last night with no issues on my M1 mac. However after the latest update (7 Nov, Sonoma), it does not seem to open. Here is a part of the crash report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               osc [7748]
Path:                  /Applications/osc.app/Contents/MacOS/osc
Identifier:            software.osc
Version:               0.01 (???)
Code Type:             X86-64 (Translated)
Parent Process:        launchd [1]
User ID:               1249621022

Date/Time:             2023-11-17 12:40:04.4950 +1300
OS Version:            macOS 14.1.1 (23B81)
Report Version:        12
Anonymous UUID:        5932BC01-F513-547D-5597-06D582AB61BC

Sleep/Wake UUID:       6611E72E-E320-4260-B012-5B2248D3F18D

Time Awake Since Boot: 1600 seconds
Time Since Wake:       1300 seconds

System Integrity Protection: enabled

Notes:
PC register does not match crashing frame (0x0 vs 0x7FF814DF9818)

Crashed Thread:        5  Dispatch queue: com.Metal.DeviceDispatchQueue

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [7748]

Error Formulating Crash Report:
PC register does not match crashing frame (0x0 vs 0x7FF814DF9818)
adamkewley commented 7 months ago

Hi @SAI-sentinal-ai , I'm sorry to hear this

Just so I understand, is the OSC release you're using is 0.5.4? Or is it a development release (from the GitHub Actions)? And by "latest update", do you mean "the latest update of OSC (as in, OSC has broken something)" or "the latest update of MacOS (as in, there's something in MacOS that i need to investigate"?

adamkewley commented 7 months ago

(additional information): if it's related to the mac OS update, it could be that you've upgraded from a pre-Sonoma to a Sonoma release? There's a very large amount of posts that appear to indicate that Sonoma may have stability issues - esp with software that renders 3D (e.g. games, Blender, etc.)

SAI-sentinal-ai commented 7 months ago

Hi @adamkewley, thanks for the quick reply. I am using the latest version of OSC from: https://github.com/ComputationalBiomechanicsLab/opensim-creator/releases. In fact, I think OSC stopped working overnight even before I updated either OSC or macOS... but I am not 100% as I have macOS set up to update at night. I was using OSC on Sonoma previously, so it may have to do with the latest November update. I have not noticed issues other software such as Paraview or Cloudcompare which render in 3D.

adamkewley commented 7 months ago

Hi @SAI-sentinal-ai ,

I have managed to reproduce a crash on my Intel Macbook Air (note: it may not be your crash) and, after a little debugging, it turns out to be due to quite old code in OSC that was algorithmically bogus, but that has been fine until a recent update to Mac's standard library (see 69899c0 if you want a technical overview).

It would be useful if you tried out a build of OSC with the relevant fix in it. If it fixes your problem, then I can ship the fix as a patch release for OSC very soon.

To try it out:


If that doesn't work out for you then further steps would be:

SAI-sentinal-ai commented 7 months ago

Hi @adamkewley, the build on https://github.com/ComputationalBiomechanicsLab/opensim-creator/actions/runs/6930226982 seems to work! Thanks for the quick turn around. Your software makes editing OpenSim models much less painful :) I guess we can close this issue?

adamkewley commented 7 months ago

@SAI-sentinal-ai good to hear!

I'll try and test+ship a release that includes the fix, followed by closing this (I'll keep it open as a reminder)

adamkewley commented 7 months ago

@SAI-sentinal-ai the fix, along with another fix bug I found in the meshimporter (due to the C++20/math changes I made since 0.5.4) are now published as 0.5.5 on the releases page:

Cheers for taking the time to report this!

SAI-sentinal-ai commented 7 months ago

thanks for fixing it!

Perhaps you could help me with a related issue: I am trying to update locations and offsets in an osim file programatically. I guess you have used the CPP API to implement these sliders in OSC. Is there anyway to access OSC programatically, or how can I find the relevant code for updating locations, say of wirepoints of muscle, in the repo? Thanks! (my email is h.saini@auckland.ac.nz)

adamkewley commented 7 months ago

No problem!

Perhaps you could help me with a related issue: I am trying to update locations and offsets in an osim file programatically. I guess you have used the CPP API to implement these sliders in OSC.

Yep, exactly right, if you can squint past the UI-related stuff (making a table, adding buttons, etc. etc.) the source code behind (e.g.) the coordinate editor is calling OpenSim::Coordinate methods (perhaps via an actions layer that handles undo/redo etc.):

Is there anyway to access OSC programatically, or how can I find the relevant code for updating locations, say of wirepoints of muscle, in the repo?

No way to access OSC programatically: it's designed as an application with only the UI exposed to end-users. This is (currently) a deliberate decision, because OSC's codebase undergoes very very aggressive changes (in comparison to, OpenSim, which has API users, so must guarantee long-term API stability).

I'd use python+anaconda to do it, or C++ (if you're familiar) against OpenSim itself. The code that OSC's doing to (e.g.) move muscle points around is very generic, because it also has to handle (e.g.) moving offset frames, stations, and so on. Rough breakdown is:

https://github.com/ComputationalBiomechanicsLab/opensim-creator/blob/a1a7ea9c8f3c84a8d1bce516f42b2ce40e9bd34c/src/OpenSimCreator/UI/Widgets/ModelSelectionGizmo.cpp#L245

Whenever the user moves the object in the 3D scene then that's turned into an internal undoable function call:

https://github.com/ComputationalBiomechanicsLab/opensim-creator/blob/a1a7ea9c8f3c84a8d1bce516f42b2ce40e9bd34c/src/OpenSimCreator/UI/Widgets/ModelSelectionGizmo.cpp#L277

And that function call computes the new location of the (e.g.) OpenSim::PathPoint and saves it into the model:

https://github.com/ComputationalBiomechanicsLab/opensim-creator/blob/a1a7ea9c8f3c84a8d1bce516f42b2ce40e9bd34c/src/OpenSimCreator/Utils/UndoableModelActions.cpp#L1767

But OSC's implementation of this approach is much heavier than what you could write yourself in (e.g.) python, because OSC has to handle it in realtime, with edge-cases, undo/redo support, error fallback (e.g. when muscle pennation angles are wrong) and automatic error rollback to earlier versions, etc. etc.

SAI-sentinal-ai commented 7 months ago

Thanks for the detailed answer. You are right, essentially I want to set up the same simulation with different joint offsets (this includes moving not only the bones but also the wrapping objects and wire points). Honestly, it may be easier to just modify the XML file directly. The Python API documentation is quite lacking, unless I am looking in the wrong place (could be the case!). Thanks anyway! Harry

adamkewley commented 7 months ago

No problem. For documentation, I'd recommend this page (tl;dr - use the anaconda version, it's much less painful):

And then you kind of need to translate the C++ doxygen documentation. But an easier way (imo) is to read the Examples/ scripts in opensim-core, or read other python-based projects that use OpenSim, such as Pose2Sim