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

Cleanup the background task that pauses the SDK when resigning active #903

Merged
merged 6 commits into from
May 19, 2023

Conversation

Velin92
Copy link
Member

@Velin92 Velin92 commented May 16, 2023

From the video you can see that only the third time I background the app (where I waited about 30 seconds) when I foregrounded it, I got back the loading indicator showing the the sync has restarted.

So we are extending the duration of the sync for 30 seconds after suspension, and then stopping it in the expiration handler

We restart the sync only if the app is coming from a suspended state and the sync was stopped.

Simulator.Screen.Recording.-.iPhone.14.-.2023-05-17.at.17.53.12.mp4

@Velin92 Velin92 requested a review from a team as a code owner May 16, 2023 16:21
@Velin92 Velin92 requested review from stefanceriu and removed request for a team May 16, 2023 16:21
@Velin92 Velin92 marked this pull request as draft May 16, 2023 16:21
@github-actions
Copy link

github-actions bot commented May 16, 2023

Warnings
⚠️ Some of the commits are missing ticket numbers. Please consider squashing all commits that don't have a tracking number.

Generated by 🚫 Danger Swift against 81b3eee

@Velin92 Velin92 linked an issue May 17, 2023 that may be closed by this pull request
@Velin92 Velin92 marked this pull request as ready for review May 17, 2023 15:46
@Velin92 Velin92 force-pushed the mauroromito/cleanup_bg_task branch from 352e0af to 9105b0b Compare May 17, 2023 15:47
@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.13 ⚠️

Comparison is base (03dece7) 49.31% compared to head (905a44d) 49.18%.

❗ Current head 905a44d differs from pull request most recent head 81b3eee. Consider uploading reports for the commit 81b3eee to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #903      +/-   ##
===========================================
- Coverage    49.31%   49.18%   -0.13%     
===========================================
  Files          329      329              
  Lines        19979    19996      +17     
  Branches     11037    11038       +1     
===========================================
- Hits          9852     9835      -17     
- Misses        9847     9883      +36     
+ Partials       280      278       -2     
Flag Coverage Δ
unittests 22.80% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
ElementX/Sources/Application/AppCoordinator.swift 50.47% <0.00%> (-2.78%) ⬇️
ElementX/Sources/Services/Client/ClientProxy.swift 41.00% <0.00%> (-1.83%) ⬇️
.../Sources/Services/Client/ClientProxyProtocol.swift 0.00% <ø> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Velin92
Copy link
Member Author

Velin92 commented May 17, 2023

I am actually wondering, do we really need this background task at all? Don't we just need to suspend the sync when the AppCoordinator sees that the app is suspending, and nothing more?

@Velin92 Velin92 force-pushed the mauroromito/cleanup_bg_task branch from fa7eb2f to 16f4974 Compare May 17, 2023 16:21
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

Looks good to me but I would like some api changes that I commented on inline.

Separately from this, the usage of the background tasks in the roomProxy feels fishy to me. For example sendMessage starts a background task and then stops it on exiting the method. In reality the async call to the SDK doesn't return when the message was actually sent but when it was enqueued. I think that basically means that the background task here is useless. What do you think?

@Velin92 Velin92 force-pushed the mauroromito/cleanup_bg_task branch from 905a44d to 6092331 Compare May 19, 2023 07:57
@Velin92
Copy link
Member Author

Velin92 commented May 19, 2023

Looks good to me but I would like some api changes that I commented on inline.

Separately from this, the usage of the background tasks in the roomProxy feels fishy to me. For example sendMessage starts a background task and then stops it on exiting the method. In reality the async call to the SDK doesn't return when the message was actually sent but when it was enqueued. I think that basically means that the background task here is useless. What do you think?

I actually tested it and the background task is actually needed, I added an artificial delay before the enqueueing of let's say 3 seconds before the sending of the message, without that bg task it will only get sent when I reopen the app, instead with it gets sent in bg.

@stefanceriu
Copy link
Member

instead with it it gets sent in bg

Huh, interesting, okay then 👍

@stefanceriu stefanceriu self-requested a review May 19, 2023 08:14
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Velin92 Velin92 enabled auto-merge (squash) May 19, 2023 08:19
@Velin92 Velin92 merged commit 4e46c01 into develop May 19, 2023
@Velin92 Velin92 deleted the mauroromito/cleanup_bg_task branch May 19, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup the background task that pauses the SDK when resigning active.
2 participants