Tencent / MMKV

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

crashed in Harmony Next Emulator API 11 x86_64 #1278

Closed Amarterlus closed 3 months ago

Amarterlus commented 3 months ago

Snipaste_2024-04-25_16-51-29

[IDE INFO] DevEco Studio NEXT Developer Preview2 Build Version: 4.1.3.700, built on March 19, 2024 crash2.log

lingol commented 3 months ago

I don't see any mmkv related symbols or libmmkv.so in your crash log.

What's the log from hilog?

Amarterlus commented 3 months ago

sry, I've updated the log and screenshot

lingol commented 3 months ago

04-25 16:50:31.066 2458 2458 I A00000/MMKV: NAPI Error: code 1, msg Invalid parameter 04-25 16:50:31.066 2458 2458 E C03f00/ArkCompiler: [ecmascript] Pending exception before ToString called in line:242, exception details as follows: 04-25 16:50:31.066 2458 2458 E C03f00/ArkCompiler: Error: null 04-25 16:50:31.066 2458 2458 E C03f00/ArkCompiler: at initializeWithPath (oh_modules/.ohpm/@tencent+mmkv@1.3.5/oh_modules/@tencent/mmkv/src/main/ets/utils/MMKV.ets:54:26)

When you called MMKV.initialize() (or MMKV.initializeWithPath()), what param did you pass as context (or rootDir & cacheDir)? Did you accidentally pass null or undefined?

Amarterlus commented 3 months ago

at EntryAbility onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) something like const filePath: string = context.filesDir + "/mmkv" const cachePath: string = context.cacheDir + "/mmkv" MMKV.initializeWithPath(filePath, cachePath)

lingol commented 3 months ago

Would you print the filePath, cachePath before calling MMKV.initializeWithPath()?

Amarterlus commented 3 months ago

Would you print the filePath, cachePath before calling MMKV.initializeWithPath()?

path is leagl filePath => /data/storage/el2/base/haps/entry/files/mmkv cachePath => /data/storage/el2/base/haps/entry/cache/mmkv

lingol commented 3 months ago

That's strange. Can you provide a reproducible demo project?

Amarterlus commented 3 months ago

That's strange. Can you provide a reproducible demo project?

actually I just create a new project with empty Ability maybe IDE version or emulator version not suit but change to @ohos/mmkv dose work

lingol commented 3 months ago

Does it work if you passed in an Application Context?

Amarterlus commented 3 months ago

Does it work if you passed in an Application Context?

just same fatal error

lingol commented 3 months ago

We can't reproduce this in a device. Did you only reproduce this in a simulator?

lingol commented 3 months ago

I just found out that you are using DevEco Studio 4.1.3.700, you should try using the 5.0.3.100 or newer.

lingol commented 3 months ago

Aka, @tencent/mmkv is developed under 5.0.3.100 (API 12). We have not tested our lib under API 11. I am not surprised if it doesn't run correctly.

ChawLoo commented 3 months ago

目前测试情况如下: Dev:5.0.3.200 模拟器:Beta1(正常),Preview2(报错) 真机:Preview2(正常)

lingol commented 3 months ago

Okay, I think we can close this issue for now, for Beta1 is newer than Preview2 if I understand correctly.