I have this issue which i spent all day trying to track down in Box2D. Its a crash that occurs when compiling with thumb turned off. When thumb is on, it works fine but since its all floating point, the game runs slower.
The basic problem is this variable. m_pairBufferCount.
When compiling with thumb for device, the m_pairBufferCount will stay between 1 and 15 in this particular level.
When compiling without thumb for device, the m_pairBufferCount will stay between 1 and 15 for a bit, but all of a sudden, it will go from having a value of 1 to having a value of 3844. Basically, this takes the pairCount which is hovering from 350-400 and over the amount that is allowed in my settings which is set at 4096.
Here is the line where it asserts.
Here is the print out.
So in one frame, it will add 3844 pairs into the pair manager and cause a crash to occur. This only happens when not compiling with thumb on the iphone.
I can explain my the setup for the particular level that we have. Basically we have 1 prismatic joint with a body attached to it, that is moving left with a motor. This body has around 40-50 shapes on it. We also have 2 objects in our level called particle generators, which generate b2Body's with set velocity and angle.
I am not sure how the pair manager works and so forth but would like some insight into this please. Seems weird that it will break when not compiling with thumb.
If there is a hard limit on the number of shapes in a body that is attached to a joint, that would be helpful.
My only solution at the moment is to compile with thumb but that means the game will run slower.
The basic problem is this variable. m_pairBufferCount.
When compiling with thumb for device, the m_pairBufferCount will stay between 1 and 15 in this particular level.
When compiling without thumb for device, the m_pairBufferCount will stay between 1 and 15 for a bit, but all of a sudden, it will go from having a value of 1 to having a value of 3844. Basically, this takes the pairCount which is hovering from 350-400 and over the amount that is allowed in my settings which is set at 4096.
Here is the line where it asserts.
Code:
b2Pair* b2PairManager::AddPair(int32 proxyId1, int32 proxyId2)
{
if (proxyId1 > proxyId2) b2Swap(proxyId1, proxyId2);
int32 hash = Hash(proxyId1, proxyId2) & b2_tableMask;
b2Pair* pair = Find(proxyId1, proxyId2, hash);
if (pair != NULL)
{
return pair;
}
// CRASH OCCURS AT THIS ASSERT WHEN THE SYSTEM HAS RUN OUT OF PAIRS FROM MEMORY
b2Assert(m_pairCount < b2_maxPairs && m_freePair != b2_nullPair);
//printf("addPair: pair count: %d\n",m_pairCount);
uint16 pairIndex = m_freePair;
pair = m_pairs + pairIndex;
m_freePair = pair->next;
pair->proxyId1 = (uint16)proxyId1;
pair->proxyId2 = (uint16)proxyId2;
pair->status = 0;
pair->userData = NULL;
pair->next = m_hashTable[hash];
m_hashTable[hash] = pairIndex;
++m_pairCount;
return pair;
}
{
if (proxyId1 > proxyId2) b2Swap(proxyId1, proxyId2);
int32 hash = Hash(proxyId1, proxyId2) & b2_tableMask;
b2Pair* pair = Find(proxyId1, proxyId2, hash);
if (pair != NULL)
{
return pair;
}
// CRASH OCCURS AT THIS ASSERT WHEN THE SYSTEM HAS RUN OUT OF PAIRS FROM MEMORY
b2Assert(m_pairCount < b2_maxPairs && m_freePair != b2_nullPair);
//printf("addPair: pair count: %d\n",m_pairCount);
uint16 pairIndex = m_freePair;
pair = m_pairs + pairIndex;
m_freePair = pair->next;
pair->proxyId1 = (uint16)proxyId1;
pair->proxyId2 = (uint16)proxyId2;
pair->status = 0;
pair->userData = NULL;
pair->next = m_hashTable[hash];
m_hashTable[hash] = pairIndex;
++m_pairCount;
return pair;
}
Here is the print out.
Code:
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 0
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 3844
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 0
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 2
void b2PairManager::Commit() pairBufferCount: 3
void b2PairManager::Commit() pairBufferCount: 1
void b2PairManager::Commit() pairBufferCount: 3844
So in one frame, it will add 3844 pairs into the pair manager and cause a crash to occur. This only happens when not compiling with thumb on the iphone.
I can explain my the setup for the particular level that we have. Basically we have 1 prismatic joint with a body attached to it, that is moving left with a motor. This body has around 40-50 shapes on it. We also have 2 objects in our level called particle generators, which generate b2Body's with set velocity and angle.
I am not sure how the pair manager works and so forth but would like some insight into this please. Seems weird that it will break when not compiling with thumb.
If there is a hard limit on the number of shapes in a body that is attached to a joint, that would be helpful.
My only solution at the moment is to compile with thumb but that means the game will run slower.