Skip to content

[Android] Add support for 16 KB page sizes, update to NDK r28b #106358

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

Merged
merged 1 commit into from
May 15, 2025

Conversation

m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented May 13, 2025

Bump the NDK to version 28.1.13356709; doing so automatically adds support for 16kib page to the Godot Android shared libraries. See https://developer.android.com/guide/practices/page-sizes#compile-16-kb-alignment for details.

Fixes #106313

This PR, alongside #106152 and #105611 should be cherry-picked to previous releases to provide similar support for 16kb page sizes.

Doing so automatically adds support for 16kib page to the Godot Android shared libraries.
See https://developer.android.com/guide/practices/page-sizes#compile-16-kb-alignment for details.
@m4gr3d m4gr3d requested a review from a team as a code owner May 13, 2025 15:34
@m4gr3d m4gr3d requested a review from a team as a code owner May 13, 2025 15:34
@m4gr3d m4gr3d added topic:buildsystem topic:export cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels May 13, 2025
@m4gr3d m4gr3d added this to the 4.5 milestone May 13, 2025
m4gr3d added a commit to m4gr3d/godot that referenced this pull request May 13, 2025
Follow-up to godotengine#106358, this is a separate commit / PR since it shouldn't be cherry-picked in previous releases as it removes existing functionality.

Support for 16kb page size added in the previous PR requires the native libraries to be uncompressed, so we're deprecating and removing the option to compress native libraries.
See https://developer.android.com/guide/practices/page-sizes#agp_version_851_or_higher for more details.
m4gr3d added a commit to m4gr3d/godot that referenced this pull request May 13, 2025
Follow-up to godotengine#106358, this is a separate commit / PR since it shouldn't be cherry-picked in previous releases as it removes existing functionality.

Support for 16kb page size added in the previous PR requires the native libraries to be uncompressed, so we're deprecating and removing the option to compress native libraries.
See https://developer.android.com/guide/practices/page-sizes#agp_version_851_or_higher for more details.
@Alex2782
Copy link
Member

Do we still have to test it?
https://developer.android.com/guide/practices/page-sizes#test

@m4gr3d
Copy link
Contributor Author

m4gr3d commented May 13, 2025

Do we still have to test it?
https://developer.android.com/guide/practices/page-sizes#test

I did a quick test building the Android editor and running it on an Android device, but yes more tests would be good!

@Alex2782
Copy link
Member

Alex2782 commented May 15, 2025

adb shell getconf PAGE_SIZE

Have you changed your device to 16 KB via developer options?


There are 4 Android 15 devices on Firebase Test Lab, all running in 4 KB mode.
Pixel 9 Pro XL, Pixel 9, Lenovo Tab P12, Pixel 8.

We can probably take our time with this (Q4 2025 ?), Android 16 will have a 16 KB page size compatibility mode
https://developer.android.com/about/versions/16/behavior-changes-all#16-kb-compatibility-mode

I have a Pixel 8a with Android 15, so I could switch to 16 KB. But that requires a reboot, and I'm currently unsure whether all the apps that are essential in everyday life will run smoothly. I'll continue with an emulator for now; there's a special image for 16KB.


C++ page_size check (UNIX only)
#include <unistd.h>

Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
	Thread::make_main_thread();
	set_current_thread_safe_for_nodes(true);

    int page_size;

#ifdef _SC_PAGESIZE
    page_size = sysconf(_SC_PAGESIZE);
#else
    page_size = getpagesize();
#endif
    print_line("Main::setup page_size: ", page_size);

Copy link
Member

@syntaxerror247 syntaxerror247 left a comment

Choose a reason for hiding this comment

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

Looks good!
Did some tests with Android Editor, everything seems to work correctly.

@akien-mga akien-mga changed the title [Android] Add support for 16 KB page sizes [Android] Add support for 16 KB page sizes, update to NDK r28b May 15, 2025
@m4gr3d
Copy link
Contributor Author

m4gr3d commented May 15, 2025

Have you changed your device to 16 KB via developer options?

@Alex2782 I also validated the update using the script provided by Google at https://developer.android.com/guide/practices/page-sizes#alignment-use-script.

@Repiteo Repiteo merged commit 82ea0b9 into godotengine:master May 15, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented May 15, 2025

Thanks!

@m4gr3d m4gr3d deleted the update_ndk_28 branch May 15, 2025 15:38
m4gr3d added a commit to m4gr3d/godot that referenced this pull request May 15, 2025
Follow-up to godotengine#106358, this is a separate commit / PR since it shouldn't be cherry-picked in previous releases as it removes existing functionality.

Support for 16kb page size added in the previous PR requires the native libraries to be uncompressed, so we're deprecating and removing the option to compress native libraries.
See https://developer.android.com/guide/practices/page-sizes#agp_version_851_or_higher for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release enhancement platform:android topic:buildsystem topic:export
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android: Native libraries not aligned to support devices with 16 KB memory page sizes
5 participants