Skip to content

Commit b18cd52

Browse files
committed
Update progress on main thread
1 parent b4ead0f commit b18cd52

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/Upscaling/UpscalingExportSession.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@ public class UpscalingExportSession {
383383
while assetWriterInput.isReadyForMoreMediaData {
384384
if let nextSampleBuffer = assetReaderOutput.copyNextSampleBuffer() {
385385
if nextSampleBuffer.presentationTimeStamp.isNumeric {
386-
progress.completedUnitCount = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
386+
let timestamp = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
387+
DispatchQueue.main.async {
388+
progress.completedUnitCount = timestamp
389+
}
387390
}
388391
if let imageBuffer = nextSampleBuffer.imageBuffer {
389392
let upscaledImageBuffer = upscaler.upscale(
@@ -433,7 +436,10 @@ public class UpscalingExportSession {
433436
while assetWriterInput.isReadyForMoreMediaData {
434437
if let nextSampleBuffer = assetReaderOutput.copyNextSampleBuffer() {
435438
if nextSampleBuffer.presentationTimeStamp.isNumeric {
436-
progress.completedUnitCount = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
439+
let timestamp = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
440+
DispatchQueue.main.async {
441+
progress.completedUnitCount = timestamp
442+
}
437443
}
438444
if let taggedBuffers = nextSampleBuffer.taggedBuffers {
439445
let leftEyeBuffer = taggedBuffers.first(where: {

0 commit comments

Comments
 (0)