Skip to content

Commit 3ad9af6

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Upscaling/UpscalingExportSession.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ 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+
DispatchQueue.main.async {
387+
progress.completedUnitCount = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
388+
}
387389
}
388390
if let imageBuffer = nextSampleBuffer.imageBuffer {
389391
let upscaledImageBuffer = upscaler.upscale(
@@ -433,7 +435,9 @@ public class UpscalingExportSession {
433435
while assetWriterInput.isReadyForMoreMediaData {
434436
if let nextSampleBuffer = assetReaderOutput.copyNextSampleBuffer() {
435437
if nextSampleBuffer.presentationTimeStamp.isNumeric {
436-
progress.completedUnitCount = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
438+
DispatchQueue.main.async {
439+
progress.completedUnitCount = Int64(nextSampleBuffer.presentationTimeStamp.seconds)
440+
}
437441
}
438442
if let taggedBuffers = nextSampleBuffer.taggedBuffers {
439443
let leftEyeBuffer = taggedBuffers.first(where: {

0 commit comments

Comments
 (0)