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

Energy use #129

Open
Article19 opened this issue Apr 24, 2020 · 3 comments
Open

Energy use #129

Article19 opened this issue Apr 24, 2020 · 3 comments

Comments

@Article19
Copy link

I believe I’m noticing different amounts of energy use (as measured by the Activity Monitor in OSX) in different scenarios. In particular, when I pause a game (stop all rendering and tickers) if I issue a PIXI.sound.pauseAll() I see a MUCH lower average energy impact than if I only pause the 1 or 2 sounds that are playing at that moment. Is there some background process running that pauseAll interrupts?

@andrewstart
Copy link
Contributor

andrewstart commented Jul 2, 2020

pauseAll() suspends the WebAudio audio context, so the browser stops whatever processing it normally does for the context.

@Article19
Copy link
Author

Understood. As an accompanying concern, are any of the built-in PIXI tickers being used? We often fiddle with the FPS of some of these, and completely stop others. Haven't run into any issues with sound yet, but wouldn't want to find something out the hard way. In our experience, high ticker rates results in more cpu use.

@andrewstart
Copy link
Contributor

Each playing audio instance will attach a listener to Ticker.shared for an update method. Reducing the fps of that ticker will have two effects:

  1. Reduce how many "progress" events it emits (one per tick, if the sound is playing).
  2. Reduce the accuracy of unpausing audio, as playback progress is calculated during this update method. This matters if pausing is done outside of the update loop, which I would imagine would generally be the case.

That said, the actual cpu usage of the update method depends on the number of sounds playing and due to the small amount of basic math should pale in the comparison to usage due to rendering.

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

No branches or pull requests

2 participants