-
Notifications
You must be signed in to change notification settings - Fork 8
Use resilient storage for globals #648
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
base: main
Are you sure you want to change the base?
Conversation
Size Comparison Report (x86_64)
|
918a9a8
to
1d55c45
Compare
Size Comparison Report (x86_64)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Replaces platform-specific storage implementations (UserDefaults on iOS and Preferences on Android) with a crash-resilient key-value storage solution that stores data in the SDK directory as storage.jrna
and storage.jrnb
files.
- Updates both iOS/Swift and Android/JVM platforms to use
ResilientKvStorage
instead of platform-specific storage - Bumps shared-core dependency to include the resilient storage implementation
- Ensures SDK directory creation on Android before initializing storage
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
platform/swift/source/src/bridge.rs | Replaces UserDefaultsStorage with ResilientKvStorage and moves path extraction earlier |
platform/jvm/src/jni.rs | Replaces PreferencesHandle with ResilientKvStorage and adds directory creation |
Cargo.toml | Updates shared-core dependency revision to include resilient storage support |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
e3e4c37
to
673cd6f
Compare
Size Comparison Report (x86_64)
|
let preferences = new_global!(PreferencesHandle, &mut env, preferences)?; | ||
let store = Arc::new(bd_key_value::Store::new(Box::new(preferences))); | ||
|
||
let storage = Box::new(bd_key_value::resilient_kv::ResilientKvStorage::new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're no longer passing the storage implementation from the platform layer should we just move this initialization into builder.rs instead? That would let us unify all the setup and sequence the initialization better with the rest of the logger setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look, but the relationships between the various objects are surprisingly complicated here (and arranged differently in JVM vs Swift). I think this would be better done in a separate PR as it could get quite hairy...
673cd6f
to
680023d
Compare
Size Comparison Report (x86_64)
|
8102248
to
81d8a54
Compare
81d8a54
to
9b9165f
Compare
); | ||
|
||
// Create the SDK directory if it doesn't exist | ||
std::fs::create_dir_all(&sdk_directory)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? I see it exists here but not on the iOS side?
This PR makes use of bitdriftlabs/shared-core#255 to provide alternatives for the current
Storage
implementations for storing global data on mobile.Instead of
Preferences
(Android) andUserDefaults
(iOS), we use the crash-resilient KV store, which is stored in the sdk directory asstorage.jrna
andstorage.jrnb
.