Recently i publish a game in the play store, some users report random crashes on android 4.3 and above, i had tested my app in several phones mostly 4.0.x with zero problems. I debug the app using the AVD and a 4.4 android device resulting in a crash, this is the log :
D/InputEventConsistencyVerifier( 2578): TouchEvent: ACTION_MOVE contained 1 pointers but there are currently 0 pointers down.
D/InputEventConsistencyVerifier( 2578): in com.android.internal.policy.impl.PhoneWindow$DecorView{b2d478a0 V.E… R…I. 0,0-288,240}
D/InputEventConsistencyVerifier( 2578): 0: sent at 53427610000000, MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=229.0, y[0]=210.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=53427610, downTime=53427262, deviceId=0, source=0x1002 }
In the app you control a marble, rolling it with the finger, here the code within the Update function that causes the error :
t = Input.GetTouch(0);
if (t.phase==TouchPhase.Moved)
{
final.Set(t.deltaPosition.x, 0, t.deltaPosition.y);
velocidad = t.deltaPosition.magnitude / t.deltaTime;//touch's speed of motion
if (rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce(final * velocidad);
}
}
I found that replacing that code, with other approach like this solve the error :
switch (Input.GetTouch(0).phase)
{
case TouchPhase.Began:
SW = false;
startpos = new Vector3(Input.GetTouch(0).position.x, 0, Input.GetTouch(0).position.y);
break;
case TouchPhase.Moved:
SW = true;
break;
case TouchPhase.Canceled:
SW = false;
return;
case TouchPhase.Stationary:
SW = false;
break;
case TouchPhase.Ended:
if (SW)
{
endpos = new Vector3(Input.GetTouch(0).position.x, 0, Input.GetTouch(0).position.y);
final = endpos - startpos;
if (rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce(final);
}
}
break;
}
With this code the apps doesnt freeze but the movement is less accurate, you must end the stroke in order to apply the force to the ball, while in the first solution the ball steadily respond your finger movements. It seems to me that the problem is the access to the Input.GetTouch(0) during the TouchPhase.Moved state in terminals with the most recent android version.
Any help would be appreciated, i spent a lot of time wondering the cause of this randomly crashes.