Fix IndexOutOfBounds crash when sending media with an undecodable preview#7050
Open
Narasimha-sc wants to merge 2 commits into
Open
Fix IndexOutOfBounds crash when sending media with an undecodable preview#7050Narasimha-sc wants to merge 2 commits into
Narasimha-sc wants to merge 2 commits into
Conversation
2d12dcb to
0f3c78f
Compare
…tOfBounds on send processPickedMedia appended to MediaPreview.content unconditionally for videos (and size-ok animated images) but only appended to images when a preview bitmap existed. getBitmapFromVideo returns a null preview for undecodable/corrupted videos without throwing, desyncing the two lists; sendMessageAsync then indexes images[index] past its end and crashes. Pair both appends behind a non-null bitmap so the lists stay equal-length and index-aligned, and skip only the bad item so the rest of the picked batch still sends. A video skipped this way shows showVideoDecodingException(), guarded by hasAlertsShown() so it neither stacks across multiple bad items nor duplicates the alert already shown on getBitmapFromVideo's exception path. Image decode failures are already surfaced earlier by getBitmapFromUri.
0f3c78f to
ad26b70
Compare
shumvgolove
approved these changes
Jun 8, 2026
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.
Problem. Sending a batch of picked media crashes with
IndexOutOfBoundsException(ComposeView.sendMessageAsync) when one of the items — typically a corrupted video — produces no preview frame.Cause.
processPickedMediaappended toMediaPreview.contentunconditionally for videos (and size-ok animated images) but only appended toimageswhen a preview bitmap existed;getBitmapFromVideoreturns a null preview for undecodable videos without throwing, desyncing the two index-aligned lists sosendMessageAsyncindexesimages[index]past its end.Fix. Pair both appends behind a single non-null-bitmap check so
contentandimagesalways stay equal-length and index-aligned; only the undecodable item is skipped while the rest of the batch still sends. A skipped video showsshowVideoDecodingException()(guarded byhasAlertsShown()so the alert neither stacks across multiple bad items nor duplicates the one already shown on the exception path) instead of being dropped silently. SharedcommonMainchange, so Android and Desktop are both covered.