Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16368] Android: App crashes on exit if HTTP request is pending

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-07-15T21:07:45.000+0000
Affected Version/sRelease 3.2.0, Release 3.2.2, Release 3.2.3
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, crash, exit, network
ReporterVladimir S
AssigneePing Wang
Created2014-01-13T04:48:13.000+0000
Updated2017-03-16T21:43:50.000+0000

Description

If the app is closed while an HTTP request is pending, as soon as the response is received, Android displays an error message that the app has crashed (even if it is apparently stopped). Attached is the sample project that does it. Just run it and exit the program, before the alert pops up. Happens both on real device and on the simulator. Attached is logcat dump and sample project

Attachments

FileDateSize
ErrorOnExit.zip2014-01-13T04:48:13.000+0000636487
logcat.txt2014-01-13T04:48:13.000+000016073

Comments

  1. Ritu Agrawal 2014-01-14

    I tried this test case on Samsung Galaxy Nexus device and it displayed the correct INFO message so I cannot reproduce this issue. I followed exact same steps so not sure what I am missing. [INFO] : abort request: [object HTTPClient]
  2. Vladimir S 2014-01-14

    Hi Ritu, This is just an info message that the abort method is called on a real object, it was just for testing. What happens on the S4, is that after closing the app, about 6-7 seconds later, in logcat - the dump that i posted is thrown, and on the device a message pops up - that the application has crashed I assume you did not get this error message ? right ?
  3. Ritu Agrawal 2014-01-14

    Correct. I did not get the error message.
  4. Vladimir S 2014-01-14

    https://www.youtube.com/watch?v=MBi1FoyX9o4&feature=youtu.be here i have uploaded a video from genymotion, using image S4, API 18
  5. Ritu Agrawal 2014-01-15

    Thanks for posting the video. I will try to get hold of a S4 device and test it out.
  6. Vladimir S 2014-01-15

    But did you try it out on Genymotion? there you can just download the S4 image and run it against it - this is why i posted the video - it is not a screencast from my own device - it is rather the Genymotion running the S4 image with the app installed there
  7. Ritu Agrawal 2014-01-15

    Thanks. I was trying to narrow it down to if it is a S4 device issue or a S4 image on Genymotion issue. You have already covered the second part so I wanted to do the first one.
  8. Vladimir S 2014-01-15

    Both - this is why i listed it in the Environment section of the jira issue i have the listed S4 device - 9505, where this fails, and it turned out it fails also on the genymotion - this is why I entered both But indeed - on Samsung Galaxy Tab 3110 and android 4.2.2, and HTC Desire S - it does not fail. i tried now
  9. Ritu Agrawal 2014-01-22

    I tried to reproduce the issue on Samsumg Galaxy S4 device but every time it is displaying the correct INFO message and not crashing. I followed the same steps as earlier so not sure what I am missing. I haven't got a chance to try on Genymotion yet but will update once I tried on it.
  10. Vladimir S 2014-01-22

    actually you should not receive any message, because - once the app starts, it opens an HTTP request, which takes few seconds. You have to exit the app (using back button) before the request comes back. The Info message is displayed once the request comes back. So it is already too late. The prblem happens when the request comes back, and the application has already exited. Then i get the mentioned exception You can see this in the video that i have created as well
  11. Ritu Agrawal 2014-01-24

    I actually used the back button to kill the application before the alert shows (sometimes alert showed because I was too late) and still cannot reproduce the error. May be we need to make a request that takes really long.
  12. Vladimir S 2014-01-24

  13. Ritu Agrawal 2014-02-04

    Moving this ticket to engineering I can reproduce this issue (finally) on Google Nexus 7 device with 4.4 SDK. It may be reproducible on other devices as well.
  14. Alberto Marcone 2014-05-21

    this is happening on our side too: TiSDK 3.2.3, Both on Simulator and the device is a Vodafone 875. If I press the back button and the HTTP request is pending, the app crashes. We tried to abort the HTTP call but with no success.
  15. Betty Tran 2014-06-20

    I was also able to reproduce this issue using the following code:
        var win = Ti.UI.createWindow({
        	exitOnClose: true
        });
        win.open();
        
        var button = Ti.UI.createButton({
        	title : "Send"
        });
        win.add(button);
        
        button.addEventListener('click', function(e) {
        	var xhr = Ti.Network.createHTTPClient({
        		onerror : function(e) {
        			Ti.API.info('error ' + e.error);
        		},
        		onload : function(e) {
        			alert('loaded');
        		}
        	});
        
        	xhr.open('GET', 'http://www.appcelerator.com');
        	xhr.send();
        });
        
    Tested on a Nexus 5 running Android 4.4.3.
  16. Ping Wang 2014-07-01

  17. Lee Morris 2017-03-16

    Closing ticket as the issue has been fixed.

JSON Source