Android coroutine loop ruins game

so I am making a game where i am trying to draw a line based on the users input.
for that i am using a coroutine, with a while loop`function draw() :IEnumerator{
while(Input.GetMouseButton(0)){
Debug.Log(“startPosss=”+startPos);

	endPos = Input.mousePosition;
	endPos.z = 20;
	endPos = Camera.main.ScreenToWorldPoint(endPos);
	
	platform.localScale.x = endPos.x-startPos.x;
	Debug.Log("endpos="+startPos);
	//brick.localRotation.z = endPos.y - startPos.y;
	if(startPos.y<endPos.y)
	{
	Debug.Log("lll");
	distance = Mathf.Sqrt(Mathf.Pow((startPos.x-endPos.x),2)+Mathf.Pow((startPos.y-endPos.y),2));
	rotationAngle = Mathf.Rad2Deg * Mathf.Asin((Mathf.Abs(endPos.y-startPos.y))/distance);
	if(startPos.x>endPos.x){
	rotationAngle = 180-rotationAngle;
	}
	//Debug.Log("distance="+distance);
	//Debug.Log("rotationAngle="+rotationAngle);
	
	for(var j = 0; j<GameObject.FindGameObjectsWithTag("Platform").Length;j++){
	Destroy(GameObject.FindGameObjectsWithTag("Platform")[j]);
	}
	Instantiate(platform, Vector3((endPos.x-startPos.x)/2+startPos.x,(endPos.y-startPos.y)/2+startPos.y,0.0), Quaternion.Euler(0,0,rotationAngle));
	}
	else{
	
	distance = Mathf.Sqrt(Mathf.Pow((startPos.x-endPos.x),2)+Mathf.Pow((startPos.y-endPos.y),2));
	rotationAngle = Mathf.Rad2Deg * Mathf.Asin((Mathf.Abs(endPos.y-startPos.y))/distance);
	if(startPos.x<endPos.x){
	rotationAngle= 180-rotationAngle;
	}
	
	//Debug.Log("distance="+distance);
	//Debug.Log("rotationAngle="+rotationAngle);
	
	for(var i = 0; i<GameObject.FindGameObjectsWithTag("Platform").Length;i++){
	Destroy(GameObject.FindGameObjectsWithTag("Platform")*);*
  •   }	*
    
  •   Instantiate(platform, Vector3((endPos.x-startPos.x)/2+startPos.x,(endPos.y-startPos.y)/2+startPos.y,0.0), Quaternion.Euler(0,0,rotationAngle));*
    

}
yield WaitForSeconds(0.01);
}
}` . In my unity editor everything is fine, yet on a android device, once i try to draw, it goes straight to game over scene, and when ever i try to click retry, it goes back for a second and then back to game over scene.

Why arent you just doing this on Update rather then trying to run a whole separate threaded loop?