-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWSS3TransferUtility download progress when coming back to foreground #1143
Comments
Thanks for reporting this - I have observed this in my testing as well and had the same understanding as you i.e, the progress update callback in the |
I thought there might be something wrong with my implementation and was mainly focusing on the online AWS docs and its proper implementation rather than the Ahh unfortunately i don't. My knowledge regarding |
@mrikh |
So I finally got about to trying to find a solution to this problem and ran into the following post here. It talks of a workaround that does seem to work and is endorsed by apple engineers! So what I did was at the end of:
I added a notification observer and then:
This works as expected. 0 problems. |
@mrikh Thanks for investigating and for bringing a solution to this old issue! The workaround seems reasonable, but I'm not inclined to build lifecycle monitoring into the TransferUtility, since we are already relying on customer apps to manage the lifecycle by recreating a TransferUtility with the appropriate key. In fact, the initialization code you reference above is the first part of that--it's invoked by a customer app creating a transfer utility with a key, as noted here. The good news is, TransferUtility already loads tasks from the NSURLSession during its initialization! Although, it uses So there's a small question of whether there something magic about invoking It sounds like you've got a working test with a forked copy of the repo--would you be able to change the code in AWSS3TransferUtility.m around line 634 and test? We can certainly look at this, but it's not super high on our priority list, and it'll be a while before we're able to spin up a test to try to reproduce this and see if the code snippet below fixes it. //If it is in any other status than running, then we need to recover by retrying.
if ([task state] != NSURLSessionTaskStateRunning) {
//We think the task in IN_PROGRESS. The underlying task is not running.
//Recover the situation by retrying.
[self retryUpload:uploadTask];
continue;
// #################
// ADD THIS ELSE CLAUSE
} else {
[task resume];
// #################
} That will take care of testing this for upload tasks. If it works, we'll apply that patch to the section for download tasks as well down on line 680 or so. Thanks again for the investigation! |
I understand. So the magic is with I also tried
To control it from the client side without the need to include the notification observer in the transfer utility but unfortunately that doesn't work. The reason I had to go inside to the TransferUtility class was so that I can find a reference to the |
It looks like invoking (task as? AWSS3TransferUtilityTask)?.sessionTask.resume() to bypass that check and directly operate on the session's task. However, that's a last resort--we really want to handle this for customer apps, not make y'all do low-level operations on NSURLSession.
Let's think about this a bit more. Your point about the resume path is valid and I'm sorry I missed it. Our current instructions imply that TransferUtility should begin delivering progress events and callbacks as soon as the customer app attaches to them, without any additional method calls or wiring. Further, it seems innocuous to call So we just have to 1) Listen to the correct lifecycle event; and 2) make sure that we resume the correct items. For 1): your proposal to use a notification is a good one, but I think we want to listen to For 2): Rather than iterate over the session tasks directly, we should iterate over the TransferUtility tasks, inspect to make sure they are in What do you think? |
Interestingly enough everything works fine on the simulator but not on device. Well i never checked the instructions before. But i tried them with a print statement in
and iterating over the results after checking for Sure can do that but is there a specific reason for it since we do end up modifying the |
A couple of notes:
We don't want to |
By this I mean that the original bug in the first post doesn't appear on the simulator at all. Only appears on device.
Ohhh I didn't mean that the Notification isn't fired, sorry I should have been clearer. I re-read what I wrote and it can be read like that. I mean that the putting the code inside the notification selector doesn't work! It only works 2/10 times. The selector is called but putting
Ah thats what I had the below check for
I just automatically assumed that the |
Describe the bug:
The bug seems to be that we don't get callbacks for the progress continuously if we start the download, put the application in the background and then come back to the foreground. The download does keep on happening just the progress callbacks aren't received.
I am sure the download is happening in the background as the UI gets updated once the download is complete but not while the progress is happening after coming back into the foreground.
I tried debugging the issue, it seems that the callback doesn't happen in the
NSURLSession
delegate itself inside the SDK until the download is completed. This is the method i'm using for the download:Edit: I also get a callback in the progress closure just after the coming back into the foreground and just before the download is completed. I've also implemented the appropriate method inside app delegate as well
Before putting app in the background the fraction completed shows values starting from lets say 0 to 0.5 perfectly fine with the appropriate progress values, if i put the app in the background at this point and come back again, the next time i receive the progress will be just before the download is completed and that too only once.
To Reproduce
Steps to reproduce the behavior:
Use the above method to start the download after passing the appropriate callbacks. Put the application in the background and then back into the foreground. Observe that the progress closure isn't called but once the download is done, the completion is called.
Expected behavior
Continue to get progress callbacks.
Screenshots
Can't upload screenshots/video cause its an official project.
Environment(please complete the following information):
Device Information (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: