Local Reference Table Overflow 问题

JS 层调起 Android Native 的方法时,很容易遇到 reference table overflow 错误。就像一个定时炸弹,随时可能导致我们的应用卡死。

A/art: art/runtime/indirect_reference_table.cc:138] JNI ERROR (app bug): local reference table overflow (max=512)
A/art: art/runtime/indirect_reference_table.cc:138] local reference table dump:
A/art: art/runtime/indirect_reference_table.cc:138]   Last 10 entries (of 512):
A/art: art/runtime/indirect_reference_table.cc:138]       511: 0x12e45170 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       510: 0x12dd33c0 java.lang.Class<com.tencent.abcmouse.report.DcReport>
A/art: art/runtime/indirect_reference_table.cc:138]       509: 0x12e45180 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       508: 0x12f89490 java.lang.String "59"
A/art: art/runtime/indirect_reference_table.cc:138]       507: 0x135a4f40 java.lang.String "1522668817662"
A/art: art/runtime/indirect_reference_table.cc:138]       506: 0x12e89400 java.lang.String "onLoad"
A/art: art/runtime/indirect_reference_table.cc:138]       505: 0x12e451d0 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       504: 0x12c8bc00 java.lang.Class<
A/art: art/runtime/indirect_reference_table.cc:138]       503: 0x12e451f0 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       502: 0x134627f0 java.lang.String "1522668817664"
A/art: art/runtime/indirect_reference_table.cc:138]   Summary:
A/art: art/runtime/indirect_reference_table.cc:138]         1 of android.opengl.GLSurfaceView$GLThread
A/art: art/runtime/indirect_reference_table.cc:138]       222 of java.lang.Class (7 unique instances)
A/art: art/runtime/indirect_reference_table.cc:138]       289 of java.lang.String (289 unique instances)
A/art: art/runtime/indirect_reference_table.cc:138] 

A/art: art/runtime/indirect_reference_table.cc:138] JNI ERROR (app bug): local reference table overflow (max=512)
A/art: art/runtime/indirect_reference_table.cc:138] local reference table dump:
A/art: art/runtime/indirect_reference_table.cc:138]   Last 10 entries (of 512):
A/art: art/runtime/indirect_reference_table.cc:138]       511: 0x12e45170 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       510: 0x12dd33c0 java.lang.Class<com.tencent.abcmouse.report.DcReport>
A/art: art/runtime/indirect_reference_table.cc:138]       509: 0x12e45180 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       508: 0x12f89490 java.lang.String "59"
A/art: art/runtime/indirect_reference_table.cc:138]       507: 0x135a4f40 java.lang.String "1522668817662"
A/art: art/runtime/indirect_reference_table.cc:138]       506: 0x12e89400 java.lang.String "onLoad"
A/art: art/runtime/indirect_reference_table.cc:138]       505: 0x12e451d0 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       504: 0x12c8bc00 java.lang.Class<
A/art: art/runtime/indirect_reference_table.cc:138]       503: 0x12e451f0 java.lang.String ""
A/art: art/runtime/indirect_reference_table.cc:138]       502: 0x134627f0 java.lang.String "1522668817664"
A/art: art/runtime/indirect_reference_table.cc:138]   Summary:
A/art: art/runtime/indirect_reference_table.cc:138]         1 of android.opengl.GLSurfaceView$GLThread
A/art: art/runtime/indirect_reference_table.cc:138]       222 of java.lang.Class (7 unique instances)
A/art: art/runtime/indirect_reference_table.cc:138]       289 of java.lang.String (289 unique instances)
A/art: art/runtime/indirect_reference_table.cc:138] 
art: art/runtime/runtime.cc:408] Runtime aborting...
art: art/runtime/runtime.cc:408] Aborting thread:
art: art/runtime/runtime.cc:408] "GLThread 2765" prio=5 tid=36 Runnable
art: art/runtime/runtime.cc:408]   | group="" sCount=0 dsCount=0 obj=0x12c147c0 self=0xdb57be00
art: art/runtime/runtime.cc:408]   | sysTid=8988 nice=0 cgrp=default sched=0/0 handle=0xc8815920
art: art/runtime/runtime.cc:408]   | state=R schedstat=( 102616736426 1849397394 49903 ) utm=9373 stm=888 core=5 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xc8713000-0xc8715000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes= "abort lock" "mutator lock"(shared held)
art: art/runtime/runtime.cc:408]   native: #00 pc 0035128d  /system/lib/libart.so S0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+128)
art: art/runtime/runtime.cc:408]   native: #01 pc 00331749  /system/lib/libart.so NS1_11char_traitsIcEEEEbP12BacktraceMap+336)
art: art/runtime/runtime.cc:408]   native: #02 pc 003247e9  /system/lib/libart.so treamIcNS1_11char_traitsIcEEEEPNS_6ThreadE+24)
art: art/runtime/runtime.cc:408]   native: #03 pc 00324633  /system/lib/libart.so NS1_11char_traitsIcEEEE+362)
art: art/runtime/runtime.cc:408]   native: #04 pc 0031b09b  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+90)
art: art/runtime/runtime.cc:408]   native: #05 pc 000b4f77  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+866)
art: art/runtime/runtime.cc:408]   native: #06 pc 001bc1cf  /system/lib/libart.so jectE+194)
art: art/runtime/runtime.cc:408]   native: #07 pc 0027bea5  /system/lib/libart.so (_ZN3art3JNI12NewStringUTFEP7_JNIEnvPKc+424)
art: art/runtime/runtime.cc:408]   native: #08 pc 007aea2c  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so 
art: art/runtime/runtime.cc:408]   native: #09 pc 0088ceb4  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so textjPN2JS5ValueE+2288)
art: art/runtime/runtime.cc:408]   native: #10 pc 0088c52c  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so (???)
art: art/runtime/runtime.cc:408]   native: #11 pc 0000bb0c  [anon:js-executable-memory] (???)
art: art/runtime/runtime.cc:408]   at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native method)
art: art/runtime/runtime.cc:408]   at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:106)
art: art/runtime/runtime.cc:408]   at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1582)
art: art/runtime/runtime.cc:408]   at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1267)
art: art/runtime/runtime.cc:408] Dumping all threads without appropriate locks held: thread list lock
art: art/runtime/runtime.cc:408] All threads:
art: art/runtime/runtime.cc:408] DALVIK THREADS (64):
art: art/runtime/runtime.cc:408] "GLThread 2765" prio=5 tid=36 Runnable
art: art/runtime/runtime.cc:408]   | group="" sCount=0 dsCount=0 obj=0x12c147c0 self=0xdb57be00
art: art/runtime/runtime.cc:408]   | sysTid=8988 nice=0 cgrp=default sched=0/0 handle=0xc8815920
art: art/runtime/runtime.cc:408]   | state=R schedstat=( 102644460384 1849397394 49903 ) utm=9374 stm=890 core=5 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xc8713000-0xc8715000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes= "abort lock" "mutator lock"(shared held)
art: art/runtime/runtime.cc:408]   native: #00 pc 0035128d  /system/lib/libart.so S0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+128)
art: art/runtime/runtime.cc:408]   native: #01 pc 00331749  /system/lib/libart.so NS1_11char_traitsIcEEEEbP12BacktraceMap+336)
art: art/runtime/runtime.cc:408]   native: #02 pc 0034385f  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #03 pc 0033d7ed  /system/lib/libart.so 6)
art: art/runtime/runtime.cc:408]   native: #04 pc 0033d4e7  /system/lib/libart.so S1_11char_traitsIcEEEEb+586)
art: art/runtime/runtime.cc:408]   native: #05 pc 0032463d  /system/lib/libart.so NS1_11char_traitsIcEEEE+372)
art: art/runtime/runtime.cc:408]   native: #06 pc 0031b09b  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+90)
art: art/runtime/runtime.cc:408]   native: #07 pc 000b4f77  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+866)
art: art/runtime/runtime.cc:408]   native: #08 pc 001bc1cf  /system/lib/libart.so jectE+194)
art: art/runtime/runtime.cc:408]   native: #09 pc 0027bea5  /system/lib/libart.so (_ZN3art3JNI12NewStringUTFEP7_JNIEnvPKc+424)
art: art/runtime/runtime.cc:408]   native: #10 pc 007aea2c  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so 
art: art/runtime/runtime.cc:408]   native: #11 pc 0088ceb4  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so textjPN2JS5ValueE+2288)
art: art/runtime/runtime.cc:408]   native: #12 pc 0088c52c  /data/app/com.tencent.abcmouse-1/lib/arm/libcocos2djs.so (???)
art: art/runtime/runtime.cc:408]   native: #13 pc 0000bb0c  [anon:js-executable-memory] (???)
art: art/runtime/runtime.cc:408]   at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native method)
art: art/runtime/runtime.cc:408]   at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:106)
art: art/runtime/runtime.cc:408]   at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1582)
art: art/runtime/runtime.cc:408]   at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1267)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "main" prio=5 tid=1 Native
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x7600c578 self=0xea184f00
art: art/runtime/runtime.cc:408]   | sysTid=8892 nice=-10 cgrp=default sched=0/0 handle=0xecfab534
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 1290844797 238326036 4391 ) utm=97 stm=32 core=1 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xff5d0000-0xff5d2000 stackSize=8MB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: SyS_epoll_wait+0x354/0x49c
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_epoll_pwait+0x118/0x120
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 00048e44  /system/lib/libc.so (__epoll_pwait+20)
art: art/runtime/runtime.cc:408]   native: #01 pc 0001a2ad  /system/lib/libc.so (epoll_pwait+60)
art: art/runtime/runtime.cc:408]   native: #02 pc 0001a2dd  /system/lib/libc.so (epoll_wait+12)
art: art/runtime/runtime.cc:408]   native: #03 pc 00011eab  /vendor/lib/libutils.so (_ZN7android6Looper9pollInnerEi+118)
art: art/runtime/runtime.cc:408]   native: #04 pc 00011da7  /vendor/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+26)
art: art/runtime/runtime.cc:408]   native: #05 pc 00098085  /system/lib/libandroid_runtime.so 8_jobjecti+22)
art: art/runtime/runtime.cc:408]   native: #06 pc 007e405d  /data/dalvik-cache/arm/system@framework@boot-framework.oat (
art: art/runtime/runtime.cc:408]   at android.os.MessageQueue.nativePollOnce(Native method)
art: art/runtime/runtime.cc:408]   at android.os.MessageQueue.next(MessageQueue.java:356)
art: art/runtime/runtime.cc:408]   at android.os.Looper.loop(Looper.java:138)
art: art/runtime/runtime.cc:408]   at android.app.ActivityThread.main(ActivityThread.java:6523)
art: art/runtime/runtime.cc:408]   at java.lang.reflect.Method.invoke!(Native method)
art: art/runtime/runtime.cc:408]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
art: art/runtime/runtime.cc:408]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "Jit thread pool worker thread 0" prio=5 tid=2 Native (still starting up)
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x0 self=0xe2d94000
art: art/runtime/runtime.cc:408]   | sysTid=8897 nice=9 cgrp=default sched=0/0 handle=0xe98a2920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 762069797 371594795 1132 ) utm=70 stm=6 core=1 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe97a4000-0xe97a6000 stackSize=1022KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b4  /system/lib/libc.so (syscall+28)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6b4d  /system/lib/libart.so hreadE+92)
art: art/runtime/runtime.cc:408]   native: #02 pc 00344db5  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #03 pc 003445e3  /system/lib/libart.so (_ZN3art16ThreadPoolWorker3RunEv+62)
art: art/runtime/runtime.cc:408]   native: #04 pc 00344109  /system/lib/libart.so (_ZN3art16ThreadPoolWorker8CallbackEPv+64)
art: art/runtime/runtime.cc:408]   native: #05 pc 000479c3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
art: art/runtime/runtime.cc:408]   native: #06 pc 00019efd  /system/lib/libc.so (__start_thread+6)
art: art/runtime/runtime.cc:408]   (no managed stack frames)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "Signal Catcher" prio=5 tid=3 WaitingInMainSignalCatcherLoop
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23160 self=0xdd117700
art: art/runtime/runtime.cc:408]   | sysTid=8902 nice=0 cgrp=default sched=0/0 handle=0xe97a1920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 567707 17077082 6 ) utm=0 stm=0 core=0 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe96a5000-0xe96a7000 stackSize=1014KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: do_sigtimedwait+0x15c/0x244
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_rt_sigtimedwait+0x8c/0xe8
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000491b0  /system/lib/libc.so (__rt_sigtimedwait+12)
art: art/runtime/runtime.cc:408]   native: #01 pc 0001e321  /system/lib/libc.so (sigwait+72)
art: art/runtime/runtime.cc:408]   native: #02 pc 00327803  /system/lib/libart.so (_ZN3art9SignalSet4WaitEv+22)
art: art/runtime/runtime.cc:408]   native: #03 pc 003273fd  /system/lib/libart.so NS_9SignalSetE+168)
art: art/runtime/runtime.cc:408]   native: #04 pc 00326113  /system/lib/libart.so (_ZN3art13SignalCatcher3RunEPv+286)
art: art/runtime/runtime.cc:408]   native: #05 pc 000479c3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
art: art/runtime/runtime.cc:408]   native: #06 pc 00019efd  /system/lib/libc.so (__start_thread+6)
art: art/runtime/runtime.cc:408]   (no managed stack frames)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "JDWP" prio=5 tid=4 WaitingInMainDebuggerLoop
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c231f0 self=0xe2d95400
art: art/runtime/runtime.cc:408]   | sysTid=8905 nice=0 cgrp=default sched=0/0 handle=0xe96a2920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 1355728 3599478 17 ) utm=0 stm=0 core=0 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe95a6000-0xe95a8000 stackSize=1014KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: poll_schedule_timeout+0x40/0x6c
art: art/runtime/runtime.cc:408]   kernel: do_select+0x534/0x5d4
art: art/runtime/runtime.cc:408]   kernel: compat_core_sys_select+0x18c/0x21c
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_pselect6+0x268/0x288
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 00049088  /system/lib/libc.so (__pselect6+20)
art: art/runtime/runtime.cc:408]   native: #01 pc 0001d0f5  /system/lib/libc.so (select+88)
art: art/runtime/runtime.cc:408]   native: #02 pc 003fd3d3  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #03 pc 00248767  /system/lib/libart.so (_ZN3art4JDWP9JdwpState3RunEv+654)
art: art/runtime/runtime.cc:408]   native: #04 pc 00247f07  /system/lib/libart.so (_ZN3art4JDWPL15StartJdwpThreadEPv+22)
art: art/runtime/runtime.cc:408]   native: #05 pc 000479c3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
art: art/runtime/runtime.cc:408]   native: #06 pc 00019efd  /system/lib/libc.so (__start_thread+6)
art: art/runtime/runtime.cc:408]   (no managed stack frames)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "ReferenceQueueDaemon" prio=5 tid=5 Waiting
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23280 self=0xdd118b00
art: art/runtime/runtime.cc:408]   | sysTid=8907 nice=0 cgrp=default sched=0/0 handle=0xe95a3920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 25316658 9453648 116 ) utm=2 stm=0 core=1 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe94a1000-0xe94a3000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b4  /system/lib/libc.so (syscall+28)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6b4d  /system/lib/libart.so hreadE+92)
art: art/runtime/runtime.cc:408]   native: #02 pc 0029efa1  /system/lib/libart.so eE+512)
art: art/runtime/runtime.cc:408]   native: #03 pc 002a073b  /system/lib/libart.so ExibNS_11ThreadStateE+258)
art: art/runtime/runtime.cc:408]   native: #04 pc 002afbf7  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #05 pc 00000537  /data/dalvik-cache/arm/system@framework@boot.oat (
art: art/runtime/runtime.cc:408]   at java.lang.Object.wait!(Native method)
art: art/runtime/runtime.cc:408]   - waiting on <0x04a7d3f8> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:150)
art: art/runtime/runtime.cc:408]   - locked <0x04a7d3f8> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.run(Thread.java:776)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "FinalizerDaemon" prio=5 tid=6 Waiting
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23310 self=0xea185900
art: art/runtime/runtime.cc:408]   | sysTid=8908 nice=0 cgrp=default sched=0/0 handle=0xe949e920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 37011447 8431253 127 ) utm=2 stm=1 core=2 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe939c000-0xe939e000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b4  /system/lib/libc.so (syscall+28)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6b4d  /system/lib/libart.so hreadE+92)
art: art/runtime/runtime.cc:408]   native: #02 pc 0029efa1  /system/lib/libart.so eE+512)
art: art/runtime/runtime.cc:408]   native: #03 pc 002a073b  /system/lib/libart.so ExibNS_11ThreadStateE+258)
art: art/runtime/runtime.cc:408]   native: #04 pc 002afc23  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #05 pc 00000635  /data/dalvik-cache/arm/system@framework@boot.oat (
art: art/runtime/runtime.cc:408]   at java.lang.Object.wait!(Native method)
art: art/runtime/runtime.cc:408]   - waiting on <0x07db00d1> (a java.lang.Object)
art: art/runtime/runtime.cc:408]   at java.lang.Object.wait(Object.java:407)
art: art/runtime/runtime.cc:408]   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
art: art/runtime/runtime.cc:408]   - locked <0x07db00d1> (a java.lang.Object)
art: art/runtime/runtime.cc:408]   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:204)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.run(Thread.java:776)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "FinalizerWatchdogDaemon" prio=5 tid=7 Sleeping
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c233a0 self=0xea185e00
art: art/runtime/runtime.cc:408]   | sysTid=8909 nice=0 cgrp=default sched=0/0 handle=0xe9399920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 682292 3562499 23 ) utm=0 stm=0 core=2 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe9297000-0xe9299000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b8  /system/lib/libc.so (syscall+32)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6f79  /system/lib/libart.so +108)
art: art/runtime/runtime.cc:408]   native: #02 pc 0029efb1  /system/lib/libart.so eE+528)
art: art/runtime/runtime.cc:408]   native: #03 pc 002a073b  /system/lib/libart.so ExibNS_11ThreadStateE+258)
art: art/runtime/runtime.cc:408]   native: #04 pc 002b4855  /system/lib/libart.so xi+56)
art: art/runtime/runtime.cc:408]   native: #05 pc 00093683  /data/dalvik-cache/arm/system@framework@boot.oat (26)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.sleep!(Native method)
art: art/runtime/runtime.cc:408]   - sleeping on <0x05253736> (a java.lang.Object)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.sleep(Thread.java:379)
art: art/runtime/runtime.cc:408]   - locked <0x05253736> (a java.lang.Object)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.sleep(Thread.java:321)
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:314)
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:336)
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:253)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.run(Thread.java:776)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "HeapTaskDaemon" prio=5 tid=8 Blocked
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23430 self=0xea186300
art: art/runtime/runtime.cc:408]   | sysTid=8910 nice=0 cgrp=default sched=0/0 handle=0xe9294920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 1592385442 240584379 1188 ) utm=147 stm=12 core=2 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe9192000-0xe9194000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b8  /system/lib/libc.so (syscall+32)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6f79  /system/lib/libart.so +108)
art: art/runtime/runtime.cc:408]   native: #02 pc 001b4a15  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   native: #03 pc 001b50d1  /system/lib/libart.so +44)
art: art/runtime/runtime.cc:408]   native: #04 pc 00260def  /data/dalvik-cache/arm/system@framework@boot-core-libart.oat (
art: art/runtime/runtime.cc:408]   at dalvik.system.VMRuntime.runHeapTasks(Native method)
art: art/runtime/runtime.cc:408]   - waiting to lock an unknown object
art: art/runtime/runtime.cc:408]   at java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:433)
art: art/runtime/runtime.cc:408]   at java.lang.Thread.run(Thread.java:776)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "Binder:8892_1" prio=5 tid=9 Native
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23550 self=0xea186800
art: art/runtime/runtime.cc:408]   | sysTid=8911 nice=0 cgrp=default sched=0/0 handle=0xe9091920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 670170815 211742194 4041 ) utm=39 stm=28 core=2 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe8f95000-0xe8f97000 stackSize=1014KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: futex_wait_queue_me+0xdc/0x168
art: art/runtime/runtime.cc:408]   kernel: futex_wait+0xf0/0x244
art: art/runtime/runtime.cc:408]   kernel: do_futex+0x168/0xa64
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_futex+0x7c/0x15c
art: art/runtime/runtime.cc:408]   kernel: el0_svc_naked+0x24/0x28
art: art/runtime/runtime.cc:408]   native: #00 pc 000174b4  /system/lib/libc.so (syscall+28)
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6b4d  /system/lib/libart.so hreadE+92)
art: art/runtime/runtime.cc:408]   native: #02 pc 00265c73  /system/lib/libart.so P10_jmethodIDSt9__va_list+226)
art: art/runtime/runtime.cc:408]   native: #03 pc 00071101  /system/lib/libandroid_runtime.so (???)
art: art/runtime/runtime.cc:408]   native: #04 pc 0009e9e3  /system/lib/libandroid_runtime.so (???)
art: art/runtime/runtime.cc:408]   native: #05 pc 000359bf  /system/lib/libbinder.so )
art: art/runtime/runtime.cc:408]   native: #06 pc 0003d19d  /system/lib/libbinder.so 
art: art/runtime/runtime.cc:408]   native: #07 pc 0003cdef  /system/lib/libbinder.so +114)
art: art/runtime/runtime.cc:408]   native: #08 pc 0003d2ff  /system/lib/libbinder.so 
art: art/runtime/runtime.cc:408]   native: #09 pc 0004f985  /system/lib/libbinder.so (???)
art: art/runtime/runtime.cc:408]   native: #10 pc 0000e4d1  /vendor/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+144)
art: art/runtime/runtime.cc:408]   native: #11 pc 0006c895  /system/lib/libandroid_runtime.so 
art: art/runtime/runtime.cc:408]   native: #12 pc 000479c3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
art: art/runtime/runtime.cc:408]   native: #13 pc 00019efd  /system/lib/libc.so (__start_thread+6)
art: art/runtime/runtime.cc:408]   (no managed stack frames)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408] "Binder:8892_2" prio=5 tid=10 Native
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c23670 self=0xe2d96800
art: art/runtime/runtime.cc:408]   | sysTid=8912 nice=0 cgrp=default sched=0/0 handle=0xe8f90920
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 679614002 256192715 4174 ) utm=43 stm=24 core=0 HZ=100
art: art/runtime/runtime.cc:408]   | stack=0xe8e94000-0xe8e96000 stackSize=1014KB
art: art/runtime/runtime.cc:408]   | held mutexes=
art: art/runtime/runtime.cc:408]   kernel: __switch_to+0x74/0x8c
art: art/runtime/runtime.cc:408]   kernel: binder_thread_read+0xd14/0x154c
art: art/runtime/runtime.cc:408]   kernel: binder_ioctl+0x9a0/0xcdc
art: art/runtime/runtime.cc:408]   kernel: compat_SyS_ioctl+0xb0/0x1114
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x12c25790 self=0xdd135e00
art: art/runtime/runtime.cc:408]   | sysTid=8925 nice=0 cgrp=default sched=0/0 handle=0xe2ff3920
art: art/runtime/runtime.cc:408]   at java.lang.Thread.run(Thread.java:776)
art: art/runtime/runtime.cc:408]   native: #02 pc 0029efb1  /system/lib/libart.so eE+528)
art: art/runtime/runtime.cc:408]   native: #04 pc 002afc23  /system/lib/libart.so 
art: art/runtime/runtime.cc:408]   at java.lang.Thread.parkFor$(Thread.java:2142)
art: art/runtime/runtime.cc:408]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
art: art/runtime/runtime.cc:408] 
art: art/runtime/runtime.cc:408]   | group="" sCount=1 dsCount=0 obj=0x130d85e0 self=0xb35b5000
art: art/runtime/runtime.cc:408]   | state=S schedstat=( 447931202 152343221 2566 ) utm=29 stm=15 core=2 HZ=100
art: art/runtime/runtime.cc:408]   at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(
art: art/runtime/runtime.cc:408]   | stack=0xad8f8000-0xad8fa000 stackSize=1038KB
art: art/runtime/runtime.cc:408]   native: #01 pc 000b6f79  /system/lib/libart.so +108) 

论坛里类似的问题有:

  1. cocos cteator 编译的包 运行报错 原因是缺少他们第三方的 VoiceRecorder 方法实现,和本问题不同;
  2. cocos2dx3.10 android 出现local reference table overflow (max=512) 崩溃 :解答说是和 HttpClient 有关,而我们的问题不是 HTTPClient 的调用引发,像是渲染过程中的卡死;
  3. jsb.reflection.callStaticMethod 大量调用会导致 local reference table overflow (max=512) 请问怎么解决 这个贴基本没有什么价值。

看到一个 PR 用于修复 local reference table overflow 问题,但我把它也合进了工程里头,没有效果。

请问还有没有什么解决方案?

经过定位,我发现 callStaticMethod 对 JNI 层字符串型参数的转换 NewStringUTF() 方法没有在后面执行 DeleteLocalRef() 方法释放,导致字符串型参数一直积压在 reference table 里头没有释放,久而久之就会引发 local reference table 错误。

已发 pull request:https://github.com/cocos-creator/cocos2d-x-lite/pull/1178

1赞