Skip to content

Fix infinite GIF reader loop on zero-frame streams - #2315

Open
XXcipherX wants to merge 1 commit into
TelegramMessenger:masterfrom
XXcipherX:fix/gif-reader-infinite-loop
Open

Fix infinite GIF reader loop on zero-frame streams#2315
XXcipherX wants to merge 1 commit into
TelegramMessenger:masterfrom
XXcipherX:fix/gif-reader-infinite-loop

Conversation

@XXcipherX

Copy link
Copy Markdown

BatchVideoRenderingContext repeatedly reopened an FFmpeg reader when a stream reached EOF without producing any frames. This caused a synchronous decoding loop, sustained CPU usage, and blocked GIF rendering.

Track whether the reader has produced a frame. Restart it only after it has produced at least one frame; treat zero-frame EOF as a decoding failure.

Testing

Verified with the focused BatchVideoRenderingTests regression harness on GitHub Actions using Xcode 26.2 and iOS 26.2:

https://github.com/XXcipherX/telegram-ios-gif-regression-test/actions/runs/33513158372

Fixes #2246

Stop reopening an FFmpeg reader that reaches EOF before producing a frame, preventing repeated synchronous decoding.

Fixes TelegramMessenger#2246
@CLAassistant

CLAassistant commented Sep 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saved GIFs panel: infinite decode loop + permanent 100% CPU hang on unsupported pixel format (e.g. H.264 4:4:4)

2 participants