Skip to content

Commit 05b0284

Browse files
Julius Marmingeclaude
andcommitted
fix(ios): re-mint the video URL when AVKit fails to play it
A stale signed URL failed, the alert closed the player, and the next open reused the same cached URL. The failure now refreshes the asset URL in the background so the next open plays from a fresh one. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 2aa19e5 commit 05b0284

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎apps/mobile/src/components/VideoPreviewModal.ios.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Alert, Keyboard } from "react-native";
55

66
import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
77
import { mediaVideoPreviewUri, type VideoPreviewSource } from "../lib/videoPreviewSource";
8-
import { useAssetUrlState } from "../state/assets";
8+
import { useAssetUrlState, useRefreshAssetUrl } from "../state/assets";
99
import { usePreparedConnection } from "../state/session";
1010

1111
export type { VideoPreviewSource } from "../lib/videoPreviewSource";
@@ -33,6 +33,7 @@ function NativeVideoPreview(props: {
3333
const resource = source.type === "media" && "resource" in source ? source.resource : null;
3434
const preparedConnection = usePreparedConnection(environmentId);
3535
const assetUrl = useAssetUrlState(environmentId, resource);
36+
const refreshAssetUrl = useRefreshAssetUrl(environmentId, resource);
3637
const name = source.type === "media" ? source.name : source.attachment.name;
3738
// The first minted URL is kept so a background refresh does not restart playback.
3839
const resolvedUrl =
@@ -85,6 +86,8 @@ function NativeVideoPreview(props: {
8586
}
8687
})().catch((error: unknown) => {
8788
if (controller.signal.aborted) return;
89+
// AVKit gives no retry, so re-mint now; the cached URL may simply have expired.
90+
if (ready) void refreshAssetUrl();
8891
Alert.alert(
8992
"Could not open video",
9093
ready
@@ -99,7 +102,7 @@ function NativeVideoPreview(props: {
99102
controller.abort();
100103
void NativeControls.dismissVideo(identifier).catch(() => undefined);
101104
};
102-
}, [localAttachment, name, source.sourceIdentifier, playbackUrl, identifier]);
105+
}, [localAttachment, name, source.sourceIdentifier, playbackUrl, identifier, refreshAssetUrl]);
103106

104107
return null;
105108
}

‎docs/internals/mobile-navigation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ opening overlay before presentation.
9494
The URL is captured once per preview so credential refresh does not restart playback.
9595
Media actions (copy path, open in file viewer, save or share) belong to the surface that
9696
opened the video, a long-press on the thumbnail, so the player carries no
97-
menu. AVKit has no retry; a failed mint alerts and closes, and the next open mints again.
97+
menu. AVKit has no retry; a failure alerts and closes, re-mints the URL in the background, and the next open plays from the fresh one.
9898

9999
The native presentation promise completes after dismissal. Local draft previews
100100
hold their file lease until that promise settles. The iOS preview component requests

0 commit comments

Comments
 (0)