Tencent / MMKV

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

MMKV初始化异常 导致ANR #1333

Closed ljackChen001 closed 3 months ago

ljackChen001 commented 3 months ago

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

e.g. Objective-C, Swift, Java, or Kotlin

Kotlin

The version of MMKV

1.3.2

e.g. v1.2.2
Note: For versions older than the latest version, please upgrade before posting any issue.
We don't have much time for old version tech support.

The platform of MMKV

e.g. iOS or Android

android

The installation of MMKV

e.g. Cocoapods, Maven, or Git clone

maven

What's the issue?

Post the outputs or screenshots for errors.

Explain what you want by example or code in English. If you have a crash/OOM/ANR on Android, please provide symbolize stack traces. https://developer.android.com/ndk/guides/ndk-stack.html

suspend all histogram: Sum: 11.039ms 99% C.I. 0.005ms-10.470ms Avg: 1.103ms Max: 10.932ms DALVIK THREADS (12): "main" prio=5 tid=1 Native | group="main" sCount=1 ucsCount=0 flags=1 obj=0x731349d8 self=0xb4000074ad86dc00 | sysTid=23735 nice=0 cgrp=foreground sched=0/0 handle=0x756a68cd28 | state=S schedstat=( 178305433 258496450 142 ) utm=8 stm=9 core=1 HZ=100 | stack=0x7fc939b000-0x7fc939d000 stackSize=8188KB | held mutexes= native: #00 pc 000bca00 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32) (BuildId: 9992cffda0d638f1220d7b4123ea7f2a) native: #01 pc 004f5694 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocksWithInfo+160) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #02 pc 00a499d4 /apex/com.android.art/lib64/libart.so (art::JNI::GetStringUTFChars+1072) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #03 pc 000340c8 /data/app/xxxx/lib/arm64/libmmkv.so (???) (BuildId: 7b8c8da9f4a766122906c0d5262afe49dc56c948) native: #04 pc 000317fc /data/app/xxxx/lib/arm64/libmmkv.so (???) (BuildId: 7b8c8da9f4a766122906c0d5262afe49dc56c948) native: #05 pc 0047a170 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #06 pc 007447d8 /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #07 pc 00211aee /data/app/xxxx.apk (com.tencent.mmkv.MMKV.t+30) native: #08 pc 007447d8 /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #09 pc 00211bd0 /data/app/xxxx.apk (com.tencent.mmkv.MMKV.E+80) native: #10 pc 007447d8 /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #11 pc 00211b64 /data/app/xxxx.apk (com.tencent.mmkv.MMKV.D+56) native: #12 pc 007447d8 /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #13 pc 001e66b4 /data/app/xxxx.apk (xxxx.mmkv.b.b+20) native: #14 pc 00745694 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #15 pc 001e6686 /data/app/xxxx.apk (xxxx.mmkv.b.+14) native: #16 pc 00745694 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) native: #17 pc 002aec38 /data/app/xxxx.apk (xxxxApplication.x+8) native: #18 pc 00745694 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 3b46873707e5fa0b519e8a3065b9c63b) at com.tencent.mmkv.MMKV.jniInitialize(Native method) at com.tencent.mmkv.MMKV.t(MMKV.java:16) at com.tencent.mmkv.MMKV.E(MMKV.java:41) at com.tencent.mmkv.MMKV.D(MMKV.java:29) at xxxx.mmkv.b.b(MMKVSharedPreferences.kt:11) at xxxx.mmkv.b.(MMKVSharedPreferences.kt:8) at xxxxApplication.x(GameSpaceApplication.java:5) at xxxxApplication.onCreate(xxxxApplication.java:11) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1404) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8198) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(unavailable:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2650) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:282) at android.os.Looper.loop(Looper.java:387) at android.app.ActivityThread.main(ActivityThread.java:9481) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1005) DumpLatencyMs: 35.446

What's the log of MMKV when that happened?

Your detail logs. As much as possible. For how to forward MMKV's log, you can checkout the wiki on each platform. An crash issue will be ignored & closed in a week without logs.

在Application#onCreate()中初始化的MMKV 线上用户部分会出现ANR

lingol commented 3 months ago

According to your stacks, the ANR is inside a system lib art::JNI::GetStringUTFChars(), nothing we can do about it.

ljackChen001 commented 3 months ago

有什么办法避免吗,现在每天有1000多次 @lingol

lingol commented 3 months ago

No idea. It's not mmkv's problem.