I have written very simple application in Unity for Windows Phone.
Aquarium background, bubbles (particle system) and fishes moving from left to right and right to left.
I published app to Windows Phone Store for free and in reports there are many crashes.
Stack trace which can I export:
App: AquariumInPhone
OS version: 8.0
Problem function: Unknown
Exception type: c0000005
30-day crash count: 23
Stack trace:
Frame Image Function Offset
0 ntdll RtlpWaitOnCriticalSection 0x0000007e
1 ntdll RtlpEnterCriticalSectionContended 0x00000060
2 unityplayer 0x002ef5ac
This is very simple application, but crashes :(
Fishes moving left have code:
using UnityEngine;
public class Fish1 : MonoBehaviour {
float speed = 0.0032f;
Vector3 startPoint;
Vector3 currentPosition;
System.Random r = new System.Random ();
void Start()
{
startPoint = transform.position;
currentPosition = transform.position;
}
void Update ()
{
if (Camera.main.WorldToViewportPoint(transform.position).x < -0.2f)
{
int newY = r.Next(0, 5);
if(r.Next(0, 2) == 0)
newY = -newY;
Vector3 pos = new Vector3(12.0f, (float)newY, 0.0f);
currentPosition = pos;
transform.position = currentPosition;
}
else
{
currentPosition.x--;
transform.position += (currentPosition + startPoint) * speed * Time.deltaTime;
}
}
}
Fishes moving right have code:
using UnityEngine;
public class Fish2 : MonoBehaviour {
float speed = 0.005f;
Vector3 startPoint;
Vector3 currentPosition;
System.Random r = new System.Random ();
void Start()
{
startPoint = transform.position;
currentPosition = transform.position;
}
void Update ()
{
if (Camera.main.WorldToViewportPoint(transform.position).x > 1.2f)
{
int newY = r.Next(0, 5);
if(r.Next(0, 2) == 0)
newY = -newY;
Vector3 pos = new Vector3(-12.0f, (float)newY, 0.0f);
currentPosition = pos;
transform.position = currentPosition;
}
else
{
currentPosition.x++;
transform.position += (currentPosition + startPoint) * speed * Time.deltaTime;
}
}
}
What can be the reason of crash? How can I fix this?
Greets, David
Because the problem seems to be related to the Unity Engine itself, it would be better to post your problem on the Unity Support Forum. The devs are watching the forums and are more likely able to help you.
It could be some problematic setting or even a bug in the engine. For example, I had an app for the Windows Store where only one of the scenes would crash. In my case the crash only occurred when I used the development build setting and it was crashing before executing my code, so in the end it wasn't a problem with my code.
User contributions licensed under CC BY-SA 3.0