Description of the problem of slow loading of game levels: Cocos version 2.4.10, the mini-game has 40 levels, each level is 2M, a total of 80M, and it cannot be sub-packaged because the file is too large and exceeds the regulations of Douyin. All levels are configured with remote packages, zip compression, and loaded on demand. Click one to load one. After building, upload to the server, run the Douyin developer tool, and find that it takes 30 seconds to load a level. In cocos, the level loads normally, 1-2 seconds. How do you generally deal with this problem? Please give me some guidance. If there are masters who can solve it, please leave a message. It’s not in vain. Thank you all.
Code screenshot:
Level bundle screenshot:
Build screenshots:
Network request screenshot:
5 Likes
2mb on demand loading 30s each?
Yes, it’s normal in RunoseAI, and then it takes 30 seconds to load when I open it with the TikTok developer tool. I used bundle.loadDir(dir, type, function(err, assets) {…} to load the remote package, but I can’t tell what’s going on. I used CDN, but it doesn’t work either.
1 Like
Why is the data so large?
Because there are many levels, 40 levels, each 2M, that is 80M.
First of all, why do we need to loadDir? Shouldn’t we load what we need? What is in the dir you want to load? Secondly, if a single level is 2M and the loading speed cannot meet the requirement, then you should split the single level further, right? For example, if there are nodes 1, 2, etc. in the level, can we load them on demand after entering the level, or recursively load them one by one? Finally, it is not normal for a 2M item to take 30 seconds to load.
First check whether the network is loading slowly or the remote package is loading slowly from the local disk after downloading.
Thanks for the detailed reply. 1. Use loadDir, mainly because each level is a bundle, and then when you click in, all the resources, pictures, background music, etc. of this level need to be loaded before you can play normally. 2. The main reason is that it takes 30 seconds to load 2M, which is quite abnormal. I use Tencent Cloud and the speed is no problem. I feel that when Douyin loads the level, it automatically adapts to use tt.downfile. This interface can only be serial and the speed is limited, otherwise it would not take 30 seconds. I compressed the bundle package of a level into zip. Even if it is downloaded serially, a package has only 2 files, one json and one zip, so it will not take 30 seconds.
2 Likes