Skip to content

Set audiostreamplayer default area_mask to 0 and exit early to reduce performance overhead. #107679

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pirey0
Copy link
Contributor

@pirey0 pirey0 commented Jun 18, 2025

Addresses #106751

Quick summary:
By default AudioStreamPlayers2D/3D do a physics check on their position every frame when running to support the audio_bus_override feature on Area2D/3D.

From my search this is a feature that is rarely used, but results in a non negligible overhead for all projects, even if the feature is never used.

I propose setting the default area_mask to 0 and exiting early in those scenarios to remove this overhead.

Reasons:

  1. Most projects don't use this feature and should thus not be affected by the cost.
  2. A default of 0 (aka. no overlap) more closely aligns with the opt-in nature of the feature.
    I think the default of 1 (aka. check for overlaps with all default areas) is more likely to cause unexpected behaviour.
  3. Most projects using this feature will very likely be using a specific non-1 layer for this effect and will thus be unaffected by the change.

Warning:

This PR includes a Behavior Breaking Change:
Projects using the audio_bus_override feature on the default layer will find their overrides not working anymore.
(Though I expect this number to be very low, can do a targeted search if required)

Improved performance of default no-check case.
@pirey0 pirey0 requested review from a team as code owners June 18, 2025 19:45
@pirey0 pirey0 changed the title DIsabled audiostreamplayer bus_override being active by default. #106751 Set audiostreamplayer default area_mask to 0 and exit early to reduce performance overhead. (See #106751) Jun 18, 2025
@KoBeWi KoBeWi added this to the 4.x milestone Jun 18, 2025
@AThousandShips AThousandShips changed the title Set audiostreamplayer default area_mask to 0 and exit early to reduce performance overhead. (See #106751) Set audiostreamplayer default area_mask to 0 and exit early to reduce performance overhead. Jun 18, 2025
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.

2 participants