opensim-core
opensim-core copied to clipboard
Beefup markersreference testcase
Fixes issue #3226
Brief summary of changes
Exercise workflow in issue 3226
Testing I've completed
Looking for feedback on...
CHANGELOG.md (choose one)
- no need to update because...
- updated.
@CVHammond this PR exercises the code you have in #3226, I will not merge it since it tests nothing now but it doesn't crash. If you agree, this points to memory management issues/early garbage collection in Matlab rather than an actual API bug, I will propose ideas/suggestions if that proves to be the case.
@aymanhab that appears to be the correct C++ implementation of the MATLAB test case that I posted. Looking forward to advice on adjustments to deal with MATLAB's memory management
Some ideas for troubleshooting:
- print the version (opensimCommonJNI.GetVersionAndDate()) to make sure the wiring is to the latest build of 4.4.
- Create objects and keep references to them in variables rather than on the stack e.g. SimTKArrayCoordinateReference(), otherwise they could be immediately garbage collected.
- Where does the crash happen, if in a loop is it at a specific index?
- If there's a stacktrace that would be extremely helpful to pinpoint the issue source.
- I understand this is a simplified version, which is best but I don't know if it actually crashes for you or if the crash happens only in more complicated setting where the three sets (Model-makers vs. weights vs. markers-in-trc-file) are not identical.
- I don't have a working Matlab environment but can get that setup over the next day or two. In that case I'd like to know your Matlab version.
Let me know what you find out or if you get more clues on what's going wrong.
I believe I have found the issue and fixed it. It was a combination of the MarkersReference
object requiring a specific signature and the MarkerReference
's MarkerTable
returning double
sometimes and java.lang.double
other times for MarkerTable.getNearestRowIndexForTime()
. The suggestion to make sure I was using the HEAD (opensimCommonJNI.GetVersionAndDate()
) was important as well. I'm learning more about interacting with the C++ API than I originally thought I would.
All of my tests now pass as they did on 4.0.
Outstanding! thanks for the update. The issue with double vs. java.lang.double was reported by another user earlier and we couldn't reproduce. If you can provide a minimal example that would be awesome. Thanks for your help 👍