Skip to content
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

Uploading files with a content size >~ 2.1 GB do not restart properly #5468

Open
kaloramik opened this issue Dec 1, 2024 · 10 comments
Open
Labels
bug Something isn't working pending-maintainer-response Issue is pending response from an Amplify team member pending-triage Issue is pending triage

Comments

@kaloramik
Copy link

kaloramik commented Dec 1, 2024

Describe the bug

I am utilizing the behavior in the Swift TransferUtility documentation here https://docs.amplify.aws/gen1/swift/sdk/storage/transfer-utility/#managing-transfers-when-an-app-restarts

I have tested this with a 1.75 GB file and a 2.3 GB file. It seems to work correctly for the 1.75 GB file, but not for the 2.3 GB file.

In the 2.3 GB case, the contentLength gets changed to something negative. One possible hypothesis could be that 2.3 GB is larger than the size of a 32 bit signed int?

To Reproduce
Base case

  1. Try uploading a file of size < 2.1 GB
  2. use Fast App Termination and put app in background to simulate the app getting terminated by the system
  3. re-open app
  4. after a few minutes, the app correctly associates the upload and finishes

Steps to reproduce the behavior:

  1. Try uploading a file of size > 2.1 GB
  2. use Fast App Termination and put app in background to simulate the app getting terminated by the system
  3. re-open app
  4. after a few minutes, you can see onProgress callbacks, but the progress is always 0 and task.contentLength is negative
  5. Eventually, the upload will fail with the following error
com.amazonaws.AWSS3TransferUtilityErrorDomain - 2: Error Domain=com.amazonaws.AWSS3TransferUtilityErrorDomain Code=2 "(null)" UserInfo={Message=Expected to send [-1962180493], but sent [2332786803] and there are no remaining parts. Failing transfer }

Observed Behavior
see above
Expected Behavior

  • my expected behavior is that the upload would restart more quickly than 3 minutes, or at least have some way to indicate to the app that it is restarting, but that bug is already filed here Long delay in resuming multi-part uploads after restarting app #4580. I suspect if one were to terminate the app again while the restart is happening, this would incur more issues, but that's separate from this issue.

A clear and concise description of what you expected to happen.

Stack Trace
Please provide a stack trace if applicable e.g. a crash is occurring.

I am logging to Datadog here

  private func handleProgress(task: MultiPartUploadTask, progress: Progress) {
    NavigateDD.logger?.info("in handle progress \(task.file) \(task.location) \(task.file) \(task.status) \(task.error) \(task.description) \(task.key) \(task.contentLength) \(task.completedPartsSet.count)")
    let progressParams = ["progress": progress.fractionCompleted]
    let event = self.createEvent(task: task, customParams: progressParams)
    self.sendEvent(withName: PROGRESS_EVENT, body: event)
  }

you can see here where after the app restarts, the contentLength changes
Screenshot 2024-12-01 at 1 09 38 PM

Note that the original content length was 2332786803. the new content length is -1962180493 This is the value of the former as a signed int

>>> def get_signed_value(unsigned_int):
...     signed_value = large_value & 0xFFFFFFFF
...     if signed_value >= 2**31:
...             signed_value -= 2**32
...     return signed_value
...
>>> get_signed_value(2332786803)
-1962180493

Code Snippet
I have generally followed the same instructions in the AutoResume sample app

Unique Configuration
If you are reporting an issue with a unique configuration or where configuration can make a difference in code execution (i.e. Cognito) please provide your configuration. Please make sure to obfuscate sensitive information from the configuration before posting.

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?

  • AWSTransferUtility

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • SDK Version: 2.37.2
  • Dependency Manager: Cocoapods
  • Swift Version : Latest
  • Xcode Version: Latest

Device Information (please complete the following information):

  • Device: iPhone 14 Pro
  • iOS Version: 18
  • Specific to simulators: probably not

Additional context
Add any other context about the problem here like your specific use case.

Relevant Console Output
In some cases, it might be helpful to add any logs from your console that better help you tell the story of this issue. You can easily enable logging in your app by putting the following code in your app delegate.

AWSDDLog.sharedInstance.logLevel = .debug
AWSDDLog.add(AWSDDTTYLogger.sharedInstance)

Logs

Please logs in the code block below. (See: Logs Guidance)

Log Messages
INSERT LOG MESSAGES HERE
@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Dec 1, 2024
@kaloramik kaloramik changed the title Uploading files that have content size > size of Int do not restart properly Uploading files with a content size > 2.1 GB do not restart properly Dec 1, 2024
@kaloramik kaloramik changed the title Uploading files with a content size > 2.1 GB do not restart properly Uploading files with a content size >~ 2.1 GB do not restart properly Dec 1, 2024
@tylerjroach
Copy link
Member

Thank you for your report. I will go ahead and label this as a bug while we attempt to replicate the issue.

@tylerjroach tylerjroach added the bug Something isn't working label Dec 2, 2024
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 2, 2024
@harsh62
Copy link
Member

harsh62 commented Dec 2, 2024

@kaloramik Is using Amplify a possibility for you? Amplify uses the latest feature sets and has lot of improvements compared to AWS SDK.

@kaloramik
Copy link
Author

@harsh62 we can, but we already have our own backend / auth setup and would prefer not onboarding on to the entire Amplify ecosystem. Do you have a link to instructions / guide on how to use Amplify as a drop-in replacement for the AWSTransferUtility?

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 2, 2024
@kaloramik
Copy link
Author

kaloramik commented Dec 3, 2024

@harsh62 In addition, background uploading is extremely important for us. Looking at the documentation, the Amplify Upload Storage does not mention behavior when the app goes into suspension, terminated by system, or terminated by user.

https://docs.amplify.aws/swift/build-a-backend/storage/upload-files/

Whereas the gen 1 system seems to lay it out more specifically

https://docs.amplify.aws/gen1/swift/sdk/storage/transfer-utility/

Do you have any guarantees on reliability, especially when it comes to backgrounding, suspension, and restarts for the Amplify version? I would not want to spend a lot of time migrating just to run into issues that were solved in the Gen 1 version.

@creitz
Copy link

creitz commented Dec 3, 2024

This could be (one of) the source(s) of the issue. It seems the value for content_length is not being hydrated properly from the DB here:

[transfer setObject:@([rs intForColumn:@"content_length"]) forKey:@"content_length"];

For example, when uploading a file of 2,493,465,483 bytes, this is the value that's shown when rehydrating:
int_for_column

Obviously, -1801501813 is an impossible content length. Changing intForColumn to longForColumn seems to at least fix the reading of that value.
long_for_column

@harsh62
Copy link
Member

harsh62 commented Dec 3, 2024

@creitz Do you want to open a PR for the fix that you are suggesting? (Looks correct to me)

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 3, 2024
@kaloramik
Copy link
Author

@harsh62 just bumping the previous message on Amplify, would love to get some more info on migrating and the feature set in the new Amplify SDK, especially WRT background uploads

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 3, 2024
@harsh62
Copy link
Member

harsh62 commented Dec 3, 2024

@kaloramik I am working with my team to draft documentation around your question.

backgrounding, suspension, and restarts for the Amplify version

I will get back to you on this soon

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 3, 2024
@kaloramik
Copy link
Author

awesome thank you!

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Dec 3, 2024
@creitz
Copy link

creitz commented Dec 4, 2024

@creitz Do you want to open a PR for the fix that you are suggesting? (Looks correct to me)

Sure can do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-maintainer-response Issue is pending response from an Amplify team member pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

4 participants