UnityWebRequest custom DownloadHandlerScript crash on iOS.

Hello,

I’m having crashes on iOS whenever I instantiate a custom DownloadHandlerScript with preallocated buffer.

I sent a bug report but it has not been reproduced yet, so ou can find the complete project I use to test this here: https://drive.google.com/file/d/0B_WKsIMYzN7yLXFjaFNQNVJxMkU/view?usp=sharing
But to make it simpler, if anyone has encountered the same problem or could help me, here the relevants parts of my code:

class FileDownloader : IDisposable
{
  public string Url;
  public string LocalPath;

  public UnityWebRequest Request;

  byte[] _chunkBuffer;

  public FileDownloader(string url, string localPath)
  {
    Url = url;
    LocalPath = localPath;

    Request = new UnityWebRequest(url);

    _chunkBuffer = new byte[64 * 1024];

    Request.downloadHandler = new ChunkDownloadHandler(_chunkBuffer);
  }

  // [...]
}
public class ChunkDownloadHandler : DownloadHandlerScript
{
  // Pre-allocated buffer only
  public ChunkDownloadHandler(byte[] buffer) : base(buffer)
  {
  }

  // [...]
}

I’m getting the EXC_BAD_ACCESS with this stack trace:

I have reproduced this problem on Unity 5.3.4p5 and Unity 5.4.0b17

Am I doing something wrong? Has anyone encountered anything like this and figured out a way to fix it?

Thanks,

François

We ran into that too. Unity has reproduced it and fixed it. Will be available in a patch release next week for 5.3. I don’t know the status for 5.4.

Thanks for this information!

I looked at the messages you posted, do you talk about this issue : http://forum.unity3d.com/threads/unitywebrequest-current-status-and-ios-problems.380647/#post-2614565 ?
It doesn’t seem to be exactly the same problem, you said it only concerned data upload (POST/PUT), and it crashed in a destructor, whereas my problem concerns a constructor, and in my case it happens on a GET request too.

You’re right, but I would bet that your issue is fixed too since I gave them a repro project that was a decent torture test of mixing get and post infinitely.

If in doubt, file a bug with a repro project for them. It’s the only way to definitely move forward.

Unity has contacted me and said the bug should be fixed in the next patch release : 5.3.5p3

1 Like