My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 54: GirafPlace is very slow to download APK files (with solution)
2 people starred this issue and may be notified of changes. Back to list
 
Project Member Reported by julemand101, May 15, 2011
What steps will reproduce the problem?
1. Start GIRAF Place.
2. Select an application.
3. Touch install.

Whats happen?
It's takes lots of time to download the APK file to the Android Device and sometimes I get a timeout.

Problem:
The problem can be identified to be in sw6.girafplaceclient.AppDetailsActivity in the loop started at line 385:

while((current = bis.read()) != -1 && !isCancelled()) {
	baf.append((byte) current);
	read++;
	publishProgress((read/size)*100);
}

The problem is that the method publishProgress() is a very CPU-intensive operation on the phone and it's make no sense to call it for every byte there are been downloaded to the Android Device. I have made a patch to fix the issue and its make the application a lot faster (it takes 6-7 sec to download the aSchedule app on the Android Emulator):

Log.d(tag,"Starting to read");
int current = 0;
double read = 0;
int load = 0;
while((current = bis.read()) != -1 && !isCancelled()) {
	baf.append((byte) current);
	read++;
	load++;
	if (load == 10000) {
		publishProgress((read/size)*100);
		load = 0;
	}
}

Log.d(tag,String.format("Read %1$f bytes from the stream", read));

First i have added a load variable there counts every byte we download. For every 10000 bytes we reset the variable and run publishProgress() method. This means that we are running publishProgress() approx. 50-60 times when installing the aSchedule application and enough times to sill give a useful progress bar.

I could have done this instead:
if (read % 10000 == 0) {

But this is not as fast as the other solution because in this case the CPU needs to make a more CPU-intensive calculation again for every downloaded byte.


May 15, 2011
Project Member #1 rj...@student.aau.dk
Implemented in r1140
Status: Fixed
May 15, 2011
Project Member #2 jkg@jkg.dk
Good catch, julemand101 :)

Powered by Google Project Hosting