Skip to content

fix: audio recording and playing crashes [WPB-16687] [WPB-16835] 🍒 #3956

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

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 2, 2025

This PR was automatically cherry-picked based on the following PR:

Original PR description:


BugWPB-16687 [Android] App crashes when second audio is recorded after playing the first before sending


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

This PR contains fixes for two issues related to recording and playing audio messages:
https://wearezeta.atlassian.net/browse/WPB-16687
https://wearezeta.atlassian.net/browse/WPB-16835

Issues

The app crashes when attempting to send an audio recording for the second time because the user played the 1st recording before sending it.
The app crashes when attempting to play an audio message after sending it.

Causes (Optional)

  • MediaPlayer being released after closing or sending a message so it cannot be reused again
  • audio focus not being abandoned correctly and receiving audiofocus loss when trying to record again
  • trying to pause audio when there is no audio being played and MediaPlayer is not initialised
  • asset file path is being changed from temporary to proper one after uploading and player keeps the temporary path

Solutions

  • do not release MediaPlayer after sending or closing, it can be reused then (the same instance is persisted as long as the view model exists)
  • abandon focus when closing the recording
  • fix abandonExclusive function to abandon exclusiveFocusRequest and not regular focusRequest
  • check if there is any current audio set before trying to pause or resume
  • implement missing "uploading" audio message state so that view model is not injected while the path can change
  • execute getting asset again when the resulting file does not exist anymore

Testing

How to Test

Steps to Reproduce:

1
-record an audio message
-play the recording before sending it
-send the audio message
-attempt to make another audio recording

2
-record an audio message
-send it
-attempt to play it from the audio message cell

Attachments (Optional)

record-play-send-and-record-again.mp4
play_after_uploading.mp4
image

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@github-actions github-actions bot added cherry-pick PR is cherry-picking changes from another banch size/M labels Apr 2, 2025
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 32.25806% with 21 lines in your changes missing coverage. Please review.

Project coverage is 45.55%. Comparing base (e15daac) to head (36dd0aa).

Files with missing lines Patch % Lines
...oid/media/audiomessage/RecordAudioMessagePlayer.kt 0.00% 11 Missing ⚠️
...tions/model/messagetypes/audio/AudioMessageType.kt 0.00% 8 Missing ⚠️
...ire/android/media/audiomessage/AudioFocusHelper.kt 0.00% 1 Missing ⚠️
...dia/audiomessage/ConversationAudioMessagePlayer.kt 90.90% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (32.25%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3956      +/-   ##
===========================================
- Coverage    45.57%   45.55%   -0.02%     
===========================================
  Files          518      518              
  Lines        17959    17971      +12     
  Branches      3041     3044       +3     
===========================================
+ Hits          8184     8186       +2     
- Misses        8936     8946      +10     
  Partials       839      839              
Files with missing lines Coverage Δ
...essagecomposer/recordaudio/RecordAudioViewModel.kt 65.28% <ø> (+0.15%) ⬆️
...ire/android/media/audiomessage/AudioFocusHelper.kt 0.00% <0.00%> (ø)
...dia/audiomessage/ConversationAudioMessagePlayer.kt 66.04% <90.90%> (+0.38%) ⬆️
...tions/model/messagetypes/audio/AudioMessageType.kt 0.00% <0.00%> (ø)
...oid/media/audiomessage/RecordAudioMessagePlayer.kt 1.13% <0.00%> (-0.05%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e15daac...36dd0aa. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor Author

github-actions bot commented Apr 2, 2025

Built wire-android-staging-compat-pr-3956.apk is available for download

Copy link
Contributor Author

github-actions bot commented Apr 2, 2025

Built wire-android-dev-debug-pr-3956.apk is available for download

@saleniuk saleniuk requested review from a team, vitorhugods, Garzas, ohassine, saleniuk and mathias-niboulies and removed request for a team April 3, 2025 07:59
@MohamadJaara MohamadJaara added this pull request to the merge queue Apr 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Apr 4, 2025
saleniuk added 2 commits April 4, 2025 21:16
…udio-recording-and-playing-crashes-cherry-pick

# Conflicts:
#	app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageContentAndStatus.kt
#	app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/audio/AudioMessageType.kt
Copy link

sonarqubecloud bot commented Apr 4, 2025

Copy link
Contributor Author

github-actions bot commented Apr 4, 2025

Built wire-android-staging-compat-pr-3956.apk is available for download

Copy link
Contributor Author

github-actions bot commented Apr 4, 2025

Built wire-android-dev-debug-pr-3956.apk is available for download

@saleniuk saleniuk added this pull request to the merge queue Apr 4, 2025
Merged via the queue into develop with commit 3b89284 Apr 4, 2025
13 of 14 checks passed
@saleniuk saleniuk deleted the fix/audio-recording-and-playing-crashes-cherry-pick branch April 4, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick PR is cherry-picking changes from another banch size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants