Tencent / MMKV

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

easy anr on some vivo device #365

Closed shaopx closed 4 years ago

shaopx commented 4 years ago

The language of MMKV

Java, Kotlin

The version of MMKV

e.g. v1.0.10

The platform of MMKV

Android

The installation of MMKV

AAR Package

What's the issue?

anr when reading and writing by muti thread

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

"global-default-pool-2-3" prio=5 tid=20 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14a41120 self=0xe4ff5600 | sysTid=6301 nice=10 cgrp=default sched=0/0 handle=0xd0148970 | state=S schedstat=( 290786874 10285038264 833 ) utm=21 stm=8 core=7 HZ=100 | stack=0xd0046000-0xd0048000 stackSize=1038KB | held mutexes= kernel: switch_to+0x90/0xc4 kernel: futex_wait_queue_me+0xc4/0x13c kernel: futex_wait+0xe4/0x204 kernel: do_futex+0x170/0x58c kernel: compat_SyS_futex+0xf0/0x174 kernel: cpu_switch_to+0x34c/0x22c0 native: #00 pc 00018dc4 /system/lib/libc.so (syscall+28) native: #01 pc 000b75cd /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread)+80) native: #02 pc 002abbdd /system/lib/libart.so (art::JNI::NewStringUTF(_JNIEnv, char const*)+296) native: #03 pc 000020ef /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #04 pc 00009021 /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #05 pc 000043a7 /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #06 pc 00003ce1 /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #07 pc 00004ce5 /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #08 pc 00002847 /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/lib/arm/libmmkv.so (???) native: #09 pc 0000dc1d /data/app/com.smile.xxx-r3Ee0Oidsb7Xg6Hj-a7zVg==/oat/arm/base.odex (Java_com_tencent_mmkv_MMKV_getMMKVWithIDLjava_lang_String_2ILjava_lang_String_2Ljava_lang_String_2+172) at com.tencent.mmkv.MMKV.getMMKVWithID(Native method) at com.tencent.mmkv.MMKV.mmkvWithID(kSourceFile:50790405)

"main" prio=5 tid=1 Blocked | group="main" sCount=1 dsCount=0 flags=1 obj=0x72fee4a8 self=0xefcb7000 | sysTid=6187 nice=0 cgrp=default sched=0/0 handle=0xf6f514a4 | state=S schedstat=( 1191789191 3496319239 2179 ) utm=83 stm=36 core=4 HZ=100 | stack=0xff370000-0xff372000 stackSize=8MB | held mutexes= at com.yxcorp.preferences.a.a(kSourceFile:51511298)

device list with this anr: vivo U1 全网通版(vivo(V1818A)) vivo(vivo Y85A) vivo Y7s 全网通版(vivo(V1913A)) vivo(vivo X20) vivo(vivo X21A) vivo(vivo X9s)

lingol commented 4 years ago

native: #1 pc 000b75cd /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread)+80) native: #2 pc 002abbdd /system/lib/libart.so (art::JNI::NewStringUTF(_JNIEnv, char const*)+296)

As far as your call stacks show, the lock is inside JNI runtime, when creating a Java String object from c string. There's nothing we can do. Maybe you should contact VIVO to solve that problem.

lingol commented 4 years ago

A little hint for you: Google these keywords NewStringUTF, WaitHoldingLocks.

shaopx commented 4 years ago

thanks for your help