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

Add build option to enable MP1 and MP2 support in minimp3 #72729

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

Ithamar
Copy link

@Ithamar Ithamar commented Feb 4, 2023

This adds only 3.5k to the template size (Win/64bits).

fixes #72688

@Ithamar Ithamar requested a review from a team as a code owner February 4, 2023 19:22
@ellenhp
Copy link
Contributor

ellenhp commented Feb 4, 2023

I don't know if it makes sense to add even 3.5k to the export template to support one game. Couldn't you transcode these audio files or maintain a separate export template? 3.5k doesn't seem like much but for web games where it's common to strip down the export template via a custom build, every kb counts.

@Calinou Calinou added this to the 4.x milestone Feb 4, 2023
@Calinou
Copy link
Member

Calinou commented Feb 4, 2023

I don't know if it makes sense to add even 3.5k to the export template to support one game. Couldn't you transcode these audio files or maintain a separate export template? 3.5k doesn't seem like much but for web games where it's common to strip down the export template via a custom build, every kb counts.

The difference in HTML5 export templates is likely smaller (since these use optimize=size by default). It may be worth creating release HTML5 builds with and without this change to check if the difference is significant.

@ellenhp
Copy link
Contributor

ellenhp commented Feb 4, 2023

We're talking about a feature that likely only one person will ever use, though. And it seems like @Ithamar is more than capable of making their own export templates. I know 3.5k is practically nothing, but I still don't think this is a valuable feature for the mainline engine to have, and I think guidance is still to refuse-by-default to keep the engine small, right? https://godotengine.org/article/will-your-contribution-be-merged-heres-how-tell/

@Ithamar
Copy link
Author

Ithamar commented Feb 4, 2023

@ellenhp would a build-time option be acceptable? Or are you suggesting I maintain a fork?

@Riteo
Copy link
Contributor

Riteo commented Feb 4, 2023

I'll stick my nose in here to say that, were the mp2/mp1 branch be too big in html builds and considering that these formats are completely unused outside of remakes, a build flag would be perfect IMO, since it's basically a three line patch.

@ellenhp
Copy link
Contributor

ellenhp commented Feb 4, 2023

A build time option would be fine by me! I'm not opposed to this feature existing especially considering how little code maintenance burden it is for us (it's all in minimp3) but I just think that when someone goes to create a stripped-down web export for their game by removing every node that they don't use, that web export shouldn't have to know how to decode MP2. :)

@Riteo
Copy link
Contributor

Riteo commented Feb 4, 2023

@ellenhp thinking about it, are there some benchmarks about template size in relation to available features? I think that there might be lots of similar cases of "mostly unused thing that could be hidden behind a switch" that we could get rid of.

While this is a bit OT, #50148 might come useful in this regard, but as I said we should probably move into another thread if there exists one.

@Ithamar Ithamar requested a review from a team as a code owner February 4, 2023 20:49
SConstruct Outdated Show resolved Hide resolved
SConstruct Outdated Show resolved Hide resolved
modules/minimp3/audio_stream_mp3.cpp Outdated Show resolved Hide resolved
modules/minimp3/resource_importer_mp3.cpp Outdated Show resolved Hide resolved
@Riteo
Copy link
Contributor

Riteo commented Feb 4, 2023

Sorry for the "redo everything" review, at least I suggested a lot of changes, so you should be able to just apply them if you agree.

BTW Don't forget to squash everything once you're done!

@Ithamar
Copy link
Author

Ithamar commented Feb 4, 2023

Sorry for the "redo everything" review, at least I suggested a lot of changes, so you should be able to just apply them if you agree.

No problem, its not like it is a lot of code, so even if I do it manually it is not a lot of work ;)

BTW Don't forget to squash everything once you're done!

Ah, Github does not do that automagically? I'm more used to Gitlab which has an PR option to do this at merge time.

@Riteo
Copy link
Contributor

Riteo commented Feb 4, 2023

@Ithamar

