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

Not possible to exclude SoundManager in custom build #4428

Closed
goldfire opened this issue Mar 16, 2019 · 5 comments
Closed

Not possible to exclude SoundManager in custom build #4428

goldfire opened this issue Mar 16, 2019 · 5 comments

Comments

@goldfire
Copy link
Contributor

Version

  • Phaser Version: 3.16.2

Description

As described in devlog 127 (https://phaser.io/phaser3/devlog/127), doing a custom build of phaser that excludes the sound manager should remove those files from the output. However, because of SoundManagerCreator being required in core/Games.j, a lot of the sound code gets included anyway (and is leading to errors with the onBlur, etc events).

Additional Information

I assume this isn't intended behavior based on the comments in the devlog, but I'm not sure in the broader context of the engine what the best approach to fix it is.

@spayton
Copy link
Contributor

spayton commented Mar 19, 2019

I also tried doing this yesterday, slimming down Phaser3 omitting some of the larger chunks I didn't want, such as tilemaps, physics, rendertexture, sounds, tilesprite, keyboard, gamepad, various file type loaders etc.

As you've found, sound dependency cannot be removed solely via the webpack config because SoundManagerCreator is required in core/game.js and referenced in scene/SceneManager.js:loadComplete().

In my test case I only had to knock out the Sound: require('./sound') from the webpack config and edit the two files mentions above to get it going without Phaser sounds, but now I have the headache of edited source files to keep intact with git updates.

I think some chunks of the Phaser lib should be more easily excluded. When their dependency is in the source code then some more of those conditional compile typedef's could do the job, just like CANVAS_RENDERER does.

What I liked about PhaserV2 was the ability to override almost any functionality of the lib without touching it just by supplying replacement prototype functions.

@photonstorm
Copy link
Collaborator

There is a new webpack config FEATURE_SOUND which is set to true by default, but if set to false it will exclude the Sound Manager and all of its systems into the build files.

Please can you test?

@spayton
Copy link
Contributor

spayton commented May 3, 2019

When setting FEATURE_SOUND to false an exception is thrown "Cannot read property 'onBlurPausedSounds' of null" on checking this.game.sound.onBlurPausedSounds in SceneManager.loadComplete()

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

@spayton
Copy link
Contributor

spayton commented May 7, 2019

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Yup, that's got it. Though using the webpack flag instead would would have resulted in less/quicker code, ie

if (typeof FEATURE_SOUND) { if (this.game.sound.onBlurPausedSounds) { this.game.sound.unlock(); } }

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

No branches or pull requests

3 participants