Skip to content
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

Voice Broadcast - Stop recording on app restart #7450

Merged

Conversation

Florian14
Copy link
Contributor

@Florian14 Florian14 commented Oct 25, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Stop the recording when opening the room timeline after an application crash or restart
Also, handled already paused VB before pausing again when the timeline is not shown anymore

Motivation and context

The voice broadcast is stuck in a recording state when the app is not active anymore, until we improve the code to be able to resume a VB from the last sequence, it is better to stop it as soon as we detect the wrong recording state

Screenshots / GIFs

Tests

  • Start record a voice broadcast
  • Kill the app
  • Open the app and go to the room where you were recording
  • Verify that the VB is automatically stopped

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Florian14 Florian14 changed the base branch from develop to feature/fre/voice_broadcast_timeline_improvements October 25, 2022 15:03
@Florian14 Florian14 changed the title Feature/fre/voice broadcast stop on app restart Voice Broadcast - Stop recording on app restart Oct 25, 2022
@Florian14 Florian14 requested review from a team and onurays and removed request for a team October 25, 2022 15:03
@Florian14 Florian14 changed the base branch from feature/fre/voice_broadcast_timeline_improvements to feature/fre/voice_broadcast_device_id October 25, 2022 15:42
@Florian14 Florian14 marked this pull request as draft October 25, 2022 15:49
@Florian14
Copy link
Contributor Author

Moved to draft for the moment, I detected an issue

@Florian14 Florian14 force-pushed the feature/fre/voice_broadcast_device_id branch from 1b7928e to a4eff0c Compare October 25, 2022 15:56
@Florian14 Florian14 force-pushed the feature/fre/voice_broadcast_stop_on_app_restart branch from a154db9 to 85bc78b Compare October 26, 2022 07:52
@Florian14 Florian14 marked this pull request as ready for review October 26, 2022 07:52
private fun stopOngoingVoiceBroadcast() {
val session = activeSessionHolder.getSafeActiveSession() ?: return

// FIXME Iterate only on recent rooms for the moment, improve this
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be fixed in a dedicated PR, it should be enough for the moment

@mnaturel mnaturel self-requested a review October 26, 2022 09:08
* Stop ongoing voice broadcast if any.
*/
private fun stopOngoingVoiceBroadcast() {
val session = activeSessionHolder.getSafeActiveSession() ?: return
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is possible to encapsulate all this code in a dedicated UseCase such as StopOngoingVoiceBroadcastUseCase? We could add unit tests on it later.

import javax.inject.Inject

class GetOngoingVoiceBroadcastsUseCase @Inject constructor(
private val session: Session,
Copy link
Contributor

@mnaturel mnaturel Oct 26, 2022

Choose a reason for hiding this comment

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

I think we should use ActiveSessionHolder instead. @bmarty what do you think about this suggestion?


Timber.d("## GetLastVoiceBroadcastUseCase: get last voice broadcast in $roomId")

return room.stateService().getStateEvents(
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if we should use getStateEvent() instead. I think the issue may only happen for the last emitted state event of the room right? If we use getStateEvents it will go through every saved state events which may be a big list in large room.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mnaturel Not sure, in Element, we cannot have more than one ongoing VB in a room. But "advanced users" or other clients are still allowed to send new state events with different state keys and we'll have several ongoing VB from several users...

Base automatically changed from feature/fre/voice_broadcast_device_id to resilience-rc October 26, 2022 09:54
Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

LGTM. I have only added some small comments.

@sonarcloud
Copy link

sonarcloud bot commented Oct 26, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

22.6% 22.6% Coverage
0.0% 0.0% Duplication

@Florian14 Florian14 merged commit 6ee77ad into resilience-rc Oct 26, 2022
@Florian14 Florian14 deleted the feature/fre/voice_broadcast_stop_on_app_restart branch October 26, 2022 13:49
@@ -31,8 +31,12 @@ class GetOngoingVoiceBroadcastsUseCase @Inject constructor(
) {

fun execute(roomId: String): List<VoiceBroadcastEvent> {
val session = activeSessionHolder.getSafeActiveSession() ?: return emptyList()
val room = session.getRoom(roomId) ?: error("Unknown roomId: $roomId")
println("## GetOngoingVoiceBroadcastsUseCase")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this println? If we want to keep some logs, we should use Timber instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch... will create a new PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

None yet

2 participants