Skip to content

Fix wakelock not being released when EC returns an error#6752

Closed
bxdxnn wants to merge 1 commit into
element-hq:developfrom
bxdxnn:fix/call-error-wakelock
Closed

Fix wakelock not being released when EC returns an error#6752
bxdxnn wants to merge 1 commit into
element-hq:developfrom
bxdxnn:fix/call-error-wakelock

Conversation

@bxdxnn

@bxdxnn bxdxnn commented May 7, 2026

Copy link
Copy Markdown
Contributor

Content

Release wakelock when Element Call exits with an error

Motivation and context

It wasn't released, and so I had the proximity sensor active even when I've closed Element Call.

Screenshots / GIFs

Tests

  • Close the Element Call error dialog (e.g. on an unsupported server) then test if the screen doesn't turns off on the proximity sensor

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • 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 defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@bxdxnn bxdxnn requested a review from a team as a code owner May 7, 2026 21:07
@bxdxnn bxdxnn requested review from ganfra and removed request for a team May 7, 2026 21:07
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • If your pull request adds a feature or modifies the UI, this should have an equivalent pull request in the Element X iOS repo unless it only affects an Android-only behaviour or is behind a disabled feature flag, since we need parity in both clients to consider a feature done. It will also need to be approved by our product and design teams before being merged, so it's usually a good idea to discuss the changes in a Github issue first and then start working on them once the approach has been validated.
  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

@jmartinesp

jmartinesp commented May 20, 2026

Copy link
Copy Markdown
Member

I just tested this branch and I don't think it's solving the issue. If I got it right, the issue seems to be WebView.onCallStopped is called and that should in turn launch a coroutine that releases the wakelock... but the provided coroutine scope is already cancelled at that point, so the code inside the coroutineScope.launch { ... } block never runs.

I believe since the WebView was destroyed, it would be OK to not use the proximitySensorMutex at all there, not needing to use the coroutine scope to launch a coroutine either and just calling:

if (proximitySensorWakeLock?.isHeld == true) {
    proximitySensorWakeLock?.release()
}

Directly inside the method.


Yep, that seemed to do the trick when I just tested it. I'll leave it up to you to update the PR, otherwise let me know and I can create a new one with the mentioned changes.

@bxdxnn

bxdxnn commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@jmartinesp thanks for investigating this, I would prefer for you to fix it properly, I'm not very familiar with the logic here.

@bxdxnn bxdxnn closed this May 20, 2026
@bxdxnn bxdxnn deleted the fix/call-error-wakelock branch May 20, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants