Skip to content

Fix forwarded voice notes autoplaying audio from another chat. - #6340

Closed
bhanage-viraj wants to merge 1 commit into
signalapp:mainfrom
bhanage-viraj:fix/forwarded-voice-message-autoplay
Closed

bhanage-viraj wants to merge 1 commit into
signalapp:mainfrom
bhanage-viraj:fix/forwarded-voice-message-autoplay

Conversation

@bhanage-viraj

Copy link
Copy Markdown
Contributor

Attachments are deduplicated by content, so finishing playback in one conversation could match a stale listener in another and start the wrong next message.

Contributor checklist

Administrative:

Commits and testing:

  • My commits are rebased on the latest main branch.
  • My commits are well-structured for review.
  • My change has been thoroughly tested, and I am not aware of any regressions to existing features or behaviors.
  • I have tested my contribution on these devices:
    • iPhone 17, iOS 26.6.1
    • iPhone Simulator, iOS 26.6.1

Description

Fixes #6339.

Problem: After forwarding a voice message from one chat to another and playing it, the app would incorrectly autoplay the next voice message from the original chat instead of staying in the chat where playback actually happened.

Root cause: CVAudioPlayer is a single app-wide singleton, and when playback finishes it broadcasts to every registered CVAudioPlayerListener across all open conversations. Signal deduplicates attachments by content, so a forwarded voice message shares its underlying attachmentId with the original. The existing audioPlayerDidFinish guard only checked attachmentId, so a stale listener still registered from the source conversation could match on that shared id and trigger its own (unrelated) autoplay of the next message in a different chat.

Fix: Added the owning interaction id of the attachment that finished playing to the CVAudioPlayerListener.audioPlayerDidFinish callback, and updated CVComponentAudioAttachment to also require that id to match its own message's id before autoplaying. This disambiguates by "which specific message finished" rather than "which attachment content is shared", so playback finishing in one conversation can no longer trigger autoplay logic captured by a listener belonging to a different conversation.

Testing:

  • Reproduced the bug from Playing forwarded voice messages will autoplay the next voice message from the wrong chat #6339 exactly as described (recorded 2 voice messages in chat A, forwarded the first to chat B, played it in chat B) — confirmed the wrong message no longer autoplays after this fix.
  • Verified the correct-path regression case still works: recording a new voice message directly in chat B after forwarding still autoplays as expected.
  • Verified normal sequential voice message autoplay within a single conversation (no forwarding involved) is unaffected.

Attachments are deduplicated by content, so finishing playback in one conversation could match a stale listener in another and start the wrong next message.
@bhanage-viraj

Copy link
Copy Markdown
Contributor Author

@sashaweiss-signal This pull request is ready for review

@sashaweiss-signal

Copy link
Copy Markdown
Contributor

Hi, thanks for this, and for signing the CLA. I've copied this diff into an internal PR, since there were a number of additional fixes I made on top of it. I'll ensure that this commit is merged internally with your authorship attached.

Once that merges, I'll close this PR and comment with the internal hash of your commit (for when it eventually becomes public)!

@sashaweiss-signal

Copy link
Copy Markdown
Contributor

This merged internally as 9dc8c90, which will become available with an upcoming release (should be in the next week). Thanks again for the contribution!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playing forwarded voice messages will autoplay the next voice message from the wrong chat

2 participants