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

Make the game not load everything at the start and remove audio from memory that isn't in use #9

Open
PoRa-dayo opened this issue Nov 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@PoRa-dayo
Copy link

PoRa-dayo commented Nov 2, 2024

Describe the bug
So the game apparently tries to pre-load every single resource in the game including all of the audio before starting. This is pretty much why some computers, and especially mobile phones, struggle to start the game, because websites on phones just crash when the amount of memory stored is around over 500 KB, while this game requires nearly 5 million KB to even start.

To Reproduce
Just open Task Manager and see the RAM. You can compare the RAM with this official game made by TalkWeb: https://pvz-oe.ct8.pl/ which is also on Cocos Creator. You should also pay attention to how the game handles the loading.

Suggestion
If you still want to load the graphics at the start then it's fine, but for the audio you should really consider. Only load the audio/music when necessary (like when you open a map or game mode or a level), and only store a limited amount of music/audio in memory at a time. From my experience it's best to store at most 2 songs and 30 sound effects at a time in memory, since the game uses Web Audio so it takes a lot more space in memory compared to HTML5 Audio. Cocos should already have a built-in method to remove audio from memory (it's a process called "unloading" the audio).

@BlueMrGutsy
Copy link

Agreed bro

@Gzh0821 Gzh0821 added the enhancement New feature or request label Nov 3, 2024
@guygaming647
Copy link

really needed, I have seen countless people in the Discord server complain about memory related issues

@Redles
Copy link

Redles commented Dec 29, 2024

Agreed, this is important.

@PoRa-dayo
Copy link
Author

Here are two tools that I believe can help you detect causes behind memory issues:

  1. https://facebook.github.io/memlab/
  2. DevTools, especially the Detached Elements tool in Microsoft Edge
yMRfIEG689 Like as you can see here it's not just the audio, but also all these

elements not being cleaned up properly and thus entered the "Detached" state where they can never be removed from memory as long as the game's still running.

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

No branches or pull requests

5 participants