Android WWW issue at OS 2.3 or upper

We were struggling on a issue in our game’s leader board. It’s seem some of the device like Xperia or Nexus S failed to retrive data from server but other devices is working fine. IOS or MacOSX version is working ok but only some Android device has that issue. After couple of days analysis we found:

  • Device those has OS version 2.3 or over, they are unable to complete the WWW request and even it’s not giving any error on response. Basically it’s not completing the request.
  • Device those are below 2.3, is working fine.

We found some info about it like:
http://stackoverflow.com/questions/4931733/cant-get-android-2-3-to-handle-gzip
http://pastebin.com/v0Jvn0nD

which indicate, 2.3 is using gzip in the header. We tried to add gzip option in the header in PHP end but it didn’t work. Anyone facing that issue?

I just reported a similar bug where WWW requests never complete, e.g.

private IEnumerator SomeCoroutine() {
WWW myReq = …;
yield return myReq;
if(myReq.error != null) // this never executes
}

I’m seeing this bug on at least 2.2 (haven’t checked 2.3) as an intermittent problem that seems to be caused by an uncaught exception in WWW:run().

Here’s an example of the stacktrace I see in logcat:

I’m working on an android game with a paired app that makes a bunch of REST calls using Unity’s WWW class.

In general, when I make a WWW REST request, I start a coroutine, yield on the WWW object and then check for www.error when yield returns.

It looks like on android devices though, that there are cases where the internal WWW code throws an exception and then the code following ‘yield return myWWW;’ never executes.

Below is an example stacktrace from logcat. I’ve seen other (seemingly) uncaught exception types cause the same problem where yield WWW doesn’t work as it’s supposed to.

Device is an HTC Evo, with android 2.2. Unity version is 3.3.0f4:

E/Dhcpcd ( 1846): sending DHCP_DISCOVER with xid 0x1fe75c21, next in 3.65 seconds
W/System.err( 1603): at org.apache.harmony.luni.platform.OSNetworkSystem.c onnect(OSNetworkSystem.java:115)
W/System.err( 1603): at org.apache.harmony.luni.net.PlainSocketImpl.connec t(PlainSocketImpl.java:244)
W/System.err( 1603): at org.apache.harmony.luni.net.PlainSocketImpl.connec t(PlainSocketImpl.java:533)
W/System.err( 1603): at java.net.Socket.connect(Socket.java:1055)
W/System.err( 1603): at org.apache.harmony.luni.internal.net.www.protocol. http.HttpConnection.(HttpConnection.java:62)
W/System.err( 1603): at org.apache.harmony.luni.internal.net.http://www.protocol.http.HttpConnect…onPool.java:88)
W/System.err( 1603): at org.apache.harmony.luni.internal.net.http://www.protocol.http.HttpURLConn…nImpl.java:927)
W/System.err( 1603): at org.apache.harmony.luni.internal.net.http://www.protocol.http.HttpURLConn…nImpl.java:909)
W/System.err( 1603): at org.apache.harmony.luni.internal.net.http://www.protocol.http.HttpURLConn…Impl.java:1152)
W/System.err( 1603): at com.unity3d.player.WWW.run(Unknown Source)

Since WWW class can not be used in Android 2.3.3, i use WebRequest to do the same action, but can i use “StartCoroutine” and “yield return” to wait the WebResponse and how?? THX