Repository navigation
Conversation
The success handler already ran on the main thread, but the failure handler ran on the exporter's background thread.
Export videos with the async export API, which cancels with the task. If the duration can't be loaded, the export continues, as it did with the synchronous duration property.
`VideoSessionProgressObserver.work()` called the progress handler before checking `interrupt`, so a tick already queued when the export ended ran after `fail()` marked the progress as finished and overwrote it with the session's partial progress. Check `interrupt` first, and inject the progress read so the observer can be tested without a real `AVAssetExportSession`.
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34680 | |
| Version | PR #26082 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 40f879c | |
| Installation URL | 6719rlg5t6pmg |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34680 | |
| Version | PR #26082 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 40f879c | |
| Installation URL | 19bd6vurvjq7g |
Contributor
|
I noticed the issue with this observe and left it alone, because I plan to update the minimal iOS version to 18 (which we bump every year), and use this API instead. |
Move the timer body into `tick()` so the tests can call it directly. The previous tests slept 300ms against a 100ms timer, which could fail on a slow CI agent.
Contributor
|
@jkmassel Does your thumbup on this comment mean we can close this PR, and do something like this instead: #26090? |
crazytonyli
force-pushed
the
task/zero-warnings-avasset-async
branch
from
October 19, 2026 00:21
eee87cc to
6606ea3
Compare
Contributor
|
Version |
Contributor
Author
|
Yes, close this one in favour of #26090. The task group waits for the progress task before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes a race where a failed or cancelled video export ends with an unfinished
Progress, despitefail()marking it as finished. Stacked on #26041.Root Cause
VideoSessionProgressObserver.work()callsprogressHandlerbefore checkinginterrupt.observer.stop()(thedeferinexportVideo(with:filename:progress:)) therefore doesn't prevent a tick that's already queued on the global queue — it still runs up to 100ms later.When the export throws, the order is:
defer { observer.stop() }→interrupt = truereportcatches the error →fail()setscompletedUnitCount = totalUnitCountprogressHandler(session.progress)→completedUnitCount = done * session.progress(e.g. 40)Steps 1 and 2 are microseconds apart, so step 3 landing last is the likely ordering, not an edge case. The progress — and the parent progress in
ItemProviderMediaExporter/MediaURLExporter— ends unfinished.This isn't a regression from #26041: the old callback-based code also left the progress partial when the export failed. It does mean the "finished on failure" guarantee #26041 adds with
fail()doesn't hold once the export has started.Fix
interruptbefore reporting, not after.interruptis still an unsynchronizedBool(pre-existing), but with the check first a stale read only costs one extra tick instead of clobbering the final value.init(sessionProgress:progressHandler:)seam so the observer can be tested without a realAVAssetExportSession, and moves the timer body intotick()so tests can drive it without waiting on the timer.init(videoSession:progressHandler:)is kept as a convenience initializer, so the call site is unchanged. The class goes fromfileprivateto internal for@testableaccess.Test plan
Real video-export tests in this bundle are skipped as flaky (
MediaURLExporterTests.exportTestVideo), so the new tests drive the observer directly: a stubbed progress source, andtick()called directly — no sleeps, no AVFoundation, no scheduling dependence.VideoSessionProgressObserverTests.doesNotReportAfterStop— stops the observer, marks the progress finished (whatfail()does), then runs a tick; expects it to stay finished. Fails without the fix (completedUnitCount → 40vstotalUnitCount → 100), passes with it.VideoSessionProgressObserverTests.reportsProgress— guards against the fix silencing the observer entirely.