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

Playback of Voice message stops whenever phone is rotated and changes orientation #4198

Closed
lullis opened this issue Oct 10, 2021 · 2 comments
Labels
A-Voice-Messages O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect Something isn't working: bugs, crashes, hangs and other reported problems

Comments

@lullis
Copy link

lullis commented Oct 10, 2021

Steps to reproduce

  1. Start playing a voice message that you received.
  2. Rotate the phone to change orientation portrait <-> landscape.

Intended result and actual result

What did you expect?

Voice message to be kept playing

What happened instead?

Voice message stops and reset (i.e, playing it again starts it from beginning)

Your phone model

Fairphone 3

Operating system version

/e/ OS

Application version and app store

F-Droid

Homeserver

No response

Have you submitted a rageshake?

No

@lullis lullis added the T-Defect Something isn't working: bugs, crashes, hangs and other reported problems label Oct 10, 2021
@lullis lullis changed the title Voice message playback whenever phone is rotated and changes orientation Playback of Voice message stops whenever phone is rotated and changes orientation Oct 10, 2021
@ZianeA
Copy link

ZianeA commented Oct 17, 2021

There are many approaches to handling this. WhatsApp, for example, plays voice messages in a foreground service. Youtube, on the other hand, seems to handle rotation by pausing the playback after a delay. If the onResume callback method is called within that delay, the video is never paused.

However, after I've investigated the bug, I found other related issues:

DI issue:

VoiceMessagePlaybackTracker is annotated with @ScreenScope, so it's scoped to the screen (Activity). Whenever the system recreates the Activity due to configuration changes (including but not limited to rotation), Dagger injects it with a new instance of VoiceMessagePlaybackTracker. The problem is that the RoomDetailViewModel has a transitive dependency on VoiceMessagePlaybackTracker. Since the ViewModel survives configuration changes, which means it has a longer lifespan, its instance of VoiceMessagePlaybackTracker will be different from that of the Activity after configuration changes.

A possible solution to this problem is to add the playback time to the screen state instead of a separate object.

Other issues:

  • There could be concurrency issues with the VoiceMessageHelper class. The RoomDetailViewModel invokes the startOrPausePlayback function from a background thread where it modifies the shared mutable variable mediaPlayer.

  • Per the Android docs, it's recommended to release the MediaPlayer when not used.

@ouchadam
Copy link
Contributor

closing as a duplicate of #4067, will be fixed with #4556

@ouchadam ouchadam added A-Voice-Messages O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist labels Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Voice-Messages O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect Something isn't working: bugs, crashes, hangs and other reported problems
Projects
None yet
Development

No branches or pull requests

3 participants