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

Fixing background sessions logic in SessionController #72

Merged
merged 5 commits into from
Oct 2, 2024

Conversation

NachoEmbrace
Copy link
Contributor

@NachoEmbrace NachoEmbrace commented Sep 25, 2024

Even though we were parsing the background sessions remote config, we were never actually using it in the session logic.
This PR adds the necessary validations into SessionController to drop background sessions if the config is disabled.

There's one special case that we have to deal with when the app is starting. In this scenario we can't know right away if the app is actually starting in the background or not.
Due to this, the cold start session is always created even if the app is in the background and the config is disabled.
Once the session ends it will be dropped unless the session state was updated to foreground.

We also updated the logic for "coldStart" sessions. Due to the changes in iOS 15 where apps can be pre-warmed by the OS, our calculations for the process start time are not accurate. For this reason we can't really know for sure how much time has passed since the process started and the first session is created.
For this reason we will always flag the very first session as the "coldStart" session, regardless on how much time has passed since the process started.

Additionally, this PR adds 2 new resources: process start time and process pre warm.

Copy link

github-actions bot commented Sep 25, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

github-actions bot commented Sep 25, 2024

Warnings
⚠️ No CHANGELOG entry added.

Generated by 🚫 Danger Swift against b31d80d

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 98.63636% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.82%. Comparing base (394bd68) to head (392bc06).

Files with missing lines Patch % Lines
...ources/EmbraceCore/Session/SessionController.swift 96.36% 2 Missing ⚠️
...raceCoreTests/Session/SessionControllerTests.swift 99.30% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
+ Coverage   91.76%   91.82%   +0.06%     
==========================================
  Files         403      404       +1     
  Lines       26152    26302     +150     
==========================================
+ Hits        23999    24153     +154     
+ Misses       2153     2149       -4     
Files with missing lines Coverage Δ
Sources/EmbraceCore/Embrace.swift 81.16% <100.00%> (+0.37%) ⬆️
Sources/EmbraceCore/Internal/Embrace+Setup.swift 84.88% <ø> (ø)
...n/ProcessUptime/DefaultProcessUptimeProvider.swift 100.00% <100.00%> (ø)
...ternal/Logs/EmbraceLogAttributesBuilderTests.swift 100.00% <100.00%> (ø)
...ceCoreTests/Internal/Logs/LogControllerTests.swift 100.00% <ø> (ø)
...reTests/Public/Metadata/MetadataHandlerTests.swift 94.64% <100.00%> (ø)
...upport/TestDoubles/MockProcessUptimeProvider.swift 100.00% <100.00%> (ø)
...estSupport/TestDoubles/MockSessionController.swift 100.00% <100.00%> (ø)
...raceCoreTests/Session/SessionControllerTests.swift 99.46% <99.30%> (-0.18%) ⬇️
...ources/EmbraceCore/Session/SessionController.swift 98.33% <96.36%> (-0.91%) ⬇️

... and 3 files with indirect coverage changes

@NachoEmbrace NachoEmbrace marked this pull request as ready for review September 30, 2024 19:51
@NachoEmbrace NachoEmbrace requested a review from a team as a code owner September 30, 2024 19:51
@NachoEmbrace NachoEmbrace merged commit 0ed8ad8 into main Oct 2, 2024
1 of 6 checks passed
@NachoEmbrace NachoEmbrace deleted the fix_background_sessions_logic branch October 2, 2024 15:00
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.

3 participants