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

Run SyncService.start() and stop() with a non-UI dispatcher #4133

Closed
wants to merge 1 commit into from

Conversation

jmartinesp
Copy link
Member

Content

Run SyncService.start() and SyncService.stop() using a background dispatcher.

Motivation and context

The Rust code doesn't seem to handle coroutine cancellation in a nice way, so sometimes when the sync service too a bit longer than expected to run and several syncs tried to start at the same time a deadlock happened which blocked the main thread in Android.

Tests

To make testing easier, since I wasn't able to reproduce this issue on my test devices I built this branch of the SDK to make deadlocks more probable.

Then I opened the app and kept backgrounding it, then opening it back non-stop in short amounts of time: without this patch, I'd have an ANR at 5-6s max. With the patch I couldn't trigger it.

Tested devices

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

Checklist

  • 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 define 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

@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Jan 10, 2025
@jmartinesp jmartinesp requested a review from a team as a code owner January 10, 2025 13:39
@jmartinesp jmartinesp requested review from ganfra and removed request for a team January 10, 2025 13:39
Copy link
Contributor

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

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.26%. Comparing base (63dbf93) to head (dccb73c).
Report is 19 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4133   +/-   ##
========================================
  Coverage    83.26%   83.26%           
========================================
  Files         1885     1885           
  Lines        49127    49127           
  Branches      5774     5774           
========================================
  Hits         40907    40907           
  Misses        6144     6144           
  Partials      2076     2076           

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

@jmartinesp jmartinesp marked this pull request as draft January 10, 2025 14:20
@jmartinesp jmartinesp closed this Jan 14, 2025
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