-
Notifications
You must be signed in to change notification settings - Fork 41
fix: crashes on audio message playback [WPB-16195] #3912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rash-audio-message-playback
Built wire-android-staging-compat-pr-3912.apk is available for download |
Built wire-android-dev-debug-pr-3912.apk is available for download |
…to 9 (#3910) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yamil Medina <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice improvement 🚀
app/src/main/kotlin/com/wire/android/media/audiomessage/ConversationAudioMessagePlayer.kt
Outdated
Show resolved
Hide resolved
Ups 🫰🟨This PR is too big. Please try to break it up into smaller PRs. |
@saleniuk looks like you are rolling back kalium to a previous commitish. This means that the PR's target branch (develop) is using a newer version of Kalium, and the changes in this PR will rollback Kalium to an older version.
Is this intentional? |
…into fix/crash-audio-message-playback
@saleniuk looks like you are rolling back kalium to a previous commitish. This means that the PR's target branch (develop) is using a newer version of Kalium, and the changes in this PR will rollback Kalium to an older version.
Is this intentional? |
|
closing in favour of the one that will be merged to RC first: #3917 |
Built wire-android-staging-compat-pr-3912.apk is available for download |
Built wire-android-dev-debug-pr-3912.apk is available for download |
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
The app crashes as soon as the user taps the play button on audio message.
Causes (Optional)
Race condition when fetching audio asset file - it can be executed multiple times at once as it's also called to fetch waves mask and then asset file can be overwritten and broken (created but empty for instance) resulting in a crash when trying to play empty file.
The "fetch waves mask" action can also be called multiple times for each message as it's called every time paging data is updated. The whole map of audio states is propagated through all composables all way down from the screen to the
AudioMessage
item and it's not stable so it can be also prone to more unneeded recompositions.ConversationAudioMessagePlayer
dropping and losing some of the crucial states emitted because ofDROP_OLDEST
and for instance making the audio message be played without any indication on the screen.Solutions
Secured
getAssetMessage
by keeping the deferred until it's completed so that each execution during that time will reuse the same deferred and it won't be called multiple times at the same time - no issues with overwriting the file and no unnecessary requests.Created dedicated scoped
AudioMessageViewModel
which handles the state for the given message and executes calls to play the audio associated with that message, change the audio speed or fetch waves mask for that audio so that it happens only once and is kept in the view model. Thanks to that, a map with all audio states doesn't need to be passed all the way to theAudioMessage
but instead it uses state from injected scopedAudioMessageViewModel
.Replaced
DROP_OLDEST
withSUSPEND
inConversationAudioMessagePlayer
to not lose any state updates.Testing
Test Coverage (Optional)
How to Test
Receive audio messages and try to play them.
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.