Search code examples
androidlocalhostserversocket

Android 1.6 losing Packets


just encountered the following on Android 1.6 (Sony Xperia X10): When requesting data with XMLHttpRequest in a WebView on the same device (eg. 127.0.0.1:8080) while serving packets via ServerSocket.accept(), the XMLHttpRequest sometimes get stuck. The debugger tells me that the server actually is deep into ServerSocket.accept(), eg. he has served or not received the last request. The WebViewCoreThread is stuck at

Object.wait() line: 288 
Request.waitUntilComplete() line: 381   
RequestHandle.waitUntilComplete() line: 262 
Network.requestURL(String, Map, byte[], LoadListener, boolean) line: 195    
FrameLoader.handleHTTPLoad() line: 204  
FrameLoader.executeLoad() line: 131 
...

supposedly waiting for it's http0 ... http3 threads, that all wait at

Object.wait(long, int) line: not available [native method]  
RequestQueue(Object).wait() line: 288   
ConnectionThread.run() line: 93 

First I thought the request packet just got lost. But that doesn't explain why all http.. threads are at the same waiting position, as one should wait for response, while the others for new jobs from WebView then. Any ideas?


Solution

  • This is indeed a bug in Android it seems. It can be circumvented by adding a delay to the server before the response is sent.