Skip to content

Conversation

kstenerud
Copy link
Contributor

@kstenerud kstenerud commented Sep 22, 2025

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) and UserDefaults (iOS), we use the crash-resilient KV store, which is stored in the sdk directory as storage.jrna and storage.jrnb.

Copy link

github-actions bot commented Sep 22, 2025

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3562 1452
Current 3566 1452
Difference 4 0

APK size increased by 4 KB. SO size unchanged.

@kstenerud kstenerud force-pushed the karl/resilient-globals branch 2 times, most recently from 918a9a8 to 1d55c45 Compare September 22, 2025 14:51
Copy link

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3558 1444
Current 3558 1444
Difference 0 0

APK size unchanged. SO size unchanged.

@kstenerud kstenerud marked this pull request as ready for review September 22, 2025 15:19
Copy link
Contributor

@Copilot Copilot AI left a 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.

@kstenerud kstenerud force-pushed the karl/resilient-globals branch 2 times, most recently from e3e4c37 to 673cd6f Compare September 22, 2025 15:39
Copy link

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3558 1444
Current 3558 1444
Difference 0 0

APK size unchanged. SO size unchanged.

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(
Copy link
Contributor

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

Copy link
Contributor Author

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...

@kstenerud kstenerud force-pushed the karl/resilient-globals branch from 673cd6f to 680023d Compare September 23, 2025 17:01
Copy link

Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3558 1444
Current 3562 1448
Difference 4 4

APK size increased by 4 KB. SO size increased by 4 KB.

@kstenerud kstenerud force-pushed the karl/resilient-globals branch 5 times, most recently from 8102248 to 81d8a54 Compare October 1, 2025 13:39
@kstenerud kstenerud force-pushed the karl/resilient-globals branch from 81d8a54 to 9b9165f Compare October 1, 2025 13:45
);

// Create the SDK directory if it doesn't exist
std::fs::create_dir_all(&sdk_directory)?;
Copy link
Contributor

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?

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.

2 participants