はじめに
Android 14まで4KBベージサイズをサポートしていましたが、Android 15にて16KBページサイズがオプショナルで使用できるようになりました。
developer.android.com
ページサイズが増えたことでメモリ使用量が若干増加しますが、様々な箇所でパフォーマンスの向上を見込むことができます。
16 KB ページサイズのサポート | Android Developers
素晴らしいことに感じますが、16KBページサイズに対応しているアプリに再ビルドが必要になる可能性があります。
アプリがネイティブ コードを使用している場合は、16 KB デバイスをサポートするようにアプリを再ビルドする必要があります。
// ...
次のいずれかに該当する場合は、アプリでネイティブ コードを使用しています。
- アプリで C/C++(ネイティブ)コードを使用している。アプリで Android NDK を使用している場合は、アプリでネイティブ コードを使用しています。
- アプリが、それらを使用するサードパーティのネイティブ ライブラリまたは依存関係(SDK など)とリンクしている。
- デバイス上のネイティブ ライブラリを使用するサードパーティ製アプリビルダーでビルドされたアプリ。
つまりUnityを使用していると、必ず対応する必要があります。今のところは16KBページサイズの対応が必須でないので大して問題にはなっていませんが、ゆくゆくは対応の必要がでてくると思うので一度確認してみてください。
対応しなければならないこと
以下の対応が必要です。
- 16KBページサイズに対応したUnityへバージョンアップする
- ネイティブプラグインをバージョンアップする
- 再ビルドしてストアに提出する
Apps that depend on native code, like Unity apps, will need to be rebuilt to include 16 KB support. At minimum you will need to:
- Update to an Engine-compatible patch and above.
- Update any native plugins that need updating.
- Rebuild and resubmit your application to the Store.
16 KB support is in addition to 4 KB. The same executable will be able to support both memory page sizes.
また16KBページサイズに対応しているアプリは4KBページサイズにも実質的に対応できています。4KBページサイズ用にコンパイルされたUnityが16KBページサイズのデバイスでは動作しないことを確認しているとのことです。
16KBページサイズに対応しているUnityのバージョン
16KBページサイズに対応しているUnityのバージョンは以下の通りです。一部まだリリースされていないので注意してください。
https://discussions.unity.com/t/info-unity-engine-support-for-16-kb-memory-page-sizes-android-15/1589588
- Unity 6000.1.0b5 expected to be released February 9, 2025
- Unity 6000.0.38f1 expected to be released February 14, 2025
- Unity 2022.3.56f1 released January 15, 2025
- Unity 2021.3.48f1 released January 22, 2025 accessible under extended LTS support for Enterprise/Industry customers
Unityを使用している場合は、このバージョン以上にあげて再ビルドしてあげる必要があります。
ネイティブプラグインのアップデート
ネイティブプラグインを16KBに対応してもらう必要があります。開発者に連絡をする等で対応するしかないでしょう。
追記(2024/2/24)
Android 16 beta 2 にて後方互換モードというものが登場しました。
16 KB page size compatibility mode
Android 15 introduced support for 16KB memory pages to optimize performance of the platform. Android 16 adds a compatibility mode, allowing some apps built for 4K memory pages to run on a device configured for 16KB memory pages.If Android detects that your app has 4KB aligned memory pages, it will automatically use compatibility mode and display a notification dialog to the user. Setting the android:pageSizeCompat property in the AndroidManifest.xml to enable the backwards compatibility mode will prevent the display of the dialog when your app launches. For best performance, reliability, and stability, your app should still be 16KB aligned. Read our recent blog post about updating your apps to support 16KB memory pages for more details.
// DeepL翻訳
Android 15では、プラットフォームのパフォーマンスを最適化するため、16KBメモリページのサポートが導入された。 Android 16では互換モードが追加され、4Kメモリ・ページ用にビルドされた一部のアプリを、16KBメモリ・ページ用に設定されたデバイス上で実行できるようになりました。
Androidがアプリのメモリ・ページが4KBアラインであることを検出すると、互換モードが自動的に使用され、ユーザーに通知ダイアログが表示されます。 AndroidManifest.xmlのandroid:pageSizeCompatプロパティを設定して後方互換モードを有効にすると、アプリの起動時にダイアログが表示されなくなります。 最高のパフォーマンス、信頼性、安定性を得るためには、アプリは16KBに揃える必要があります。 詳しくは、16KBメモリ・ページをサポートするためのアプリのアップデートに関する最近のブログ記事をお読みください。
Android Developers Blog: The Second Beta of Android 16
16 KB の後方互換オプションを有効にする | Android Open Source Project
Unityの中の人もその機能を試している旨がDiscussionsに記載されていました。
Hello,
Last week with Android 16 Beta 2 drop Google announced a compatibility mode. We (Unity Android Platform) are currently trying this out and we will update this post accordingly when we know more.
If you have a game in an unsupported Unity version might be worth trying this option out as well.
// DeepL翻訳
こんにちは、先週のAndroid 16 Beta 2のリリースで、Googleは互換モードを発表しました。私たち(Unity Android Platform)は現在これを試しており、詳細が分かり次第この記事を更新します。
もし未対応のUnityバージョンのゲームをお持ちでしたら、このオプションも試してみる価値があるかもしれません。
16KBに対応できたほうがパフォーマンス等の観点から推奨されるのは間違いなさそうですが、もしかしたら4KBのままでも動作する可能性があるみたいです。動向をチェックしておこうと思います。
また教えてくださったmao-san、ありがとうございますmm
良き纏め!👍
— mao🐑 (@TEST_H_) 2025年2月23日
ちなみに一点補足しておくと、Android 16 beta 2 辺りから「互換モード」と言ったのも出てきているので、ここらの動向も見ておくと良きかもです!
(Discussions でもその旨が言及されている)https://t.co/VqciuwkRyR