We’re seeing a multi-second hiccup in our application, and according to the profiler it appears to be during WWW.isDone. First, a bit of background:
Our application is a data viz tool. When it launches, we do a bunch of setup and also launch a search for the latest data to our ‘core’, which is a RESTful API on a server. When the search returns, we do a bunch of things (parse the JSON, instantiate some NGUI objects, kick off additional downloads, etc.). During this time, we’re seeing a huge pause, but only in the webplayer. The standalone app has no pause at all - it runs smoothly.
After a bit of testing, it appears that a large chunk of the delay is being caused by our download manager checking to see if the download is complete by calling dl.isDone(). Here’s what I’m seeing in the profiler:
[10165-www+bug+profiler.jpg|10165]
As you can see, each isDone call appears to be taking 50 ms, with UnityCrossDomainHelper.GetSecurityPolicy being the only thing listed under isDone. Here’s the relevant code from our download manager:
private IEnumerator monitorDownload()
{
while (state == State.Downloading)
{
if (www.isDone)
{
MonitorDownload basically just runs on a loop, yielding every frame, and checks up on the download as it’s happening, along with managing download state (something we introduced in our download manager), etc.
So, in summary, for some reason calling www.isDone in some cases is causing up to a 50 ms delay, but only in the webplayer.
Some data to consider: Apparently, the WebPlayer still uses the browser for downloading: http://forum.unity3d.com/threads/141679-WWW-calls-slow-in-the-unity-web-player WWW vs HttpWebRequest: http://forum.unity3d.com/threads/64695-Comparing-performance-of-HttpWebRequest-to-WWW-class I wonder if you (for debugging only, mind) tried using the HttpWebRequest object, what speed would it report?
– DracoratThanks @Dracorat, I've seen posts stating that HttpWebRequest isn't available in the webplayer: http://forum.unity3d.com/threads/53218-Alternative-for-httpWebRequest-amp-HttpWebResponse If that's actually the case (and not user error) that would pretty much be a no-go :)
– Julien-LyngeAgreed. If it's not available, that's too bad (for testing). =(
– Dracorat