Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[安卓原生]线上版本出现大量的 libcocos.so 引起的闪退问题. #17909

Open
finscn opened this issue Nov 23, 2024 · 3 comments
Open
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@finscn
Copy link
Contributor

finscn commented Nov 23, 2024

Cocos Creator version

3.8.4

System information

android

Issue description

该线上版本 已经停用了vulkan , 使用的是老管线. 后台捕捉到的错误信息如下:

    #00 0x000000000090c1e0 libcocos.so Java_com_cocos_lib_CocosDownloader_nativeOnProgress+76
    #01 0x0000000000222248 libart.so art_quick_generic_jni_trampoline+148
    #02 0x00000000002132a0 libart.so nterp_helper+7468
    #03 0x00000000002132e8 libart.so nterp_helper+7540
    #04 0x00000000002124c8 libart.so nterp_helper+3924
    #05 0x0000000000218bec libart.so art_quick_invoke_static_stub+568
    #06 0x00000000002845c8 libart.so art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+216
    #07 0x00000000006556c8 libart.so art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+448
    #08 0x0000000000655b8c libart.so art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92
    #09 0x00000000004b55ac libart.so art::JNI<false>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+640
    #10 0x0000000000611fa8 libcocos.so
    #11 0x0000000000610a18 libcocos.so
    #12 0x000000000061160c libcocos.so
    #13 0x000000000064f938 libcocos.so
    #14 0x000000000064f7ac libcocos.so
    #15 0x0000000000bf63fc libcocos.so
    #16 0x00000000000ebe74 libc.so __pthread_start(void*)+264
    #17 0x000000000008b7f4 libc.so __start_thread+64

最后是和 CocosDownloader 相关的.
目前大多数玩家是可以正常游戏的, 但是出现这个错误的设备有几百台.
我们研发并不能提供一个可以重现这个bug 的demo.

希望官方能给予一些帮助 谢谢.

补充:
线上还会捕捉到一个 java 的错误:

java.lang.NullPointerException
Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference.

at com.cocos.lib.CocosDownloader$c$c.a(Unknown Source:33)
at k1.w$b.e(Unknown Source:19)
at l1.b.run(Unknown Source:17)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

我搜索了 cocos的代码, 用到 getSharedPreferences 方法的 , 正好是 CocosDownloader.java 类.
这就和前面的报错信息里的 CocosDownloader 不谋而合了. 所以 是不是 这个 CocosDownloader.java 在调用 getSharedPreferences 时产生了异常? 进而又触发了前面的原生的异常?

Relevant error log output

No response

Steps to reproduce

1

Minimal reproduction project

No response

@finscn finscn added Bug Needs Triage Needs to be assigned by the team labels Nov 23, 2024
@finscn
Copy link
Contributor Author

finscn commented Nov 23, 2024

除了主贴的 错误, 还有100多个用户是这类错误, 非常抽象

#00 0x0000000000256108 libart.so art::ArtMethod::PrettyMethod(bool)+80
    #01 0x00000000002568c4 libart.so art::ArtMethod::GetOatQuickMethodHeader(unsigned long)+720
    #02 0x000000000066f970 libart.so void art::StackVisitor::WalkStack<(art::StackVisitor::CountTransitions)1>(bool)+392
    #03 0x000000000069facc libart.so art::Thread::VisitRoots(art::RootVisitor*, art::VisitRootFlags)+3760
    #04 0x0000000000320898 libart.so art::gc::collector::ConcurrentCopying::ThreadFlipVisitor::Run(art::Thread*)+300
    #05 0x0000000000694cb8 libart.so art::Thread::FullSuspendCheck(bool)+1128
    #06 0x0000000000753ec8 libart.so artTestSuspendFromCode+72
    #07 0x0000000000226e20 libart.so art_quick_test_suspend+156
    #08 0x000000000020ec9c libart.so nterp_helper+22808
    #09 0x000000000020a2d8 libart.so nterp_helper+3924
    #10 0x0000000000210c84 libart.so art_quick_invoke_static_stub+640
    #11 0x0000000000255f78 libart.so art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228
    #12 0x0000000000633058 libart.so art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+412
    #13 0x0000000000633584 libart.so art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+84
    #14 0x000000000049857c libart.so art::JNI<false>::CallStaticIntMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+608
    #15 0x00000000000801b8 libsandbox_ext.so
    #16 0x0000000000080120 libsandbox_ext.so
    #17 0x000000000075c5d4 boot-framework.oat android.os.Binder.execTransact+160

以及

   #00 0x0000000000256128 libart.so art::ArtMethod::PrettyMethod(bool)+112
    #01 0x000844f3eaac38c4 

以及

 #00 0x0000000000d1e6dc libcocos.so
    #01 0x0000000000bd3aa8 libcocos.so
    #02 0x00000000006191d4 libcocos.so
    #03 0x00000000006182d8 libcocos.so
    #04 0x000000000060d784 libcocos.so
    #05 0x00000000006501c8 libcocos.so
    #06 0x0000000000bf6538 libcocos.so
    #07 0x000000000064f894 libcocos.so
    #08 0x000000000064f7ac libcocos.so
    #09 0x0000000000bf6400 libcocos.so
    #10 0x000000000010ba84 libc.so __pthread_start(void*)+208
    #11 0x000000000009f694 libc.so __start_thread+64

以及

    #00 0x000000000006fad8 libc.so __statfs+8
    #01 0x000000000002e920 libc.so statvfs+36
    #02 0x000000000002d02c libjavacore.so Linux_getpwnam(_JNIEnv*, _jobject*, _jstring*)+264
    #03 0x000000000008c25c boot-core-libart.oat libcore.io.Linux.capget [DEDUPED]+152
    #04 0x0000000000535d8c libart.so art::JDWP::JdwpAdbState::ProcessIncoming()+1680
    #05 0x00000000000a8744 libart.so

@finscn
Copy link
Contributor Author

finscn commented Nov 23, 2024

出错的代码是

SharedPreferences sharedPreferences = GlobalObject.getContext().getSharedPreferences("breakpointDownloadSupport", Context.MODE_PRIVATE);

结合之前的错误信息, 应该是 GlobalObject.getContext() 为 null.
GlobalObject 中的 context 是一个 Activity 的context , 而不是 Application的context.
Activity的context在某些情况下会被销毁重建.
比如某些手机启动游戏之后,走第三方登录, 或者游戏过程中调用第三方支付,

虽然 cocos的代码中, 会在Activity重建时,重新给 GlobalObject中的context赋值.
但是如果在 销毁之后,重建之前, 这段时间里, 执行了 代码所在的 run task , 就会出错.
所以建议在 CocosDownloader.java 中的 那段调用 getSharedPreferences() 方法的 run task 里, 对 context 做 null check.
或者在 Activity销毁后, 确保该 run task 不被执行.

@finscn
Copy link
Contributor Author

finscn commented Nov 24, 2024

论坛里搜vulkan,你可能会找到答案

我主贴第一行就说了 ,已经停用vulkan了.... 老哥, 我说句实话 你别生气哈.. 我发现你在github上留言特别积极, 但是大多数都不在点上. 别人说东你西, 完全不在一个频道.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

1 participant