Skip to content

Conversation

@VelikovPetar
Copy link
Contributor

🎯 Goal

Fixes several StrictMode violations from the AudioRecordingController related to accessing the disk on main thread.

🛠 Implementation details

  • Make AudioRecordingController startRecording, stopRecording and completeRecording suspend
  • startRecording: wrap mediaRecorder.startAudioRecording with withContext(DispatcherProvider.IO) to ensure it is run on IO
  • stopRecording: wrap mediaRecorder.stopRecording() with withContext(DispatcherProvider.IO) to ensure it is run on IO
  • completeRecording: wrap mediaRecorder.stopRecording() with withContext(DispatcherProvider.IO) to ensure it is run on IO and post state updates on Main to ensure they are processed in order
  • completeRecordingSync: Introduce a new method which returns the Result of the recording instead of updating the internal state. This was required to ensure the MessageComposerController.sendRecording() works properly, because it previously relied on the sequential execution of completeRecording (which is no longer the case)
  • call the changed method in a coroutine from the MessageComposerController
    Note: The corresponding methods from StreamMediaRecorder were not changed to suspend because it is public API.

🎨 UI Changes

Run the following tests, ensuring that nothing is broken + there are no related StrictMode violations in the LogCat (both compose and xml)

  1. Tap an hold recoding button -> sends the recording in chat
  2. Tap and hold + swipe up to lock the recording. Tap Stop, then Send -> sends the recording in chat
  3. Tap and hold + swipe up to lock the recording. Tap Send -> sends the recording in chat
  4. Set ChatTheme.messageComposerTheme.audioRecording.sendOnComplete to false - re-run the same tests: For cases 2 and 3, the recording should first be added to the composer, and sent only when tapping the Send button.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.25 MB 0.00 MB 🟢
stream-chat-android-offline 5.48 MB 5.48 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.59 MB 10.59 MB 0.00 MB 🟢
stream-chat-android-compose 12.82 MB 12.82 MB 0.00 MB 🟢

@VelikovPetar VelikovPetar marked this pull request as ready for review December 8, 2025 12:23
@VelikovPetar VelikovPetar requested a review from a team as a code owner December 8, 2025 12:23
Copy link
Contributor

@andremion andremion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, try to add unit tests to AudioRecordingController at least

@VelikovPetar
Copy link
Contributor Author

@andremion

If possible, try to add unit tests to AudioRecordingController at least

Added tests here: 672f73a

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
77.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@andremion andremion merged commit cbab8a0 into develop Dec 11, 2025
12 of 13 checks passed
@andremion andremion deleted the bug/AND-944_fix_strictmode_violations_audio_recording branch December 11, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants