You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): abort abandoned video thumbnail extractions and deduplicate in-flight loads - #40889
When a mobile user taps Play on a chat video or leaves a thread while VideoThumbnailImage is still extracting frame 0 over a slow T3 Connect relay link (#40878), loadVideoThumbnail lets the hidden expo-video player keep running for up to 15 seconds:
extractFrame(uri) did not accept an AbortSignal, so unmounting VideoThumbnailImage (e.g. tapping Play or switching threads) left the thumbnail player open and competing for relay bandwidth with the main playback player — and blocking all other queued posters behind the 15 s timeout.
Concurrent calls for the same thumbnail key (such as MediaVideoPlayer's fitToVideo sizing effect and VideoThumbnailImage) were not deduplicated in flight, so a failed or timed-out extraction could trigger a second full 15 s extraction.
When timedOut won Promise.race([frame, timedOut]), releasing the native player in finally could cause the in-flight frame IIFE to reject without a .catch() handler.
Change
Track active readers per in-flight thumbnail key in apps/mobile/src/lib/videoThumbnails.ts and deduplicate concurrent calls for the same key.
Pass an AbortSignal into extractFrame(uri, signal) and race frame extraction against abort and the 15 s timeout, releasing the native player and disposing the source immediately when no reader remains.
Defer abort by a single microtask (queueMicrotask) when the last reader aborts so a re-signed URL mounting for the same key in the same render/tick still reuses the in-flight extraction without restarting it.
Attach .catch(() => null) to the internal frame promise so late native rejections after player.release() never surface as unhandled rejections.
Add unit tests in apps/mobile/src/lib/videoThumbnails.test.ts covering aborting abandoned extractions, deduplicating failed concurrent loads, and swallowing late post-release rejections.
vp test run apps/mobile/src/lib/videoThumbnails.test.ts apps/mobile/src/lib/useMediaVideoPlayback.test.tsx: 18/18 passed (7 in videoThumbnails.test.ts including the 3 new cases and the existing re-signed URL handoff case; 11 in useMediaVideoPlayback.test.tsx).
vp run check:changed: format, lint (0 warnings/errors), knip (1/2 and 2/2), typecheck (2 packages), tests (2 files), and React Compiler coverage all passed.
Not checked on a physical iOS/Android device or simulator (Windows host); verified via the mobile unit and React test suites.
No actionable comments were generated in the recent review.
Walkthrough
The video thumbnail loader now shares active extractions for the same key and tracks each caller as a reader. When no readers remain, it aborts the extraction. Tests cover cancellation, shared failures, and native rejection after player release.
Frame extraction checks for abort, races extraction against abort and timeout, and cleans up after failures. A test covers native rejection after an aborted player is released.
Shared requests and reader cleanup apps/mobile/src/lib/videoThumbnails.ts, apps/mobile/src/lib/videoThumbnails.test.ts
Requests with the same key share an active extraction. The loader aborts the extraction when its final reader leaves and removes the in-flight entry. Tests cover reader cancellation and shared extraction failure.
pingdotgg/t3code#32196 — Both changes reuse in-flight thumbnail extractions for the same video.
pingdotgg/t3code#40597 — Both changes handle abandoned thumbnail loads by releasing the player and discarding late extraction results.
pingdotgg/t3code#37172 — The PR’s inline sizing reuses cached video preview extraction, which this change modifies with reader tracking and cancellation.
Abandoned video thumbnail extractions are now aborted and concurrent loads for the same key share one extraction, which frees the player for queued posters. No concrete merge-blocking issue was found; the remaining gap is that physical iOS and Android devices were not exercised.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main changes: aborting abandoned video thumbnail extractions and deduplicating in-flight loads. Both match the summary and objectives. It follows conventional commit format and…
Description check
The description follows the template. It has Problem, Change, Scope (links #40878 as related and explains the bug), and Verification sections. Verification lists the exact test commands, pass counts, …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the two main changes: aborting abandoned video thumbnail extractions and deduplicating in-flight loads. Both match the summary and objectives. It follows conventional commit format and is specific to the mobile app.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope (links #40878 as related and explains the bug), and Verification sections. Verification lists the exact test commands, pass counts, and states what was not checked (physical devices, simulators). The model line is included as the template asks. The Scope section does not clearly say why the fix needs no separate issue, and it links #40878 only as 'Related'. The template asks for a linked issue that shows the bug, so this is a minor gap. The description also does not state that no UI change was made, so the screenshot requirement is not addressed.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between ad2bdc7 and 9bc64d1.
Files selected for processing: 2
apps/mobile/src/lib/videoThumbnails.test.ts
apps/mobile/src/lib/videoThumbnails.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
size:M30-99 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Problem
When a mobile user taps Play on a chat video or leaves a thread while
VideoThumbnailImageis still extracting frame 0 over a slow T3 Connect relay link (#40878),loadVideoThumbnaillets the hiddenexpo-videoplayer keep running for up to 15 seconds:extractFrame(uri)did not accept anAbortSignal, so unmountingVideoThumbnailImage(e.g. tapping Play or switching threads) left the thumbnail player open and competing for relay bandwidth with the main playback player — and blocking all other queued posters behind the 15 s timeout.key(such asMediaVideoPlayer'sfitToVideosizing effect andVideoThumbnailImage) were not deduplicated in flight, so a failed or timed-out extraction could trigger a second full 15 s extraction.timedOutwonPromise.race([frame, timedOut]), releasing the native player infinallycould cause the in-flightframeIIFE to reject without a.catch()handler.Change
keyinapps/mobile/src/lib/videoThumbnails.tsand deduplicate concurrent calls for the same key.AbortSignalintoextractFrame(uri, signal)and race frame extraction against abort and the 15 s timeout, releasing the native player and disposing the source immediately when no reader remains.queueMicrotask) when the last reader aborts so a re-signed URL mounting for the same key in the same render/tick still reuses the in-flight extraction without restarting it..catch(() => null)to the internalframepromise so late native rejections afterplayer.release()never surface as unhandled rejections.apps/mobile/src/lib/videoThumbnails.test.tscovering aborting abandoned extractions, deduplicating failed concurrent loads, and swallowing late post-release rejections.Related: #40878
Verification
vp test run apps/mobile/src/lib/videoThumbnails.test.ts apps/mobile/src/lib/useMediaVideoPlayback.test.tsx: 18/18 passed (7 invideoThumbnails.test.tsincluding the 3 new cases and the existing re-signed URL handoff case; 11 inuseMediaVideoPlayback.test.tsx).vp run check:changed: format, lint (0 warnings/errors), knip (1/2 and 2/2), typecheck (2 packages), tests (2 files), and React Compiler coverage all passed.Model: Gemini 4 Neon (via T3 Code)