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

Android memory cleanup and optimizations #94799

Conversation

m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Jul 26, 2024

Miscellaneous set of code / memory cleanup and optimizations for the Android platform:

  • Disable sensor events by default. Sensor events can fire at 10-100s Hz wasting cpu and memory resources if the sensor data is not being used. Now the use of sensor data is behind a project setting allowing projects that need it to enable it, while other projects don't have to pay the cost for a feature they don't use.

  • Returns an empty list when there's no registered plugins, thus preventing the creation of spurious iterator objects

  • Inline Godot#getRotatedValues(...) given it only had a single caller. This removes the allocation of a float array on each call

  • Create a pool of specialized Runnable objects to dispatch input events and prevent spurious, unbounded Runnable allocations

  • Disable showing the boot logo for Android XR projects

  • Delete locale references of jni strings

@m4gr3d m4gr3d added this to the 4.4 milestone Jul 26, 2024
@m4gr3d m4gr3d requested a review from a team July 26, 2024 13:41
@m4gr3d m4gr3d requested review from a team as code owners July 26, 2024 13:41
core/input/input.h Outdated Show resolved Hide resolved
@m4gr3d m4gr3d force-pushed the memory_allocation_cleanup_and_optimizations branch from 06c5227 to eddf1ff Compare July 26, 2024 13:50
@m4gr3d m4gr3d force-pushed the memory_allocation_cleanup_and_optimizations branch from eddf1ff to c2235d5 Compare July 26, 2024 23:54
@m4gr3d m4gr3d requested a review from BastiaanOlij August 5, 2024 15:00
@m4gr3d
Copy link
Contributor Author

m4gr3d commented Aug 5, 2024

Disable sensor events by default. Sensor events can fire at 10-100s Hz wasting cpu and memory resources if the sensor data is not being used. Now the use of sensor data is behind a project setting allowing projects that need it to enable it, while other projects don't have to pay the cost for a feature they don't use.

@BastiaanOlij FYI, sensor events will be disabled by default following this PR. This may constitute a breaking changes for mobile VR projects. I've added some warning logs for debug builds to help identify the issue for those projects.

@BastiaanOlij
Copy link
Contributor

Disable sensor events by default. Sensor events can fire at 10-100s Hz wasting cpu and memory resources if the sensor data is not being used. Now the use of sensor data is behind a project setting allowing projects that need it to enable it, while other projects don't have to pay the cost for a feature they don't use.

@BastiaanOlij FYI, sensor events will be disabled by default following this PR. This may constitute a breaking changes for mobile VR projects. I've added some warning logs for debug builds to help identify the issue for those projects.

Should indeed be easy to have a warning if the MobileVRInterface is used. While you're add it, a long outstanding wish has been to be able to influence the sensor accuracy which by default is set to be more laggy and less noisy. This is great when used for your normal phone applications but not in a VR settings.
I had an old PR that was closed due to it growing stale: #22644, might be worth revisiting.

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Aug 6, 2024

Should indeed be easy to have a warning if the MobileVRInterface is used.

I've added the warning when the getter for the sensor data is used while sensors are disabled, so that should cover both MobileVRInterface projects and projects using sensor data for other functionality.

While you're add it, a long outstanding wish has been to be able to influence the sensor accuracy which by default is set to be more laggy and less noisy. This is great when used for your normal phone applications but not in a VR settings.
I had an old PR that was closed due to it growing stale: #22644, might be worth revisiting.

Should be straightforward to add; I'll keep it in a separate commit.

core/input/input.cpp Outdated Show resolved Hide resolved
- Returns an empty list when there's not registered plugins, thus preventing the creation of spurious iterator objects

- Inline `Godot#getRotatedValues(...)` given it only had a single caller. This allows to remove the allocation of a float array on each call and replace it with float variables

- Disable sensor events by default. Sensor events can fired at 10-100s Hz taking cpu and memory resources. Now the use of sensor data is behind a project setting allowing projects that have use of it to enable it, while other projects don't pay the cost for a feature they don't use

- Create a pool of specialized input `Runnable` objects to prevent spurious, unbounded `Runnable` allocations

- Disable showing the boot logo for Android XR projects

- Delete locale references of jni strings
@m4gr3d m4gr3d force-pushed the memory_allocation_cleanup_and_optimizations branch from c2235d5 to a57a99f Compare August 16, 2024 16:28
@akien-mga akien-mga merged commit 82adfeb into godotengine:master Aug 16, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

5 participants