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

为 CocosDownloader.java 添加必要的 null check. #17911

Open
wants to merge 1 commit into
base: v3.8.6
Choose a base branch
from

Conversation

finscn
Copy link
Contributor

@finscn finscn commented Nov 23, 2024

解决 GlobalObject.getContext() 为 null 时, 下载任务出错的bug.
目前 3.8.4 版本 构建的 安卓原生app 运行时 偶尔会出现下列错误, 导致程序异常:

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)

此 PR 尝试解决该问题.

虽然提到了 3.8.6 , 但是希望 3.8.5 就能解决.
另外 不知道 iOS 版本是否也有类似问题.
如果有 麻烦 cocos官方修复下.

解决 GlobalObject.getContext() 为 null 时,  下载任务出错的bug.
Copy link

✅ Package size is not changed

Interface Check Report

This pull request does not change any public interfaces !

@minggo
Copy link
Contributor

minggo commented Nov 27, 2024

我们得看一下这样解决是否合理。

@finscn
Copy link
Contributor Author

finscn commented Nov 27, 2024

我们得看一下这样解决是否合理。

另一个 issue里 又一个大佬给的建议 似乎更好. 就是 用 Application Context , 而且他怀疑是 cocos写错了. 你可以看看. 我觉得他比我专业多了. 我不是专业安卓开发.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants