Skip to content

Android Multiprocess Support? #445

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

Closed
TheSteveHan opened this issue Aug 23, 2022 · 5 comments
Closed

Android Multiprocess Support? #445

TheSteveHan opened this issue Aug 23, 2022 · 5 comments

Comments

@TheSteveHan
Copy link

Hi there,

I've encounter some segfaults today from accessing the storage via both the app and the widget on android.

After a little bit of digging it seems like the mmkv instance for android is hard coded to use single process mode here:

https://github.com/mrousavy/react-native-mmkv/blob/master/android/src/main/cpp/MmkvHostObject.cpp#L19

Is this intentional? For my use case, after changing this flag to MMKV_MULTI_PROCESS the app no longer crashes, although I haven't read enough of the code base to understand the full implication of this change.

@mrousavy
Copy link
Owner

I think multi-process mode is slower because it has to perform more disk-memory synchronisation (it always assumes that data might've changed in the meantime), which single-process mode doesn't have to do.

@TheSteveHan
Copy link
Author

That makes sense. With this PR #402, multiprocess is turned on on ios when AppGroup is specified. Should we add a explicit config option for a uniform way to control this behavior on both ios and android?

@mrousavy
Copy link
Owner

Hey! Yeah I think this should be configurable from both iOS and Android, but not sure how since this is called once the JS bundle loads....

@maxencehenneron
Copy link

I added android support in #611.

On iOS, AppGroups enable this mode. Looking at the MMKV doc, MultiProcess mode on iOS only makes sense with AppGroups and needs to be initialized when the bundle js loads

On Android, this is not the case, MultiProcess mode is enabled when creating the instance so we can just add it as a config parameter.

@mrousavy
Copy link
Owner

Hey - I think this has been fixed in V3 beta.

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

No branches or pull requests

3 participants