Performing network.request on Android during suspend/exit

Hello

For 2 years, all our games sent a request when application was suspending and exiting on both platforms: iOS and Android.

Now on Android we started to get:

I/Corona (11191): Runtime error I/Corona (11191): no Java state I/Corona (11191): stack traceback: I/Corona (11191): [C]: in function 'request' I/Corona (11191): ?: in function 'request' I/Corona (11191): ?: in function 'func' I/Corona (11191): /Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-6.1.1/release/release/platform/resources/init.lua:241: in function 'dispatchEvent' I/Corona (11191): ?: in function 'loop' I/Corona (11191): ?: in function 'func' I/Corona (11191): /Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-6.1.1/release/release/platform/resources/init.lua:241: in function \</Users/jenkins/slaveroot/workspace/Enterprise/OS/xcode-6.1.1/release/release/platform/resources/init.lua:221\> E/WindowManager(11191): Activity com.ansca.corona.CoronaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42913580 V.E..... R.....I. 0,0-0,0} that was originally added here E/WindowManager(11191): android.view.WindowLeaked: Activity com.ansca.corona.CoronaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42913580 V.E..... R.....I. 0,0-0,0} that was originally added here E/WindowManager(11191): at com.ansca.corona.CoronaLuaErrorHandler$2.run(CoronaLuaErrorHandler.java:178) E/WindowManager(11191): at com.ansca.corona.CoronaLuaErrorHandler.reportError(CoronaLuaErrorHandler.java:153) E/WindowManager(11191): at com.ansca.corona.CoronaLuaErrorHandler.invoke(CoronaLuaErrorHandler.java:114) E/WindowManager(11191): at com.ansca.corona.CoronaEnvironment.invokeLuaErrorHandler(CoronaEnvironment.java:356) E/WindowManager(11191): at com.ansca.corona.CoronaRuntime.dispose(CoronaRuntime.java:90) E/WindowManager(11191): at com.ansca.corona.CoronaActivity.onDestroy(CoronaActivity.java:709) E/AndroidRuntime(11191): at com.ansca.corona.CoronaSensorManager.stopType(CoronaSensorManager.java:824) E/AndroidRuntime(11191): at com.ansca.corona.CoronaSensorManager.pause(CoronaSensorManager.java:960) E/AndroidRuntime(11191): at com.ansca.corona.CoronaLuaErrorHandler$1.run(CoronaLuaErrorHandler.java:106) W/ActivityManager( 2347): Activity stop timeout for ActivityRecord{440b1438 u0 pl.cluain.project/com.ansca.corona.CoronaActivity}

Is this something done on purpose?

If so I will have to move the request to the native layer, and I would really like to keep things simple :confused:

I’m also having an issue related to this. I’ve gotten updates rejected from Amazon for multiple apps.

You are supposed to do as little work as you can when suspended.  If you take too long the OS can hard kill your app.  You have enough time to flush data buffers and close files.  Network.request()'s can take a long time depending on network latency, server load, etc. I would not count on network.requests() working when the app is suspending…

Rob

@MochiBits: try setting timeout to 1sec [we cannot use ms unfortunately]. This should close the connection fast enough.

If that fails, try using sockets and just sending the message to the server and closing the connection manually.

I’m also having an issue related to this. I’ve gotten updates rejected from Amazon for multiple apps.

You are supposed to do as little work as you can when suspended.  If you take too long the OS can hard kill your app.  You have enough time to flush data buffers and close files.  Network.request()'s can take a long time depending on network latency, server load, etc. I would not count on network.requests() working when the app is suspending…

Rob

@MochiBits: try setting timeout to 1sec [we cannot use ms unfortunately]. This should close the connection fast enough.

If that fails, try using sockets and just sending the message to the server and closing the connection manually.