-
Notifications
You must be signed in to change notification settings - Fork 548
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
TransferUtility Pause/Resume Progress #677
Comments
Hi @RuiEEE Sorry for the inconvenience caused. |
Yes. At first I wasn't because in version 2.10.1 was not needed. But then I was but I'm still not getting callbacks on the listener. |
@RuiEEE I wrote a test to reproduce this issue and pasting the test here. @Test
public void testListener_Upload_PauseResume() throws Exception {
Log.d(LOG_TAG, "testListener_Upload_PauseResume begin");
final long size = 4 * MB;
final File tempFile = temp.newFile();
fillFile(tempFile, size);
final CountDownLatch countDownLatch = new CountDownLatch(1);
transferObserver =
transferUtility.upload(
"pr-" + tempFile.getName(),
tempFile);
// Attach a listener to the observer to get state update and progress notifications
final TransferListener transferListener = new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
Log.i(LOG_TAG, "onStateChanged = " + state);
if (TransferState.COMPLETED == state) {
// Handle a completed upload.
Log.i(LOG_TAG, "Upload Successful");
countDownLatch.countDown();
}
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
float percentDonef = ((float) bytesCurrent / (float) bytesTotal) * 100;
int percentDone = (int)percentDonef;
Log.i(LOG_TAG, "ID:" + id + " bytesCurrent: " + bytesCurrent
+ " bytesTotal: " + bytesTotal + " " + percentDone + "%");
}
@Override
public void onError(int id, Exception ex) {
Log.e(LOG_TAG, "Error uploading", ex);
assertTrue("Upload failed with exception: " + ex.getMessage(), false);
}
};
transferObserver.setTransferListener(transferListener);
waitUntilStateReached(TransferState.IN_PROGRESS, 5000);
transferUtility.pause(transferObserver.getId());
waitUntilStateReached(TransferState.PAUSED, 5000);
Log.d(LOG_TAG, "Progress after paused: Transferred = " +
transferObserver.getBytesTransferred() +
"; Total = " +
transferObserver.getBytesTotal());
TransferObserver observerAfterResume = transferUtility.resume(transferObserver.getId());
observerAfterResume.setTransferListener(transferListener);
waitUntilStateReached(TransferState.IN_PROGRESS, 5000);
try {
countDownLatch.await();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
transferObserver.refresh();
assertEquals(TransferState.COMPLETED, transferObserver.getState());
assertTrue(sS3Client.doesObjectExist(BUCKET_NAME, "pr-" + tempFile.getName()));
Log.d(LOG_TAG, "testListener_Upload_PauseResume end");
} Here are the logs from the test:
I am able to get progress and state updates before pause and after resume successfully. Can you let me know if I'm missing something in the test? This test uses single-part upload. What is the size of the file you are uploading? |
I'll try to replicate in a different project, I'm using notification to trigger pause/resume. Files are usually multipart. They go from 10mb to 80mb, its video files. |
@RuiEEE Thank you for the quick response. As you can see, I have attached the listener to |
@RuiEEE I have fixed this issue in Root cause analysis:
Description of the fix: The fix involves
See 2.11.1 for more information. |
I've checked the notes on the new 2.11.1 version, I ran some manual tests last week and I was able to get the progress on the observer, I must have been doing something wrong before, but I kept getting a state failed after pausing(with exception thrown and all). I've also noticed that after resuming the progress would go backwards a little, for example, I paused at 78% and when resumed, it would go back to 50% and resume from there. It seemed that the whole piece for the multipart was being dropped and then pick on the last part, I'm not sure I'm being clear. Regardless, on the next couple of days(tomorrow most likely) I'll update the SDK and get back to you. Thanks for being on top of it! |
@RuiEEE Thank you for the quick response. I have updated the comment with detailed root cause analysis and fix description. What you observed is accurate. My fix will make sure the progress does not go backwards and does not go beyond 100%. I will wait for your feedback on the fix. |
@RuiEEE Just checking to see how your progress on testing and if you have any feedback to share. |
Hey. Sorry for the late response, I got caught up in other stuff and because there was no major issue I didn't get back to you. I've noticed that whenever I pause I get some of these errors. Maybe it's fine and expected:
One other thing, I was setting a transferlistener everytime I was resuming the transfer(mostly because I'm running the upload on a service and wanted to make sure a transferlistener was attached) and for some reason it was attaching multiple transferlisteners instead of replacing the previous one. I know this because I was getting multiple callbacks on the stateChanged: This is after pausing and resuming 3 times: from the function onStateChange
Right now, I'm just setting one TransferListener whenever I start uploading and it's working as intended(it was not back in 2.10.x, and thats why I was setting a transferlistener everytime I resumed a transfer). |
@RuiEEE Thank you for the feedback. The exception is logged in the LogCat because when the SDK tries to pause the transfer, we kill the thread that aborts the operation in progress. However I expect you don't see an app crash and you get the state change update to PAUSED. Also, you're right that you only need one listener and we have identified and fixed the problem with managing the listeners. If you do not have any other questions, I can go ahead and close the issue. Otherwise, let me know how I can help you. |
@kvasukib Yeah, the app doesn't crash, just fills the log with those exceptions, I was just making sure it is intended. Cool. No, I'm good. Thanks a lot for your fast response and assistance! |
Describe the bug
After 2.11.0, when pausing and resuming an upload I'm not getting updates on the progress. Moreover, when I pause, I receive the FAILED state, If I resume it, the upload will eventually resume (and complete) but not get notified on the same transfer listener. I tried re-attaching the listener after the resume but it won't get notifed anyway.
To Reproduce
Which AWS service(s) are affected?
TransferUtility
Expected behavior
After pause and resuming a specific transfer, I expect the same transfer listener to be notified of the progress.
Environment:
2.11.0
Device Information:
Additional context
On SDK version 2.10.1 I'm getting the expected updates
The text was updated successfully, but these errors were encountered: