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

Defer loading of user info until when it's really necessary #537

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Mar 11, 2024

Goal

UserInfo was being loaded form preferences way before we actually need it, which delays the execution of startup on the main thread.

Instead, we defer this to when it's consumed by putting it behind a provider which will be executed when it's first read. Access to the in-memory copy is synchronized, which shouldn't impact runtime very much.

This also fixes an existing race condition where concurrent modification could result in some values being lost, though it's probably not very likely.

Testing

Existing tests cover these workflows

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 85.96491% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 79.60%. Comparing base (5e18d90) to head (e028f97).
Report is 4 commits behind head on master.

❗ Current head e028f97 differs from pull request most recent head 41b9ac8. Consider uploading reports for the commit 41b9ac8 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #537      +/-   ##
==========================================
+ Coverage   79.45%   79.60%   +0.14%     
==========================================
  Files         403      403              
  Lines       10861    10885      +24     
  Branches     1602     1605       +3     
==========================================
+ Hits         8630     8665      +35     
+ Misses       1585     1575      -10     
+ Partials      646      645       -1     
Files Coverage Δ
...cesdk/anr/ndk/EmbraceNativeThreadSamplerService.kt 90.83% <100.00%> (+2.79%) ⬆️
.../io/embrace/android/embracesdk/ndk/NativeModule.kt 100.00% <100.00%> (+21.95%) ⬆️
...embracesdk/anr/ndk/NativeThreadSamplerInstaller.kt 57.14% <50.00%> (+0.89%) ⬆️
...roid/embracesdk/capture/user/EmbraceUserService.kt 72.85% <93.10%> (+6.19%) ⬆️
.../android/embracesdk/internal/SharedObjectLoader.kt 64.28% <61.53%> (-21.43%) ⬇️

... and 6 files with indirect coverage changes

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator Author

bidetofevil commented Mar 11, 2024

Merge activity

  • Mar 11, 11:07 AM EDT: @bidetofevil started a stack merge that includes this pull request via Graphite.
  • Mar 11, 11:10 AM EDT: Graphite rebased this pull request as part of a merge.
  • Mar 11, 11:11 AM EDT: @bidetofevil merged this pull request with Graphite.

Base automatically changed from hho/defer-native-init to master March 11, 2024 15:09
@bidetofevil bidetofevil merged commit 46c1ee2 into master Mar 11, 2024
3 checks passed
@bidetofevil bidetofevil deleted the hho/defer-user-info-load branch March 11, 2024 15:11
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.

None yet

2 participants