Android Multiprocess Support?
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.
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.
That makes sense. With this PR https://github.com/mrousavy/react-native-mmkv/pull/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?
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....
I added android support in https://github.com/mrousavy/react-native-mmkv/pull/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.