Hey - getting a fairly critical error with WebGL builds and WWW.
We have found that unless the WWW status code returns a code 200 (OK) it becomes unreliable in Unity. It will often never return after a yield return WWW; and this causes major issues in our game, and any that makes WWW calls.
We have reported a bug for it - 697460 - which has a simple repro case, and even identified what the bug seems to be.
There is a JS file created in a WebGL build which has this line:
// 200 is successful http request, 0 is returned by non-http requests (file:).
if (http.status == 200 || http.status == 0)
This seems to only care about status code 200 (and status code 0), and then all the other status codes have their data ignored. Here is the full function:
function _JS_WebRequest_SetHandler(request, arg, onresponse)
{
var http = wr.requestInstances[request];
// LOAD
http.onload = function http_onload(e) {
if (onresponse)
{
// 200 is successful http request, 0 is returned by non-http requests (file:).
if (http.status == 200 || http.status == 0)
{
var byteArray = new Uint8Array(http.response);
var buffer = _malloc(byteArray.length);
HEAPU8.set(byteArray, buffer);
Runtime.dynCall('viiii', onresponse, [arg, http.status, buffer, byteArray.length]);
}
else
{
Runtime.dynCall('viiii', onresponse, [arg, http.status, 0, 0]);
}
}
};
// ERROR
http.onerror = function http_onerror(e) {
if (onresponse)
Runtime.dynCall('viiii', onresponse, [arg, http.status, 0, 0]);
};
}
It seems like a fairly easy fix - we can patch it locally in the uncompressed JS files, but the compressed JS file we cannot make the same fix in.