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

[Web] Gracefully handle non-finite audio volumes #94869

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Jul 28, 2024

These values aren't valid but they should be handled gracefully, could handle with a isFinite() instead (though that would involve checking after converting, so bit more complex code), with or without a message, but I think this is the most straight forward way to handle it

This shouldn't happen with properly handled input, but in case of user error entering invalid values we should handle this gracefully instead of failing to load

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

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

I think we can handle this case more gracefully than a try/catch. I'll try something in the following hour.

@AThousandShips
Copy link
Member Author

I'll switch to a isFinite instead as an alternative, will push momentarily

@AThousandShips
Copy link
Member Author

AThousandShips commented Jul 29, 2024

Now just ignores the value if non-finite after converting

Moving this to AudioServer could accidentally miss some cases though it would make it uniform and ignore any changes to such cases, by not even changing the audio bus volume, that would make it not change volume at all, currently (and before the introduction of samples) this would mute everything by the bus volume being invalid

But think a targeted fix would be appropriate here and looking at a broader fix with the possible implications later

@AThousandShips
Copy link
Member Author

AThousandShips commented Jul 29, 2024

To confirm this just try running:

AudioServer.set_bus_volume_db(0, +INF)

and (separately):

AudioServer.set_bus_volume_db(0, NAN)

This will error out and fail to run, with a popup of the error Uncaught TypeError: AudioParam.value setter: Value being assigned is not a finite floating-point value.

With this fix, and specifically with isFinite it will work safely

@AThousandShips
Copy link
Member Author

AThousandShips commented Jul 29, 2024

Here's an MRP to test with, check the script for instructions:

My bad uploaded wrong project:

webmrp.zip

@adamscott
Copy link
Member

Here's an MRP to test with, check the script for instructions: WebMRP.zip

@AThousandShips Are you sure you joined the right MRP? There's no script at all.

@AThousandShips
Copy link
Member Author

It's built-in

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

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

Great work @AThousandShips. I didn't know that it was the WebAudio gain node that was complaining about Infinity.

So, everything's good, I'll add a warning later, that I must implement in the JS stack.

@akien-mga akien-mga merged commit 8fd9958 into godotengine:master Jul 30, 2024
18 checks passed
@AThousandShips AThousandShips deleted the web_volume_fix branch July 30, 2024 10:37
@akien-mga
Copy link
Member

Thanks!

@AThousandShips
Copy link
Member Author

Thank you!

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.

Uncaught TypeError: AudioParam.value setter error in Web build.
3 participants