UnityWebRequest for streaming requests returning isDone

I’m building a project that relies on a type of IP-based Motion-JPEG webcam. For those of you new to the world of streaming video cameras, there are essentially two types; ones with a content-type of
“multipart/x-mixed-replace; boundary=boundary” and ones with a content-type of “image/jpeg”.

The video player works just fine. I’ve created a UnityWebRequest inside a Coroutine, call SendWebRequest() and receive bytes in a custom DownloadHandlerScript, pull out the images from the stream and render the video into a Material. However, it’s the streaming request that’s a problem.

For multipart/x-mixed-replace, everything works exactly as I expect. The DownloadHandlerScript reads and buffers in the data to deal with it, and the data just keeps coming until I abort the stream. No problem here whatsoever.

On the other hand, for image/jpeg, the request returns the first image in the stream correctly, then the request just ends. The server is never polled/pumped again by the UnityWebRequest. The DownloadHandlerScript’s “isDone” property is false; correct, I am expecting more data! However, UnityWebRequest’s “isDone” property is true, “downloadProgress” is 1. No more data comes in and my system gets stuck in an infinite loop waiting for something to come in.

It’s certainly possible to just spam calls to UnityWebRequest as fast as possible, I am actually able to get 8-10 FPS out of these old image/jpeg cameras this way, but it’s certainly not ideal.

So the question:

  • Can I pump a streaming request that’s waiting around?
  • Is there something Async that I’m not calling correctly?
  • Should I be using a different WWW request?

Sanity Check:

  • Are you sure it’s not just the camera you’re using? Yes, I’ve tested this with multiple cameras from multiple manufacturers and it works just fine through a browser, locally, and over the internet. It just doesn’t work using a UnityWebRequest.

Have you tried examining the traffic using tools like Fiddler?
For DonwloadHandlerScript isDone currently is false all the time, it’s bug.
Is CompleteContent callback called on your script? UWR thinks the request is completed based on other properties.