Is there a built-in way or recommended approach the flush the cache in Phaser? Json, tilemaps, music, etc. to keep the memory footprint as low a possible.
My little phaser game is running perfectly on regular devices (Android, iOs, iPad, pc, etc.) and on most KaiOs feature phones as well (such as the Nokia Flip 5520, see picture).
These low spec KaiOs devices have very little ram; normal ones have 512megs (leaving about 290megs for the game to run). The entry level ones however only have 256megs of ram. It leaves about 30megs for an app to run. I had found and fixed a memory leak (pr) in a tile animator plugin but that doesnât stop crashing when switching scenes (involving loading music & co).
Thanks Rich. Iâll also keep you posted once I get a new build tested with these Phaser-level cache flushing in place; The 256megs device needs to be rooted for me to tinker with its memory on the fly.
One thing I noticed when testing this, is that the browser will run major gc when it detects it is mostly idle.
Itâs possible this never happens on a low-spec phone, because of the cost of the game loop, rendering, etc.
You might be able to invoke it by freeing-up the browser from processing anything. Literally pause the game, rendering, etc so Phaser is doing nothing and the browser is idle. Then it may try to run gc, freeing up your memory.
Good idea. Just tried that as I could re-flash the device. Adding a 5s pause after clearing caches and preloading but that didnât help.
All that works so far is to disable the music. I canât settle for this as it works fine on 512megs KaiOs devices⌠and there is no memory detection at runtime so this isnât an option reallyâŚ
Iâll try to dig deeper in the WebAudio api and see if anything could help.
Erratum: HTML5 Audio doesnât work on KaiOs. No crash, but no sound. The low spec (256megs) device is just too weak to handle music and a game.
Seeing some bug (link) I gave Howler a try while disabling Phaserâs audio engine. Same problem, crashing when shutting down / preloading / creating World and playing music. Damn.
Currently fighting with the outdated / bogus APIs like navigator.getFeature(âhardware.memoryâ) which isnât working so far. Last trick that could save the day on that platform.
Well, that was off topic. Still, I have great hopes to see KaiOs as a great target for just any Phaser game
Ok @rich , I give up⌠tried to replace some internals in Phaser to use MediaElementSource instead of AudioBuffer (as suggested in the spec for long sounds). Doesnât help either. The 256megs device barely leaves 25-30 megs of ram to the game and thereâs no more time I can spend on this (not being snobbish, but itâs the cheap version of the cheap phone for developing countries).
So⌠this âsolutionâ might remind you of the Atari ST days!
Let the player decide whether he wants crashes or no music on his 520ST
emscripten ports have access to hardware memory amounts, but not us HTML5 game devs.
N.B. Runs perfectly well with music (an no crashes) on the 1040ST⌠err, 512megs Kaios devices, I mean
im not sure if a window.reload in simple javascript will do, it doesnt seem to work always on linux/firefox (i dont test on other stuff much) as over time it still starts lagging but afaik âin theoryâ reloading the page should flush everything so instead of restarting scenes on a gameover if you reload the whole page (in theory or maybe that was somewhere in the past) it should all be flushed (caveats ⌠lol) and the game starts from menu again (ofc that wont work mid-game unless you start making constructs with cookies etcâŚ-) but at game-over or init or back to menu (in theory) i suppose it should
(someone do correct me if im wrong here) i sometimes leave it on and in the morning (at wake-uptime) i find it lagging while it shouldnt so there must be some buildup or leakage somewhere
Interresting point - however for some reason reloading the page from the appâs standpoing (like weâd do via capacitor / cordova) just reloads a folder view, showing the list of files at the root of the web appâs www folder.
Reloading would indeed expose the user to the boot menu (âmusic / no musicâ in my case) even though the engine keeps track of the userâs progress every checkpoint / scene switch. Iâll stick to the âmusic on/offâ boot option since 256megs devices are on the low end of the feature phone spectrum⌠which is already on the low end of specs, generally speaking
thatâs certainly interesting ⌠i can only speak for webpages in mostly firefox and chrome
it just gets me the page its called on which is pulled from the server (i suppose) and parsed over again, including serverside php (or so i hope to think, im certainly more of a hobbyist