Skip to content
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

Fix multiprocess mode on iOS #1222

Merged
merged 1 commit into from
Jan 4, 2024
Merged

Fix multiprocess mode on iOS #1222

merged 1 commit into from
Jan 4, 2024

Conversation

maxencehenneron
Copy link
Contributor

There is currently no way to enable multiprocess mode on iOS. I was initializing MMKV using the following code (Swift):

Screenshot 2024-01-03 at 11 46 34 AM

Yet, the logs would display the following:

loading [mmkv.default] with 0 actual size, file size 16384, InterProcess 0, meta info version:4

Looking at the source code, I found the constructor associated with this class here:

https://github.com/Tencent/MMKV/blob/master/iOS/MMKV/MMKV/libMMKV.mm#L181-L184

this constructor sets rootPath to g_groupPath if mode is not MMKVSingleProcess and calls another (private) constructor

[MMKV mmkvWithID:mmapID cryptKey:cryptKey rootPath:rootPath mode:mode]

Unfortunately, this constructor forces the mode to MMKVSingleProcess, it also does not implement relativePath so the comment isn't relevant anymore.

https://github.com/Tencent/MMKV/blob/master/iOS/MMKV/MMKV/libMMKV.mm#L212

Also there does not seem to be any constructor that let you set both "mode" and "relativePath" anymore so the comment is really not needed.

Looking at all the exported constructors, none of them let you set multi-process mode as they all end up calling the constructor that forces MMKVSingleProcess so I don't think there is currently a way to enable multi-process mode on iOS. I would like to enable this mode mainly for sharing data with my iOS widgets.

@maxencehenneron
Copy link
Contributor Author

I added a comment to this commit: 73f01e5

I think this is what created this issue.

@lingol lingol merged commit 9bb7ec4 into Tencent:dev Jan 4, 2024
1 check passed
@lingol
Copy link
Collaborator

lingol commented Jan 4, 2024

Thanks for your input. Looks like a hotfix version is needed.

@nmalzieu
Copy link

Hi @maxencehenneron @lingol , thanks for the fix.
Do you know when a hotfix including this will be released? Thanks!

@lingol
Copy link
Collaborator

lingol commented Jan 23, 2024

Hi @maxencehenneron @lingol , thanks for the fix. Do you know when a hotfix including this will be released? Thanks!

Hopefully this week.

@lingol
Copy link
Collaborator

lingol commented Jan 25, 2024

Released with v1.3.3. @nmalzieu

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.

3 participants