Merge pull request #3888 from RosettaCommons/roccomoretti/interactive_address_mutex_contention2
Foldit: Address some mutex contention issues.
There are a number of locations where threaded contention for the GUI mutex was delaying threads for significant fraction of the runtime(*). A number of these locations are somewhat trivial to reorganize such that there isn't a need to hold the GUI mutex, or to hold it for shorter periods of time.
Many of these are switching to atomic data, rather than mutex-protected data. There's some larger scale reorganizations, as well as splitting up the GameApplicationTests and GameApplicationMacroTests unit tests, to better isolate some of the finicky/unstable tests.
Merge pull request #3982 from RosettaCommons/roccomoretti/interactive_fix_AP_OP_comparisons
Foldit: Fix AP/OP comparison issues
It looks like my recent pointer check branch had an unanticipated interaction with the bool() conversion function of APs & OPs. The upshot of which is that comparisons of APs & OPs were going through bool(), rather than being compared directly on the pointer. This resulted in some odd behavior in the client. This PR fixes the issue by making the bool() conversion explicit, as well as adjusting the AP & OP comparison functions.
Merge pull request #3981 from RosettaCommons/roccomoretti/interactive_geom_validity
Foldit: Fix issue with puzzle switching and focus geometry.
When you have the camera focused on a residue at the end of the pose, and then switch to a puzzle with a smaller number of residues, you get a crash due to a lingering ResidueGeometry which references a now-nonexisting residue number.
To check for this, I added a Geometry::is_valid() function which can check for this case, and added a check in StandaloneCameraController to make sure that the geometry is valid before we switch.
Merge pull request #3968 from RosettaCommons/roccomoretti/interactive_pointer_checks
Foldit: Add checks to access_ptr usage.
Looking at some of the bug reports coming in, I have a strong suspicion that a bunch of the obscure crashes are related to memory corruption due to object lifetime issues.
Part of this might be down to Foldit's heavy reliance on access pointers. The current implementation of Foldit APs doesn't provide any guarantees/safety regarding object validity when using APs. This PR augments the current APs with a validity CheckObject which gets invalidated when the object is deleted.
To make sure checks run, I knocked out a bunch of the AP->raw pointer conversions. This has the added benefit of adding AP/OP conversion functions. This also switches boost::bind() to interactive::util::bind(), which has better support for maintaining object validity for the duration of the call to a member function callback.
The one downside for interactive::util::bind is that, due to C++ templating rules, it doesn't play well with overloaded member functions. As such, when you wrap overloaded member functions, you may need to use interactive::util::bind_op instead. (And potentially add to the bind_op rules in interactive/util/bind.hh.)
RELEASE NOTES: Improve error handling and reporting for a class of obscure crashes.