From 002a62d31ed3c86576f7b26df64bb0bd29dcd6a0 Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Mon, 5 Aug 2013 15:46:12 -0700 Subject: [PATCH 1/4] Disable hand receive logic to keep team from crashing while a bug is being tracked. --- libraries/avatars/src/HandData.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index fb3d437489..c6c5a08a14 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -105,9 +105,14 @@ int HandData::encodeRemoteData(unsigned char* destinationBuffer) { size_t checkLength = destinationBuffer - startPosition; *destinationBuffer++ = (unsigned char)checkLength; + // just a double-check, while tracing a crash. +// decodeRemoteData(destinationBuffer - (destinationBuffer - startPosition)); + return destinationBuffer - startPosition; } +#define DISABLE_RECEIVE // Temporary measure while a crash is being traced + int HandData::decodeRemoteData(unsigned char* sourceBuffer) { const unsigned char* startPosition = sourceBuffer; @@ -116,8 +121,11 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { unsigned int numHands = *sourceBuffer++; for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) { +#ifndef DISABLE_RECEIVE if (handIndex >= getNumPalms()) addNewPalm(); +#endif + if (handIndex < getNumPalms()) { PalmData& palm = getPalms()[handIndex]; glm::vec3 handPosition; @@ -126,10 +134,11 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handNormal, fingerVectorRadix); unsigned int numFingers = *sourceBuffer++; +#ifndef DISABLE_RECEIVE palm.setRawPosition(handPosition); palm.setRawNormal(handNormal); palm.setActive(true); - +#endif for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) { if (fingerIndex < palm.getNumFingers()) { FingerData& finger = palm.getFingers()[fingerIndex]; @@ -139,26 +148,35 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, tipPosition, fingerVectorRadix); sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, rootPosition, fingerVectorRadix); +#ifndef DISABLE_RECEIVE finger.setRawTipPosition(tipPosition); finger.setRawRootPosition(rootPosition); finger.setActive(true); +#endif } } // Turn off any fingers which weren't used. for (unsigned int fingerIndex = numFingers; fingerIndex < palm.getNumFingers(); ++fingerIndex) { FingerData& finger = palm.getFingers()[fingerIndex]; +#ifndef DISABLE_RECEIVE finger.setActive(false); +#endif + } } } // Turn off any hands which weren't used. for (unsigned int handIndex = numHands; handIndex < getNumPalms(); ++handIndex) { PalmData& palm = getPalms()[handIndex]; +#ifndef DISABLE_RECEIVE palm.setActive(false); +#endif } +#ifndef DISABLE_RECEIVE setRaveGloveActive((gloveFlags & GLOVE_FLAG_RAVE) != 0); setRaveGloveMode(effectsMode); - +#endif + // One byte for error checking safety. unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition); unsigned char checkLength = *sourceBuffer++; From 858738a10afb918bc15e2f712a31585ab9c0fe7d Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Mon, 5 Aug 2013 15:56:49 -0700 Subject: [PATCH 2/4] Root cause of crash isolated to setRaveGloveMode(), so some disabled code has been re-enabled --- libraries/avatars/src/HandData.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index c6c5a08a14..42b18e1cb1 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -111,8 +111,6 @@ int HandData::encodeRemoteData(unsigned char* destinationBuffer) { return destinationBuffer - startPosition; } -#define DISABLE_RECEIVE // Temporary measure while a crash is being traced - int HandData::decodeRemoteData(unsigned char* sourceBuffer) { const unsigned char* startPosition = sourceBuffer; @@ -121,10 +119,8 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { unsigned int numHands = *sourceBuffer++; for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) { -#ifndef DISABLE_RECEIVE if (handIndex >= getNumPalms()) addNewPalm(); -#endif if (handIndex < getNumPalms()) { PalmData& palm = getPalms()[handIndex]; @@ -134,11 +130,9 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handNormal, fingerVectorRadix); unsigned int numFingers = *sourceBuffer++; -#ifndef DISABLE_RECEIVE palm.setRawPosition(handPosition); palm.setRawNormal(handNormal); palm.setActive(true); -#endif for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) { if (fingerIndex < palm.getNumFingers()) { FingerData& finger = palm.getFingers()[fingerIndex]; @@ -148,34 +142,27 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, tipPosition, fingerVectorRadix); sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, rootPosition, fingerVectorRadix); -#ifndef DISABLE_RECEIVE finger.setRawTipPosition(tipPosition); finger.setRawRootPosition(rootPosition); finger.setActive(true); -#endif } } // Turn off any fingers which weren't used. for (unsigned int fingerIndex = numFingers; fingerIndex < palm.getNumFingers(); ++fingerIndex) { FingerData& finger = palm.getFingers()[fingerIndex]; -#ifndef DISABLE_RECEIVE finger.setActive(false); -#endif } } } // Turn off any hands which weren't used. for (unsigned int handIndex = numHands; handIndex < getNumPalms(); ++handIndex) { PalmData& palm = getPalms()[handIndex]; -#ifndef DISABLE_RECEIVE palm.setActive(false); -#endif } -#ifndef DISABLE_RECEIVE setRaveGloveActive((gloveFlags & GLOVE_FLAG_RAVE) != 0); - setRaveGloveMode(effectsMode); -#endif +// This is disabled for crash tracing. +// setRaveGloveMode(effectsMode); // One byte for error checking safety. unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition); From 14e470133cd759fcd294c7d00125b3a7dff869a0 Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Mon, 5 Aug 2013 16:02:09 -0700 Subject: [PATCH 3/4] More cleanup after crash tracing --- libraries/avatars/src/HandData.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index 42b18e1cb1..644a0764b7 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -121,7 +121,6 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) { if (handIndex >= getNumPalms()) addNewPalm(); - if (handIndex < getNumPalms()) { PalmData& palm = getPalms()[handIndex]; glm::vec3 handPosition; @@ -133,6 +132,7 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { palm.setRawPosition(handPosition); palm.setRawNormal(handNormal); palm.setActive(true); + for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) { if (fingerIndex < palm.getNumFingers()) { FingerData& finger = palm.getFingers()[fingerIndex]; @@ -152,7 +152,6 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { FingerData& finger = palm.getFingers()[fingerIndex]; finger.setActive(false); } - } } // Turn off any hands which weren't used. for (unsigned int handIndex = numHands; handIndex < getNumPalms(); ++handIndex) { From 39f9729acbe9c7595a2647220bfba389473d8784 Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Mon, 5 Aug 2013 16:03:17 -0700 Subject: [PATCH 4/4] Warning fix: virtual method needs virtual destructor --- libraries/avatars/src/HandData.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index f0a546f184..2849096907 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -44,6 +44,7 @@ enum RaveGloveEffectsMode class HandData { public: HandData(AvatarData* owningAvatar); + virtual ~HandData() {} // These methods return the positions in Leap-relative space. // To convert to world coordinates, use Hand::leapPositionToWorldPosition.