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

Feature/fga/start sync on push #3260

Merged
merged 4 commits into from
Aug 1, 2024
Merged

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Jul 31, 2024

Content

#3257 wasn't enough, so try to sync and waits for the event in the timeline if the app is in background.

Motivation and context

Improve on top of #3257

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

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

@ganfra ganfra added the PR-Misc For other changes label Jul 31, 2024
@ganfra ganfra marked this pull request as ready for review July 31, 2024 19:16
@ganfra ganfra requested a review from a team as a code owner July 31, 2024 19:16
@ganfra ganfra requested review from jmartinesp and removed request for a team July 31, 2024 19:16
Copy link
Contributor

github-actions bot commented Jul 31, 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/XQSTXa

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, although I have my doubts about startSyncIfNeeded() and its stop counterpart.

if (!appForegroundStateService.isInForeground.value) {
val syncService = client.syncService()
syncService.startSyncIfNeeded()
room.waitsUntilEventIsKnown(eventId = notifiableEvent.eventId, timeout = 10.seconds)
Copy link
Member

Choose a reason for hiding this comment

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

When I was doing similar tests what I did here was just wait until the syncState was Running, which I believe is enough to mean the first sync has been received. But we can keep this to make it more explicit, it will probably even work better.

Copy link
Member Author

Choose a reason for hiding this comment

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

No waiting for running is not enough, the data usually comes after several sync iterations

}

private suspend fun SyncService.startSyncIfNeeded() {
if (syncCounter.getAndIncrement() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to just check the syncService state? What if some other part of the app started a sync on its own?

Copy link
Member Author

@ganfra ganfra Aug 1, 2024

Choose a reason for hiding this comment

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

The counter is just to avoid cancelling if there are other pushes received in parallel.
If the sync is already started from somewhere else, this won't have any effect.
If the app is backgrounded again it will cancel the sync anyway.
So, in the end, this is just best effort.

@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 1, 2024
@ganfra ganfra enabled auto-merge August 1, 2024 09:21
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 1, 2024
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 76.18%. Comparing base (6b8dba6) to head (d8532c0).
Report is 9 commits behind head on develop.

Files Patch % Lines
.../libraries/push/impl/push/SyncOnNotifiableEvent.kt 80.76% 1 Missing and 4 partials ⚠️
...raries/push/impl/push/OnNotifiableEventReceived.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3260      +/-   ##
===========================================
+ Coverage    76.16%   76.18%   +0.02%     
===========================================
  Files         1648     1650       +2     
  Lines        38825    38848      +23     
  Branches      7532     7536       +4     
===========================================
+ Hits         29570    29596      +26     
+ Misses        5353     5347       -6     
- Partials      3902     3905       +3     

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

@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 1, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 1, 2024
@ganfra ganfra merged commit 8a3489c into develop Aug 1, 2024
31 of 32 checks passed
@ganfra ganfra deleted the feature/fga/start_sync_on_push branch August 1, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Misc For other changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants