1

I'm trying to use AWS Transcribe in an iOS app using the aws-sdk-ios. The app starts a transcription job and I can see the job on the AWS console. But the app can't list the jobs, or get a specific job, because it gets stuck in the request to getTranscriptionJob or listTranscriptionJobs, as these requests never complete (I added a print statement and a breakpoint inside the completion block, and it never prints, nor reaches the breakpoint).

I uploaded to GitHub a sample single-view app demonstrating the problem. You'll need an AWS account or IAM user with full permissions on S3 and Transcribe. Insert that account's keys and S3 bucket in ViewController.swift in the appropriate variables.

https://github.com/joaomarceloods/AWSTranscribeBug

I need help. Is this a bug, or am I doing something wrong?

Swift, iOS 13.2, CocoaPods, AWSCore 2.12.1, AWSTranscribe 2.12.1

Most important snippet:

    /// `getTranscriptionJob` repeatedly until the status is no longer `inProgress`.
    /// However, `getTranscriptionJob` never completes.
    var transcriptionInProgress = true
    while transcriptionInProgress {
        print("getTranscriptionJob")
        transcribe.getTranscriptionJob(request).continueWith { task -> Any? in
            print("getTranscriptionJob never completes...")
            let transcriptionJob = task.result?.transcriptionJob
            transcriptionInProgress = transcriptionJob?.transcriptionJobStatus == .inProgress
            return nil
        }.waitUntilFinished()
    }
    print("...after the getTranscriptionJob")
João Souza
  • 4,032
  • 3
  • 25
  • 38

1 Answers1

0

I found a solution.

I still don't understand why getTranscriptionJob freezes, but it will execute normally if you run it on DispatchQueue.global():

.continueWith(executor: AWSExecutor(dispatchQueue: DispatchQueue.global())) {

Sample code diff: https://github.com/joaomarceloods/AWSTranscribeBug/commit/98e43af553413ed2bbd0c3f96e259139a991303e

Reference: https://aws-amplify.github.io/docs/ios/how-to-ios-asynchrounous-tasks#executing-a-block-on-the-main-thread-with-awstask

João Souza
  • 4,032
  • 3
  • 25
  • 38