Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.39k stars 1.91k forks source link

got crash on CodedInputData #1210

Closed dongfanger2018 closed 9 months ago

dongfanger2018 commented 10 months ago

The language of MMKV

Swift

The version of MMKV

v1.3.2

image

The platform of MMKV

iOS Host App & UNNotificationServiceExtension

The installation of MMKV

Cocoapods

What's the issue?

crash

What's the log of MMKV when that happened?

didn't open MMKV log, has crash log only

App use 2 MMKV instance

shared one, across user domain, use multiProcess mode image

user one, for every user image

crash when using the second(user one)

this is crash log from apple 2023-12-1519-23-05.0669+0700-760963e560ccc42e362536aff66627379c637e62.crash.zip

lingol commented 10 months ago

You should not turn off MMKV's log. And you should provide MMKV's log when crash happens.

dongfanger2018 commented 10 months ago

You should not turn off MMKV's log. And you should provide MMKV's log when crash happens.

which MMKVLogLevel? info or error?

lingol commented 10 months ago

Use the default setting.

dongfanger2018 commented 10 months ago

Use the default setting.

Added, but it will take time to collect the user's mmkv log and crash report.

dongfanger2018 commented 9 months ago

16523274.zip

20240103-192233

image

new crash user, the stack is same as old. mmkv log has been uploaded, but log at crash moment has been flushed, don't know the following mmkv log can help?

the issue will be updated as soon as I get new log

lingol commented 9 months ago

According to your log, the MMKV file mmkv.user.16523274 is corrupted. You might consider delete it for this user.

lingol commented 9 months ago

A later log with successful loading on the file shows that the file is considerable LARGE. It's over 1GB. No wonder it's constantly fail to load. Something must be wrong with your logic. You should check on what cause it expand this large. Maybe it's too much keys, or maybe some very large value is inside?

2024-01-02 01:57:52.513 [INFO] [KVManager:258]: [KV] info file:MMKV_IO.cpp|line:78|funcname:loadFromFile|message:Optional("loading [mmkv.user.16523274] with 562480594 actual size, file size 1073741824, InterProcess 0, meta info version:4") 2024-01-02 01:57:53.051 [INFO] [KVManager:258]: [KV] info file:MMKV_IO.cpp|line:127|funcname:loadFromFile|message:Optional("loaded [mmkv.user.16523274] with 9088 key-values")

lingol commented 9 months ago

Closed due to inactive.

dongfanger2018 commented 8 months ago

Is there an approach to limit the mmkv file size and reduce the count of keys? otherwise developers have to delete key-value items and call trim method in business logic layer

lingol commented 8 months ago

Yep, you have to do it by yourself. @dongfanger2018

dongfanger2018 commented 2 months ago

can you give a suggestion on max number count of keys and max filesize of store file