Skip to content

Improve FetchPushForegroundService's reliability#6757

Open
jmartinesp wants to merge 1 commit intodevelopfrom
fix/improve-fetch-push-foreground-service-reliability
Open

Improve FetchPushForegroundService's reliability#6757
jmartinesp wants to merge 1 commit intodevelopfrom
fix/improve-fetch-push-foreground-service-reliability

Conversation

@jmartinesp
Copy link
Copy Markdown
Member

Content

  • Don't use DI, we can just create the notification channel. This should speed up the creation of the service and reduce the number of ForegroundServiceDidNotStartInTimeException received. Also use MainScope instead of the app's coroutine scope.
  • Move the wakelock releasing mechanism to onDestroy so it's always used. Previously, this would only happen when stopService was called, which would only happen when stopSelf() is called, but not when the OS or the service manager stops the service.

Motivation and context

Fix the ForegroundServiceDidNotStartInTimeException we're still seeing in Sentry.

Tests

Just use notifications as usual.

Tested devices

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

Checklist

  • This PR was made with the help of AI:
    • Yes. I asked Claude what could be causing the issues, which confirmed a suspicion of mine and also added a possible cause I hadn't identified.
    • 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

- Don't use DI, we can just create the notification channel. This should speed up the creation of the service and reduce the number of `ForegroundServiceDidNotStartInTimeException` received. Also use `MainScope` instead of the app's coroutine scope.
- Move the wakelock releasing mechanism to `onDestroy` so it's always used. Previously, this would only happen when `stopService` was called, which would only happen when `stopSelf()` is called, but not when the OS or the service manager stops the service.
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label May 8, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.21%. Comparing base (4a4b3e0) to head (58a1b05).

Files with missing lines Patch % Lines
...aries/push/impl/push/FetchPushForegroundService.kt 0.00% 19 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6757      +/-   ##
===========================================
- Coverage    81.22%   81.21%   -0.01%     
===========================================
  Files         2633     2633              
  Lines        73426    73433       +7     
  Branches      9490     9491       +1     
===========================================
  Hits         59638    59638              
- Misses       10300    10307       +7     
  Partials      3488     3488              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📱 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/KWfXfY

@jmartinesp jmartinesp marked this pull request as ready for review May 8, 2026 13:32
@jmartinesp jmartinesp requested a review from a team as a code owner May 8, 2026 13:32
@jmartinesp jmartinesp requested review from ganfra and removed request for a team May 8, 2026 13:32
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.

1 participant