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

Fix Element Call closing automatically on API 34 #3402

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Sep 5, 2024

Content

The leave hint listener for PiP in the Call screen is now registered once the UI is ready.

Motivation and context

It seems like registering a user leave hint listener way too early was causing the activity to try to enter PiP erroneously and that led to the activity closing instead.

Tests

  • Try to start a call in Android 14.
  • Most of the time (always, in my case) the screen would previously close automatically. It should now work as expected.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

It seems like registering a user leave hint listener way too early was causing the activity to try to enter PiP erroneously and that led to the activity closing instead.
Copy link
Contributor

github-actions bot commented Sep 5, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/vJDN94

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.62%. Comparing base (7e37bf4) to head (b791c54).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...droid/features/call/impl/ui/ElementCallActivity.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3402      +/-   ##
===========================================
- Coverage    82.62%   82.62%   -0.01%     
===========================================
  Files         1694     1694              
  Lines        39684    39685       +1     
  Branches      4831     4831              
===========================================
  Hits         32788    32788              
- Misses        5204     5205       +1     
  Partials      1692     1692              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

val onUserLeaveHintListener = Runnable {
pipEventSink(PictureInPictureEvents.EnterPictureInPicture)
var onUserLeaveHintListener by remember { mutableStateOf<Runnable?>(null) }
DisposableEffect(lifecycleState.isAtLeast(Lifecycle.State.STARTED)) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the DisposableEffect(lifecycleState.isAtLeast(Lifecycle.State.STARTED)), this will still launch the effect with value false, and then with value true

Copy link
Member Author

Choose a reason for hiding this comment

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

I just realised I had added the wrong check to the if above (copy&paste issue), so now it should:

  • Launch the side effect with false, but do nothing.
  • Launch the side effect again with true, this time register the listener.
  • If we go out of the call and then back again, the listener won't be registered again.
  • When the activity is finished the listener will also be removed.

I tried with simpler versions using LaunchedEffect and a lifecycle observer, but neither of them removed the listener when the activity was closed. Although maybe as the activity is being closed, it's not needed at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I was able to simplify it in b791c54. It seems like using lifecycleScope.launch is enough to make it wait until the UI is ready.

@jmartinesp jmartinesp force-pushed the fix/jme/element-call-auto-closes branch from 2750bd4 to b791c54 Compare September 5, 2024 10:45
Copy link

sonarcloud bot commented Sep 5, 2024

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

My test is now passing.
FTR, starting a call on API 34 was failing, since the Activity was finished just after being started.

@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Sep 5, 2024
@jmartinesp jmartinesp marked this pull request as ready for review September 5, 2024 13:58
@jmartinesp jmartinesp requested a review from a team as a code owner September 5, 2024 13:58
@jmartinesp jmartinesp requested review from ganfra and removed request for a team September 5, 2024 13:58
@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 5, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 5, 2024
@jmartinesp jmartinesp enabled auto-merge (squash) September 5, 2024 13:59
@jmartinesp jmartinesp merged commit 9f2db3e into develop Sep 5, 2024
31 of 32 checks passed
@jmartinesp jmartinesp deleted the fix/jme/element-call-auto-closes branch September 5, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants