3.5.1 Abort message: 'art/runtime/indirect_reference_table.cc:115] JNI ERROR (app bug): local reference table overflow (max=512)'

2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: Build fingerprint: 'Meizu/meizu_PRO6Plus/PRO6Plus:6.0.1/MMB29T/m96.Flyme_5.1.1488162804:user/release-keys'
2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: Revision: '0'
2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: ABI: 'arm64'
2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: pid: 7313, tid: 7537, name: Thread-849  >>> com.joyparty.art <<<
2022-08-03 18:14:29.155 2633-2633/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2022-08-03 18:14:29.218 2633-2633/? A/DEBUG: Abort message: 'art/runtime/indirect_reference_table.cc:115] JNI ERROR (app bug): local reference table overflow (max=512)'
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x0   0000000000000000  x1   0000000000001d71  x2   0000000000000006  x3   0000000000000000
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x4   0000000000000000  x5   0000000000000001  x6   0000000000000000  x7   0000000000000000
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x8   0000000000000083  x9   0000000000006c40  x10  000000003087c358  x11  000000003087c498
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x12  0000000000000000  x13  0000007f8dc14000  x14  0000000000000000  x15  0000000000000000
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x16  0000007f8dc06568  x17  0000007f8db994a8  x18  0000007f8dc17f50  x19  0000007f6797f500
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x20  0000007f6797f440  x21  0000000000000002  x22  0000000000000006  x23  0000007f8a6b9000
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x24  0000007f0a186c40  x25  0000007f679e7800  x26  0000007f8a6c5a40  x27  0000007f8a5db000
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     x28  0000007f0a186600  x29  0000007f6797d8e0  x30  0000007f8db96c44
2022-08-03 18:14:29.219 2633-2633/? A/DEBUG:     sp   0000007f6797d8e0  pc   0000007f8db994b0  pstate 0000000020000000
2022-08-03 18:14:29.235 2633-2633/? A/DEBUG: backtrace:
2022-08-03 18:14:29.235 2633-2633/? A/DEBUG:     #00 pc 00000000000694b0  /system/lib64/libc.so (tgkill+8)
2022-08-03 18:14:29.235 2633-2633/? A/DEBUG:     #01 pc 0000000000066c40  /system/lib64/libc.so (pthread_kill+68)
2022-08-03 18:14:29.235 2633-2633/? A/DEBUG:     #02 pc 0000000000023af0  /system/lib64/libc.so (raise+28)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #03 pc 000000000001e290  /system/lib64/libc.so (abort+60)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #04 pc 00000000004320a0  /system/lib64/libart.so (art::Runtime::Abort()+324)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #05 pc 00000000001361e4  /system/lib64/libart.so (art::LogMessage::~LogMessage()+3136)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #06 pc 0000000000130c88  /system/lib64/libart.so (art::Barrier::~Barrier()+296)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #07 pc 0000000000466c84  /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+212)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #08 pc 0000000000432188  /system/lib64/libart.so (art::Runtime::Abort()+556)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #09 pc 00000000001361e4  /system/lib64/libart.so (art::LogMessage::~LogMessage()+3136)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #10 pc 00000000002718b8  /system/lib64/libart.so (art::IndirectReferenceTable::Add(unsigned int, art::mirror::Object*)+372)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #11 pc 000000000032f318  /system/lib64/libart.so (art::JNI::CallStaticObjectMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+468)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #12 pc 000000000015c240  /system/lib64/libart.so (art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+2716)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #13 pc 000000000015d1dc  /system/lib64/libart.so (art::CheckJNI::CallStaticObjectMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+68)
2022-08-03 18:14:29.236 2633-2633/? A/DEBUG:     #14 pc 00000000008617c8  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so (_JNIEnv::CallStaticObjectMethod(_jclass*, _jmethodID*, ...)+116)
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #15 pc 0000000000861438  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > cc::JniHelper::callStaticStringMethod<>(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+276)
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #16 pc 00000000008d9138  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so (cc::FileUtilsAndroid::getWritablePath() const+152)
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #17 pc 000000000094f5e4  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so (js_engine_FileUtils_getWritablePathRegistry(v8::FunctionCallbackInfo<v8::Value> const&)+400)
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #18 pc 00000000014775f8  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so (v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo)+548)
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #19 pc 0000000001476c54  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #20 pc 00000000014763e4  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so
2022-08-03 18:14:29.237 2633-2633/? A/DEBUG:     #21 pc 000000000138b308  /data/app/com.joyparty.art-1/lib/arm64/libcocos2djs.so

第二段日志:

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115] JNI ERROR (app bug): local reference table overflow (max=512)

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115] local reference table dump:

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]   Last 10 entries (of 512):

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       511: 0x13a52c00 java.lang.String "{"storageKey":"A... (260 chars)

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       510: 0x13563400 java.lang.Class<com.cocos.lib.CocosLocalStorage>

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       509: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       508: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.024 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       507: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       506: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       505: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       504: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       503: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       502: 0x1334f800 java.lang.Class<com.cocos.lib.CocosHelper>

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]   Summary:

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]       510 of java.lang.Class (3 unique instances)

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]         2 of java.lang.String (2 unique instances)

2022-08-02 15:50:53.025 12830-12951/? A/art: art/runtime/indirect_reference_table.cc:115]

Again?

3.4.1修复过这个问题,pr在此:https://github.com/cocos/engine-native/pull/4161

3.5.1还有出现的话,能提供一个demo吗?

问题已经定位出来,
jsb.fileUtils.getWritablePath()
这个方法不能频繁调用,否则会报上面的错误,所以正确的做法是获取一次后缓存起来,下次直接读取缓存,避免频繁调用

我在3.6验证的,即便是每帧调用getWritablePath也没有复现,所以可以试一试用3.6

跟机型有关,少数机型才会这样,大部分机型不会出现这个问题


合并这个PR可以修复该问题