Repository navigation
fix: keep Keystore work off the SDK init thread - #937
Draft
mahmoud-elmorabea wants to merge 12 commits into
Draft
mahmoud-elmorabea wants to merge 12 commits into
mahmoud-elmorabea wants to merge 12 commits into
Conversation
Init encrypted the persisted userId on the caller's thread, so a slow or stalled Keystore could ANR an identified cold start. The save now runs in the background and UserChangedEvent is published once it lands, so every module still finds the userId on disk when notified. A version counter orders it against identify and clearIdentify; a same-user identify skips the Keystore and publishes after the pending write. In-app polling waits for an identity instead of fetching without a user token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The restore decrypted the cached location on the caller's thread during initialize(). It now runs on the location scope; identify context, the UserChangedEvent handler and getLastKnownLocation wait for it off main. A restore that lands after a newer fix or a sign-out leaves state alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cher These scopes block on disk and Keystore calls. On Default, which has as many threads as the device has cores (2 on low-end devices), a slow Keystore in geofence or location work stalled event delivery for every module, including the push and in-app metrics carried by the bus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When foreground polling was skipped for lack of identity, the identification-change path and the UserChangedEvent fetch both started polling, sending two fetches. The identification-change path now leaves the start to the identity fetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bus forwarded with tryEmit, which fails once the slowest subscriber is a full replay buffer behind, losing the event for every subscriber, metrics included. emit suspends the forwarder instead; the unlimited channel holds what is published meanwhile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he bus resetContext cleared the persisted location after releasing its lock, so a restore could still read the signed-out user's location. The identify handler now waits for the restore in its own coroutine, not in the bus collector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sample app builds 📱Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #937 +/- ##
============================================
+ Coverage 69.07% 74.58% +5.51%
- Complexity 838 2412 +1574
============================================
Files 149 282 +133
Lines 4601 13429 +8828
Branches 628 2297 +1669
============================================
+ Hits 3178 10016 +6838
- Misses 1189 2606 +1417
- Partials 234 807 +573 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Build available to test |
📏 SDK Binary Size Comparison Report
|
…e on Error Modules built against the one-argument saveUserId keep linking when an app mixes module versions. A background write whose encryption throws an Error now takes the same plaintext fallback PreferenceCrypto uses for exceptions, so the write lands and its callbacks are never stranded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Readers waited up to 30 s again on every call while a stalled restore was running: each identify and each geofence anchor read. The 30 s now runs from the start of the restore, shared by all readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A background init write still inside the Keystore when clearInstance resets the SDK could land afterwards and store the old user. Reset now invalidates the pending write and its callbacks and stops the store's writer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the Keystore work at SDK init off the caller's thread, so an identified cold start can't ANR on a slow or stalled Keystore, while modules still get the userId only after it is saved encrypted.
🤖 Generated with Claude Code