Incorrect voice messages duration
- [x] I have searched open and closed issues for duplicates
- [x] I am submitting a bug report for existing functionality that does not work as intended
- [x] This isn't a feature request or a discussion topic
Bug description
When a voice message is received, it is shown that the length is (let’s say) 14 seconds, instead the audio will reproduce for 17 seconds.
Steps to reproduce
- receive a voice message
- click play to reproduce
- wait until it reaches the “end”, but it goes on for 3/4 seconds more
Actual result: voice message is longer than expected
Expected result: voice message length should be the exact duration of the audio
Screenshots

Device info
Device: iPhone 8 Plus
iOS version: 11.4
Signal version: 2.29.0.16 beta
Link to debug log
https://debuglogs.org/56a3b60e3fce2dbdf310b822c27c98bf95c50748b54b9e46efabd977f1950f20.zip
Can you open a thread with yourself and leave yourself a voice message - does this occur?
Or does it only occur with this one recipient?
Does it occur with every voice message they send you, or just this one?
Well, it seems that the problem affects only this particular recipient. He has an Android device (LG G4) with the latest stable version.
No problems when receiving from an iPhone user or sending to myself.
Seems like they might be sending you a malformed audio file. Do you know what device/OS version they are on?
Confirm. Wrong duration with Android client.
If useful, desktop app shows the correct duration. So maybe it's not caused by a malformed audio file.
This looks related to #3086. I did a bit of digging into how this might happen; there's some stackoverflow posts about a weird quirk of AVAudioPlayer returning an estimated duration for files it hasn't actually prepared to play (the official docs are silent on this, but I saw a mention of this trait elsewhere as well). @michaelkirk-signal I could make a PR if you want, but I can't reproduce the issue to verify that it works, so it's your call.
An audio file that reproduces this behavior would be super helpful.
@michaelkirk-signal if you need a audio file with incorrect duration you can contact me... [email protected]
Steps to reproduce:
- Generate an audio message on Android of sufficient length using Signal, and send it to an iPhone user. You do not need to do this, the attached m4a file will reproduce this behavior.
- Unzip and send the attached m4a file to yourself in Signal iOS.
- Signal-iOS reports the received file as 26 seconds in length.
- Play the file. Actual file duration played is 29 seconds.
It's not clear from the documentation, but AVAudioPlayer apparently won't return an exact length of certain types of audio files without doing a certain amount of preprocessing. I'll make a pull request.