Ah, Github does not do that automagically?

Nope.

I'm more used to Gitlab which has an PR option to do this at merge time.

I doubt that most of us use this platform out of favour :P

@Ithamar
Copy link
Author

Ithamar commented Feb 5, 2023

I'm more used to Gitlab which has an PR option to do this at merge time.

I doubt that most of us use this platform out of favour :P

Actually, turns out Github has the option too, it might be an idea to simply enforce this for PRs if it is the expected behaviour anyway......

@YuriSizov
Copy link
Contributor

We don't use this option on the main repo, because it doesn't create merge commits.

@Calinou
Copy link
Member

Calinou commented Feb 7, 2023

@ellenhp thinking about it, are there some benchmarks about template size in relation to available features? I think that there might be lots of similar cases of "mostly unused thing that could be hidden behind a switch" that we could get rid of.

I made https://github.com/Calinou/godot-size-benchmarks a few years ago, but I also had another script that invidiaully compiled Godot with each module disabled and found that optimize=size alone had a greater impact on binary size compared to disabling all modules.

Copy link
Contributor

@Riteo Riteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a teeny tiny issue (which is also my fault), this looks like a great lil' patch!

SConstruct Outdated Show resolved Hide resolved
@Ithamar
Copy link
Author

Ithamar commented Sep 30, 2023

So I updated this PR to current master again, is there anything else I can do to help get this merged?

@akien-mga
Copy link
Member

This looks fine overall as an option, but there's a problem with the implementation, as it's not self-contained. Modules are meant to be self-contained so the module-specific config can't modify SConstruct.

Thankfully there's a way to register new options from the module itself, I just tested it locally so I'll push an update to your PR directly with this change.

@Ithamar
Copy link
Author

Ithamar commented Sep 30, 2023

This looks fine overall as an option, but there's a problem with the implementation, as it's not self-contained. Modules are meant to be self-contained so the module-specific config can't modify SConstruct.

Ah, I was not aware of that.

Thankfully there's a way to register new options from the module itself, I just tested it locally so I'll push an update to your PR directly with this change.

Awesome, I'll take a look at your changes to see how it is done in case I need something similar in the future.

Thanks very much!

@akien-mga
Copy link
Member

Seems like I don't have permission to push changes to the PR branch, so I pushed changes in my fork: akien-mga@e75da97

This is making use of get_opts in config.py to add a module-specific option.

If you can push this commit to your fork's branch to update this PR, it should be good to go.

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Sep 30, 2023
@Ithamar Ithamar force-pushed the feat-mp1-mp2 branch 3 times, most recently from a92d84f to 8719f7f Compare September 30, 2023 19:27
SConstruct Outdated Show resolved Hide resolved
Enabling this adds 3.5k to the template size (Win/64bits).

Co-authored-by: Riteo <riteo@posteo.net>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
@@ -375,6 +375,8 @@ for name, path in modules_detected.items():
else:
enabled = False

opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, I moved this so that the module_<name>_enabled option would come before the options specific to that module in scons --help. It shouldn't impact any of the logic otherwise (unless some custom modules rely on this being undefined in get_opts, but I doubt it :)).

@akien-mga akien-mga merged commit ce236a6 into godotengine:master Oct 2, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@Ithamar
Copy link
Author

Ithamar commented Oct 2, 2023

Thanks! And congrats for your first merged Godot contribution 🎉

Thank you for helping getting it over the line!

Also, is there a contributors file that I need to send a PR on, as this actually my 3rd (merged) contribution (see #71394 and #65717) and every time I get congratulated for my first merged issue (not complaining, just wondering why 😛 )

@akien-mga
Copy link
Member

akien-mga commented Oct 2, 2023

This means that your commits are not linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info.

Despite this third merge, you're still shown like this:

image

@akien-mga akien-mga changed the title Enable MP1 and MP2 support in minimp3 and editor Add build option to enable MP1 and MP2 support in minimp3 Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MP2 support
6 participants