[android-developers] Re: Largish HTTP Post vs. ANR

2008-12-05 Thread Dianne Hackborn
You can look in I believe /data/anr/traces.txt to find a dump of the stacks
of all processes and threads when the ANR happened, which should tell you
what your thread was stuck doing at the time.

On Thu, Dec 4, 2008 at 4:27 PM, [EMAIL PROTECTED] wrote:


 Yes, I've already coded that up and it behaves identical to
 HttpURLConnection. So that's
 not the root cause of this.

 I just tested this on 3g vs. my home wireless and it too behaves
 identically, so it's not the
 kind of net connectivity that's causing this either.

 Mike

 On Thu, Dec 4, 2008 at 4:21 PM, Mark Murphy [EMAIL PROTECTED]
 wrote:
 
  [EMAIL PROTECTED] wrote:
  So I switch over to using DefaultHttpClient and friends and it...
  behaves the same way.
  (I assume that's what you meant by HTTPComponents aka the apache stuff?)
 
  Yes, the stuff in org.apache.http.*. Documentation can be found at
  http://hc.apache.org, and example code for HttpClient can be found at:
 
  http://hc.apache.org/httpcomponents-client/examples.html
 
  --
  Mark Murphy (a Commons Guy)
  http://commonsware.com
  _The Busy Coder's Guide to Android Development_ Version 1.9 Published!
 
  
 

 



-- 
Dianne Hackborn
Android framework engineer
[EMAIL PROTECTED]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Largish HTTP Post vs. ANR

2008-12-05 Thread Alan

Mike,

I've used the

android.net.http.RequestQueue class for large, high latency calls.
This class takes care of running the request in a seperate thread and
allowing you to create a callback to handle the result.

You can find an example of using the RequestQueue at
http://www.anddev.org/doing_http_post_with_android-t492.html

Cheers,

Alan



On Dec 4, 6:54 pm, [EMAIL PROTECTED] wrote:
 So I switch over to using DefaultHttpClient and friends and it...
 behaves the same way.
 (I assume that's what you meant by HTTPComponents aka the apache stuff?)

 Does anybody have any direct experience trying to post largish amounts of 
 data?
 It doesn't seem like what I'm doing here is particularly unusual. It
 seems fairly
 linear fwiw. above about 5kb and it starts getting the 5 second ANR's,
 at arounds
 6kb, it takes about 6 seconds and almost always triggers an ANR.

 Mike

 On Thu, Dec 4, 2008 at 2:46 PM, Mark Murphy [EMAIL PROTECTED] wrote:

  enervatron wrote:
  FWIW, I'm using HttpURLConnection to create and read/write the data,

  Have you tried switching to the HTTPComponents API in Android? It's
  possible the problem is limited to the implementation of
  HttpURLConnection, and your problem will go away by using another HTTP API.

  --
  Mark Murphy (a Commons Guy)
 http://commonsware.com

  Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Largish HTTP Post vs. ANR

2008-12-04 Thread enervatron

On Thu, Dec 4, 2008 at 2:25 PM, Justin (Google Employee) [EMAIL PROTECTED] 
wrote:

 My guess is that you're calling Thread.run() from the UI thread. This
 will execute the thread in the UI thread. You need to call Thread.start
 () for it to execute in its own thread.

No, I'm definitely calling .start (), and it's definitely running as a
background
thread otherwise doing the same thing with a little post data and lots
of post response wouldn't work either. That's why I don't understand this
because it seems to correlate with the writing of http post data and nothing
else. Which doesn't make any sense to me.

Mike

 Let me know if this isn't the issue.

 Cheers,
 Justin
 Android Team @ Google

 On Dec 4, 1:33 pm, enervatron [EMAIL PROTECTED] wrote:
 Hi all,

 I'm using a helper thread to post data back to a web site. What I
 notice is that I'm
 getting an Application Not Responding back in the main thread even
 though it's
 not doing anything other than interrupting the helper thread to wake
 up. If the
 amount of data in the post is small (~ couple hundred bytes), I don't
 have a
 problem, but when it gets moderately large (~ 10kb) it reliably stalls
 the main
 UI thread and gets (appropriately) an ANR. Even weirder is that if I
 time from
 when I start the post to when it receives the entire reply (ie, using
 Date().getTime())
 in the helper thread, it shows that it's only taking about .5 seconds
 to complete,
 even though it  takes ~10 seconds to become responsive again.

 This *only* seems to be the case writing the post data. If I do a post
 of a small
 amount of data with a large amount of data coming back from a web
 site, the
 app remains responsive and unlike the above problem, the timing
 numbers in
 the thread agree with how long it actually took.

 FWIW, I'm using HttpURLConnection to create and read/write the data,
 and
 I'm aware that I need to use Handler to affect the UI from the helper
 thread.
 Also: this is on the G1 hardware. I've also fiddled with priorities,
 etc, to
 no avail, so I'm pretty stumped as to why the helper thread is
 interacting
 with the UI thread.

 Mike
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Largish HTTP Post vs. ANR

2008-12-04 Thread Mark Murphy

enervatron wrote:
 FWIW, I'm using HttpURLConnection to create and read/write the data,

Have you tried switching to the HTTPComponents API in Android? It's 
possible the problem is limited to the implementation of 
HttpURLConnection, and your problem will go away by using another HTTP API.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Largish HTTP Post vs. ANR

2008-12-04 Thread enervatron

Yes, I've already coded that up and it behaves identical to
HttpURLConnection. So that's
not the root cause of this.

I just tested this on 3g vs. my home wireless and it too behaves
identically, so it's not the
kind of net connectivity that's causing this either.

Mike

On Thu, Dec 4, 2008 at 4:21 PM, Mark Murphy [EMAIL PROTECTED] wrote:

 [EMAIL PROTECTED] wrote:
 So I switch over to using DefaultHttpClient and friends and it...
 behaves the same way.
 (I assume that's what you meant by HTTPComponents aka the apache stuff?)

 Yes, the stuff in org.apache.http.*. Documentation can be found at
 http://hc.apache.org, and example code for HttpClient can be found at:

 http://hc.apache.org/httpcomponents-client/examples.html

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 1.9 Published!

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---