Languages

Menu
Sites
Language
Debugger and application creash when using XmlHttpWebRequest

I am creatint a Tizen Web application for controlling a device. The device exposes it's functionality by hosting an HTTP server and receives commands in query strings. The result of each operation is sent back in a binary response. I've got no trouble in calling the functionality but I see odd behaviour when I try to read the response. This is how I'm reading it. 

 

    	var request = new XMLHttpRequest();
		request.responseType = 'arraybuffer';
		request.open('GET', applyPassword(commandURL), true);
		request.onload = function(e) {
			try {
			var response = request.response;
                        //Everything freezes on next line
			if(request.status == 200) {
				var responseArray = new Uint8Array(response); 
				for(var i=0;i<responseArray.length;++i) {
					console.log(responseArray[i]);
				}
			}
			catch(exc)
			{
				console.log(exc);
			}
			//}
		};
		request.onerror = function(e) {
			console.log(e);
			console.log(e.responseText);
		};
		request.send();
	};

While the call succeeds when I attempt to check the request status the debugger becomes non-functional. and the application non-responsive. Given the simplicity of the code this is an unexpected response. Has anyone experienced anything similar and know of any work arounds?

 

Edited by: Joel Ivory Johnson on 27 Sep, 2016

Responses

2 Replies
Iqbal Hossain

Hi~

Can you check like this,

    	var request = new XMLHttpRequest();
	request.responseType = 'arraybuffer';
	request.open('GET', applyPassword(commandURL), true);
	request.onreadystatechange = function(){
	      if (request.readyState == 4 && request.status == 200) 
	        {
		  console.log(request.response);
		  console.log(request.responseText);
	        }
         }
	request.send();

Let me know if it helps you.

-Thanks

Joel Ivory Johnson

Sadly, I think the problem I am running into has to do more with the debugging system and not the code. If I don't have any breakpoints in the response code it looks that it runs fine. If I have any breakpoints in there then problems occur. The first sign of a problem is when that breakpoint is hit the button to pause/continue a script turns white. Once that happens there's no hope of getting the program to continue. 

 

I verified this behaviour by making the response function do nothing. I made the entirity of the response code

request.onstatuschange = function() {
}

Putting a break point in the body of the above function is sufficient to cause the program to freeze and the debugger to act up. 

It seems I can run my code as long as I don't do any debugging in the Http responses.