Hi! I noticed that in a macOS app, session.process will not run unless I add RunLoop.main.run() afterwards, which successfully creates the model but leaves the app unresponsive with the spinning color wheel.
Also, the sample code for the async/await version shows a session.outputs property that doesn't exist in Xcode. I'd appreciate any suggestions on how to fix this! Thank you.
session.output
// .receive(on: DispatchQueue.global())
.sink(receiveCompletion: { completion in
var maybeError: Error? = nil
if case .failure(let error) = completion {
print("Output: ERROR = \(String(describing: error))")
maybeError = error
Foundation.exit(maybeError != nil ? 0 : 1)
}
}, receiveValue: { output in
DispatchQueue.main.async {
self.output = output
}
switch output {
case .processingComplete:
// All requests are done so you can safely exit.
print("Processing is complete!")
case .requestError(let request, let error):
print("Request \(String(describing: request)) had an error: \(String(describing: error))")
case .requestComplete(let request, let result):
self.complete(request: request, result: result)
case .requestProgress(let request, let fractionComplete):
self.progress(request: request, fractionComplete: fractionComplete)
case .inputComplete: // Data ingestion has finished.
print("Data ingestion is complete. Beginning processing...")
case .invalidSample(let id, let reason):
print("Invalid Sample! id=\(id) reason=\"\(reason)\"")
case .skippedSample(let id):
print("Sample id=\(id) was skipped by processing.")
case .automaticDownsampling:
print("Automatic downsampling was applied!")
default:
print("Output: unhandled message: \(output.localizedDescription)")
}
})
.store(in: &subscriptions)
reference = try! session.process(requests: [
.modelFile(url: URL(fileURLWithPath: "model123.usdz"), detail: .reduced)
RunLoop.main.run()
])