- Home /
The question is answered, right answer was accepted
StopAllCoroutines throw exc_bad_access in XCode when app is build for iOs
When I going to cancel download process, after 1-2 seconds after call of StopAllCoroutines() Xcode throw "exc_bad_access" error. As I can see at call hierarchy it occurred somewhere in WWW class logic. This error appears only at iOs configuration. For Mac, Windows and Android all is OK. I'm using Unity 5.3.4 version. This error is actual when both scripting Backend are used: IL2CPP and Mono2x. Does anybody has faced with this problem and how can I resolve this?
code example:
public class SomeClass: MonoBehaviour
{
// Called after call of Download method of DownloadHelper class
private void CancelDownloadProcess()
{
//...
this.StopAllCoroutines(); "exc_bad_access" error
//...
}
}
public static class DownloadHelper
{
// Launched from SomeClass
public static IEnumerator Download(string url)
{
using (WWW www = new WWW(url))
{
while (!www.IsDone)
{
yield return www.progress;
}
//...
}
}
}
Answer by serginian · May 27, 2016 at 12:14 PM
I found that this error is caused when Dispose method are called of WWW class when download process is not finished (www.isDone is false). There is no difference between how this method is called obviously (www.Dispose()) or not (using statement). After www.IsDone is true the WWW class' object can be successfully disposed. So, it seems that it is Unity's bug.