AssetsManager Test downloading progress lable not sync with actual download

Hi,

I am using cocos2dx 2.1rc0-x-2.1.4 version.

I tried to download 180MB zip file using AssetsManager Test. Zip file downloaded in 10 min and extracted too(seen in output window) but the label on screen was showing only 20 percent. it takes more than 45 min for label to reach 100 percent! checked on device and PC too…at both behavior is same ! is it due separate downloading thread implemented in 2.1rc0-x-2.1.4 ?

plz help !

Thanks in advance :slight_smile:

Did you mean the downloading is finished, but the label is not refreshed?

not exactly! downloading is finished and label is updating too but not in sync.

CCLog produced by assetsManagerProgressFunc() showing “downloading… 100” and uncompress() shows “end uncompressing”.

when it shows “end uncompressing”, i checked data is downloaded and uncompressed too.

But at the same time, onProgress() shows 20 to 30 % only. onSuccess() gets call after nearly 45 min in case on 180MB zip.

Facing same issue ! need to wait for long time :frowning:

can any one help me to fix this issue

Thank you for feedback.
#2774 is created for this issue.

@sandeep g

But at the same time, onProgress() shows 20 to 30 only. onSuccess() gets call after nearly 45 min in case on 180MB zip.

Could you please add log in onProgress and onSuccess to checkout if the function is invoked or not.
I have reviewed the codes, and didn’t get any idea.

yes, function is invoked.

added CCLOG (“Downloading… %d”,percent); // in void UpdateLayer::onProgress(int percent)

downloading percentage log from assetsManagerProgressFunc() is different and ahead than downloading percentage log from onProgress().

Have u tried downloading larger zip file than what it is downloading currently ?

@sandeep g
Thanks.

Not yet, i will try later.

I think it has something to do with the messagequeu, the update gets called to slow so the message queue builds up very fast and takes ages to get empty. Every time the messagequeu posts a message, there are added 100 more. So when the download is already finished, the queue needs to be empty and takes ages for some reason. =/

I think I found a solution on stackoverflow. Its because curl calls the progressfunction to quick you can fix it by

@
static time_t prevtime;
int AssetsManagerProgressFunc(void ptr, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded)
{
time_t currtime;
double dif;
static int first = 1;
if {
time;
first = 0;
}
time;
dif = difftime;
if
return 0;
prevtime = currtime;
AssetsManager
manager = (AssetsManager**)ptr;
AssetsManager::Message**msg = new AssetsManager::Message();
msg~~>what = ACCAssetsManager_MESSAGE_PROGRESS;
ProgressMessage *progressData = new ProgressMessage;
progressData~~>percent = (int)(nowDownloaded/totalToDownload*100);
progressData~~>manager = manager;
msg~~>obj = progressData;

manager~~>_schedule~~>sendMessage(msg);

//CCLOG(“downloading… d%”, (int)(nowDownloaded/totalToDownload*100));

return 0;
}@

Now it only sends a message/second so the queue doesnt get overloaded. And this works fine for me :slight_smile:

wow….its working ! Thanks Seppe R :slight_smile: now label shows “download ok” as soon as uncompression finished !

thanks seppe R :slight_smile:
now its working, downloading 100 mb data in less than 10 min

[ HttpRequest ]

I’m using [ HTTP Request ] to download ZIP data like above !
I’m wonderring how to get percent download data ?
Please give me a examples
I would thank you so much