Kevin Well-Known Member Licensed User Longtime User Jun 23, 2012 #1 This isn't so much a problem with HTTP Utils as it is a problem that happens with CallSub2, which HTTP Utils uses. In the service, there are several statements similar to this: Code: Copy If HttpUtils.CallbackJobDoneSub <> "" Then CallSub2(HttpUtils.CallbackActivity, HttpUtils.CallbackJobDoneSub, HttpUtils.Job) End If This has worked well for me for a long time now. But since upgrading to B4A 2.0, I noticed that I was suddenly getting Null Pointer Errors in one of my activities that used HTTP Utils if the activity was backed out of before HTTP Utils was finished. I fixed this by changing the code above to the following for all CallSub2 statements in my various HTTP Utils-based services: Code: Copy If HttpUtils.CallbackJobDoneSub <> "" AND IsPaused (HttpUtils.CallbackActivity) = False Then CallSub2(HttpUtils.CallbackActivity, HttpUtils.CallbackJobDoneSub, HttpUtils.Job) End If I'm not sure why this suddenly got broken but if anyone else sees this problem, hopefully the solution above will fix it for you as well.
This isn't so much a problem with HTTP Utils as it is a problem that happens with CallSub2, which HTTP Utils uses. In the service, there are several statements similar to this: Code: Copy If HttpUtils.CallbackJobDoneSub <> "" Then CallSub2(HttpUtils.CallbackActivity, HttpUtils.CallbackJobDoneSub, HttpUtils.Job) End If This has worked well for me for a long time now. But since upgrading to B4A 2.0, I noticed that I was suddenly getting Null Pointer Errors in one of my activities that used HTTP Utils if the activity was backed out of before HTTP Utils was finished. I fixed this by changing the code above to the following for all CallSub2 statements in my various HTTP Utils-based services: Code: Copy If HttpUtils.CallbackJobDoneSub <> "" AND IsPaused (HttpUtils.CallbackActivity) = False Then CallSub2(HttpUtils.CallbackActivity, HttpUtils.CallbackJobDoneSub, HttpUtils.Job) End If I'm not sure why this suddenly got broken but if anyone else sees this problem, hopefully the solution above will fix it for you as well.
J jaminben Member Licensed User Longtime User Jun 24, 2012 #2 Hi Kevin, I was seeing the exact same thing but couldn't work a good fix out until I saw your post... your fix worked great for me. :sign0098: Upvote 0
Hi Kevin, I was seeing the exact same thing but couldn't work a good fix out until I saw your post... your fix worked great for me. :sign0098:
Kevin Well-Known Member Licensed User Longtime User Jun 24, 2012 #3 Glad to hear that worked for you as well! I had tried a few different things and was debating on making some drastic changes in order to fix it. I decided to step back and take a break for a while and the solution came to me. I am not sure why this problem seems to have started in 2.0, unless it is related to the improved message queuing that Erel mentioned. Maybe that somehow causes the error? So long as it is fixed I guess it doesn't matter. I had just released a new version of my app last night (the first with B4A 2.0) so I was feeling pressure to figure this out ASAP and post another update. Upvote 0
Glad to hear that worked for you as well! I had tried a few different things and was debating on making some drastic changes in order to fix it. I decided to step back and take a break for a while and the solution came to me. I am not sure why this problem seems to have started in 2.0, unless it is related to the improved message queuing that Erel mentioned. Maybe that somehow causes the error? So long as it is fixed I guess it doesn't matter. I had just released a new version of my app last night (the first with B4A 2.0) so I was feeling pressure to figure this out ASAP and post another update.
NeoTechni Well-Known Member Licensed User Longtime User Jun 24, 2012 #4 As a note to Erel, if he fixes it PLEASE also fix the URL issue where it doesnt replace spaces with %20 I hate having to fix it myself everytime I update the library Upvote 0
As a note to Erel, if he fixes it PLEASE also fix the URL issue where it doesnt replace spaces with %20 I hate having to fix it myself everytime I update the library
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2012 #5 It is a bug. It will be fixed in the next update. CallSubDelayed should be used instead of CallSub when you want to interact with other modules. I will update HttpUtils to use CallSubDelayed instead. Upvote 0
It is a bug. It will be fixed in the next update. CallSubDelayed should be used instead of CallSub when you want to interact with other modules. I will update HttpUtils to use CallSubDelayed instead.
Kevin Well-Known Member Licensed User Longtime User Jun 24, 2012 #6 CallSubDelayed was one of the things I tried when trying to fix the error. However, in my case it provided unwanted results. The service is used to retrieve data and populate items in a scrollview. This is done in its own activity. Specifically, it is a "guide" activity that shows a list of TV shows that are on at the current hour. The error occurred if the user backed out of the guide and went back to the main activity while HTTP Utils was in the process of downloading guide data and making callbacks to the guide activity in order to update the list. When I used CallSubDelayed, it did indeed get rid of the error, but it also caused the guide activity to start up again even though I had left it. If I left it again while it was still updating, it would then return to the guide activity again the next time an item finished downloading. So for me (unless it is just a problem with how I coded it all to work), CallSubDelayed did not work how I wanted it to. Upvote 0
CallSubDelayed was one of the things I tried when trying to fix the error. However, in my case it provided unwanted results. The service is used to retrieve data and populate items in a scrollview. This is done in its own activity. Specifically, it is a "guide" activity that shows a list of TV shows that are on at the current hour. The error occurred if the user backed out of the guide and went back to the main activity while HTTP Utils was in the process of downloading guide data and making callbacks to the guide activity in order to update the list. When I used CallSubDelayed, it did indeed get rid of the error, but it also caused the guide activity to start up again even though I had left it. If I left it again while it was still updating, it would then return to the guide activity again the next time an item finished downloading. So for me (unless it is just a problem with how I coded it all to work), CallSubDelayed did not work how I wanted it to.
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2012 #7 This is a good point. This is how CallSubDelayed works. In that case it is better to use a Service that will save the downloaded data and then get the data from the service when the activity resumes. Upvote 0
This is a good point. This is how CallSubDelayed works. In that case it is better to use a Service that will save the downloaded data and then get the data from the service when the activity resumes.
Kevin Well-Known Member Licensed User Longtime User Jun 24, 2012 #8 Erel said: [...] In that case it is better to use a Service that will save the downloaded data and then get the data from the service when the activity resumes. Click to expand... That is similar to some of the bigger changes I was considering in order to fix the problem. As it is now (checking to see if the callback activity is not paused) it is working exactly how it used to with no errors. I do also check to see if the job finished when the guide activity starts and handle that appropriately (as recommended). In that way, I don't miss anything if the user does back out of the guide activity before it is done. Since it is all working again, as far as I'm concerned the problem is fixed for me. Upvote 0
Erel said: [...] In that case it is better to use a Service that will save the downloaded data and then get the data from the service when the activity resumes. Click to expand... That is similar to some of the bigger changes I was considering in order to fix the problem. As it is now (checking to see if the callback activity is not paused) it is working exactly how it used to with no errors. I do also check to see if the job finished when the guide activity starts and handle that appropriately (as recommended). In that way, I don't miss anything if the user does back out of the guide activity before it is done. Since it is all working again, as far as I'm concerned the problem is fixed for me.
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2012 #9 HttpUtils2 is now available: http://www.b4x.com/forum/basic4andr...httputils2-web-services-now-even-simpler.html Upvote 0
HttpUtils2 is now available: http://www.b4x.com/forum/basic4andr...httputils2-web-services-now-even-simpler.html