Open wubuduan opened 5 years ago
补充:我们是一款乙女avg游戏,游戏内会播放大量的音频,音频的大小也比较大,bgm会在1M-3M之间。会频繁的触发播放和停止音频的操作。
频繁的触发播放和停止音频
I ran the test code added in https://github.com/cocos2d/cocos2d-x/pull/18865, it does not crash. It is not sure that if this is the real reason for the crash.
Can you run the test code in your codebase? Since your code is customized, I need to confirm if play/stop would cause a crash in your project. @wubuduan
Ok,we will try the test code, to confirm if play/stop would cause a crash
@PatriceJiang We test in our codebase ,frequently play/stop music, running about 30 minutes on iphone7Plus, it does not crash.
I tried to reproduce the crash and made no progress for now. If you find anything new please let me know. @wubuduan
@PatriceJiang Many thanks, we are trying to reproduce the crash too. When we have new progress, I will tell you.
We modified the value of PCMDATA_CACHEMAXSIZE to 100M and gave it to online players for testing. The current problem did not appear again. @PatriceJiang
Also has this crash in production. issue_crash.txt cocos2d-x-3.17.2 (1528ea01d2749b4ef65e97f79cffa6135fe13c4d)
This is just a null pointer issue, simply add null checking in AudioPlayer.mm line 284 while (bufferProcessed > 0 && _audioCache) The cause of this crash is OpenAL somehow detected buffer not filling (device lag or audio interruption) then switch state to stop and cocos update will clear the streaming cache, but the above loop is still going and trying to get the buffer which is null.
Edited: A simple way to reproduce this crash is play a long sfx multiple times (> 20 instance), then it should crash.
This is just a null pointer issue, simply add null checking in AudioPlayer.mm line 284 while (bufferProcessed > 0 && _audioCache) The cause of this crash is OpenAL somehow detected buffer not filling (device lag or audio interruption) then switch state to stop and cocos update will clear the streaming cache, but the above loop is still going and trying to get the buffer which is null.
Edited: A simple way to reproduce this crash is play a long sfx multiple times (> 20 instance), then it should crash.
Do null checking in AudioPlayer.mm does not fix the bug, but increase PCMDATA_CACHEMAXSIZE value to 10485760, this problem is gone.