Pause/Resume Godot Engine from JS in Web Export

Godot Version

4.5

Question

I am developing a cross-platform live wallpaper app that supports Godot games as wallpapers, similar to the way Wallpaper Engine supports displaying Unity games as wallpapers.

I use the Godot web export to display the wallpapers in a webview across all platforms, which is working fine. The problem now is that the pause and resume functions I have in JS are unable to pause and resume Godot Engine itself, to save battery and such when needed. I have looked into the Godot Engine source code and cannot find a method to pause/resume the engine itself from JS. Is there a way to do this?

You could probably use the JavaScriptBridge singleton to communicate with the game and call SceneTree.paused

You should probably enable OS.low_processor_usage_mode too if applicable or maybe limit the FPS with Engine.max_fps

Thanks for the tip! I was trying to avoid the singleton, since that requires the PCK content to expose the function, and I was trying to have the engine load unique PCK files for each wallpaper. It looks like I’ll have to make my own base PCK that then loads the different wallpaper PCKs at runtime instead so that I can do this properly.