here is my code:
function XX:getFile(asset, path)
self.loader = UrlLoader.new( path..asset )
local function onComplete(event)
local out = io.open( "|D|"..asset, "wb" )
out:write( event.data )
out:close()
end
local function onError()
// bla bla
end
local function onProgress(event)
print("progress: ", event.bytesLoaded, " of ", event.bytesTotal)
end
self.loader:addEventListener(Event.COMPLETE, onComplete)
self.loader:addEventListener(Event.ERROR, onError)
self.loader:addEventListener(Event.PROGRESS, onProgress)
end |
From my test, It seems when urlloader is downloading large file, the onProgress calls are only called when the file is already completed.
example output :
d ( DownloadData ) : timeout remaining 119000 ms
// ... skipped
d ( DownloadData ) : timeout remaining 87000 ms
// i stopped checking for timeout when onProgress was called for the first time
d ( FileLoader ) : progress: 98304 of 544466 . time remaining: 87000
d ( FileLoader ) : progress: 114688 of 544466 . time remaining: 120000
d ( FileLoader ) : progress: 122880 of 544466 . time remaining: 120000
// ... skipped
d ( FileLoader ) : progress: 540672 of 544466 . time remaining: 120000
d ( FileLoader ) : progress: 544466 of 544466 . time remaining: 120000
// ... I also kept tracking for timeout between onProgress. You can see that after the first time onProgress is called, the next onProgress calls happened in an instant.
Comments
Because UrlLoader is something that is implemented for each platform separately and we are always struggling to make them behave similar
I tested this on windows. I havent yet tested this on other platform. I'll update this thread when i have tested it on other platform
Is anyone aware of a fix or workaround for this?
Paul