WWW and WWWForm - behave differently on iOS?

I’m porting some existing code from PC/Mac Unity to an iOS project. A part of it downloads XML files from a remote service. On the desktop build everything works great, but on the iOS I only get an empty string returned.

WWWForm is used to send session details, so I’m wondering if there’s something odd going on there. In particular, do either WWW or WWWForm behave differently on iOS than they do on PC/Mac?

Any pointers would be appreciated!

Update: Ok, I just removed the WWWForm component completely, so now it’s just a straight download of some text (from a PHP script) using WWW. Still no joy on iOS, but still works fine on my laptop.

I recall some time ago UT said that they changed the way the WWW class was coded for iOS (may explain the inconsistencies). It seems like a bug report would be the next step.

Yeah, I just hacked my code up to use WWW directly instead of the wrapper class I have. Same issue, so I reported a bug.

It’s a shame. I’ve got a few days off and was hoping to get a big chunk of this project done, but it relies heavily on grabbing bits from the 'net. I guess I’ll check out alternative methods. Is there anything else that’s simple and works on iOS and Mac/PC?

The only other option that comes to mind is just straight .net. I don’t know if it contains the feature you’re after, but I know it can do some networking-like stuff (like for multiplayer games).

.NET’s HttpRequest only works on some platforms as far as I understand. I did see that someone had written a ground-up web request library, UniWeb I think, that could be worth a look. One of the first things that it said in its Asset Store writeup was that if you don’t need advanced features (which I don’t) you may as well stick with WWW.

Of course, if that works and WWW doesn’t, it’ll still be worth the changeover. (Asset Store version is for “commercial support”, the actual library itself is free from the developer’s website.)

Ok, I just swapped out one of the web requests to use UniWeb instead of WWW. Took less than 10 minutes to get it working on my laptop. Fingers crossed it’ll also work on the iPad…

… but no. In fact, I get equivalent behaviour - works on the laptop, no response on the iPad. So my guess now is that it’s something dodgy with how my iPad is set up, since that’s far more likely than it being a problem with Mono or whatever else.

And another update - turns out Safari also didn’t work. Disconnecting and re-connecting my iPad’s wireless made it work, and also the web request. I bet that WWW will also work now, though since it’s more robust and already in here, I think I’ll stick with UniWeb.

Top two ideas what might be wrong:

  1. you are not yielding on www object. (on some platforms busy waiting works, but it should be considered as feature of specific platform instead of general feature)
  2. you are checking www.text property, but response from server is not strictly UTF-8 and thus cannot be accurately converted to text. In this case you probably better check www.data field.

Cheers mantasp.

The download is hooked up to an event system, so it doesn’t need to yield. Once the download is started the calling script goes about its business until the download completion event is fired.

I am checking www.text. The server output is compatible with that, so it’s not a problem for me, but still a good pointer none the less.

The issue for me was that, despite reporting otherwise, the iPad wasn’t connected to the network properly. (So sincere apologies to whoever picked up my bug report, hope it didn’t waste too much time!)

But haven’t you got the connection failure report via www.error?