objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

recompile objectbox with the new ndk and enable 16k page support

Open andrew-ld opened this issue 1 year ago • 13 comments

android 15 have a breaking changes for all applications, it require the support for 16k page

https://developer.android.com/about/versions/15/behavior-changes-all#16-kb

andrew-ld avatar May 16 '24 15:05 andrew-ld

Thanks for bringing this to our attention. Did you try to run ObjectBox on Android 15 yet?

greenrobot avatar May 16 '24 16:05 greenrobot

yes, I tried with some pixels I have as test devices, it works but only because the kernel is not compiled with 16k memory pages, when a version with 16k pages should not work anymore.

andrew-ld avatar May 16 '24 16:05 andrew-ld

Some more details for us:

https://developer.android.com/guide/practices/page-sizes

As device manufacturers continue to build devices with larger amounts of physical memory (RAM), many of these devices will adopt 16 KB

We plan to make 16 KB page compatibility required for app uploads to the Google Play store next year.

Also this sounds like it will only impact new devices?

(Edit: there is an internal issue for this objectbox/objectbox-java#214.)

greenrobot-team avatar May 21 '24 08:05 greenrobot-team

i opened this issue to be able to get compatibility with this new google requirement as soon as possible, so even apps that i will possibly not maintain in the future will remain compatible with this new requirement

andrew-ld avatar May 21 '24 08:05 andrew-ld

Btw, it's an interesting move. Apple also went with 16K pages for iOS. (ObjectBox supports this for quite a while.)

greenrobot avatar May 21 '24 08:05 greenrobot

When I run my application on a 16 KB page sized emulator, the app crashes when initializing ObjectBox.

sebastianharder avatar Aug 13 '24 13:08 sebastianharder

For us it is the same. On a 4 KB page sized emulator everything works as expected, but our app crashes when being started on an 16 KB page sized emulator, throwing the following exception.

java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~8XEAp4Lnndxc_SHi4DabgA==/de.rewe.app.mobile.debug-nRrVTufzv3fziU8dG5DVLA==/base.apk!/lib/arm64-v8a/libobjectbox-jni.so" (new hash type from the future?)

This seems to be a serious problem as every app (independent of targetSdk) using ObjectBox might break on a device using a page size of 16 KB.

Faltenreich avatar Aug 13 '24 13:08 Faltenreich

Is there any device with 16KB pages now available? Btw, Pixel 9 Pro is to be released later today...

greenrobot avatar Aug 13 '24 13:08 greenrobot

I did not find any information about the Pixel 9 (Pro) or any other device being shipped with a 16 KB page size.

Surprisingly it seems that the Pixel 6 (Pro) can be flashed with a 16 KB page size according to source.android.com.

Faltenreich avatar Aug 14 '24 07:08 Faltenreich

this issue is more about the future than the present, it is important that apps support this requirement as soon as possible to allow them to be used in the future as well without anyone maintaining them anymore

andrew-ld avatar Aug 16 '24 16:08 andrew-ld

it would also be appreciated if the objectbox source code would be totally published to accelerate these and future developments

andrew-ld avatar Aug 16 '24 16:08 andrew-ld

@greenrobot Can we provide any additional support?

Faltenreich avatar Sep 23 '24 10:09 Faltenreich

@Faltenreich Not at this point, had no time to look into this, yet. We'll update once we have a release available for testing.

greenrobot-team avatar Sep 30 '24 07:09 greenrobot-team

We received the first complaints for our app because of this error. Will this be solved soon?

henrikstormer avatar Nov 15 '24 07:11 henrikstormer

Do you know if that occurs on standard Pixel devices that got the Android 15 update? My Pixel 9 refuses to download the update without errors... :shrug:

greenrobot avatar Nov 15 '24 15:11 greenrobot

@greenrobot flash from https://flash.android.com

andrew-ld avatar Nov 16 '24 16:11 andrew-ld

@henrikstormer Check if your users are on any Pixel 8 or newer, are running the Android 15 beta or newer and have enabled the "Boot with 16KB page size" developer option.

Edit: obviously, this also affects emulators that use the "Pre-Release 16 KB Page Size images".

Otherwise, to my knowledge there should currently be no devices out there that ship a firmware running Android 15 with 16KB page size enabled for customers. Edit: just to emphasize, this is a large breaking change and it will take a while until this will become the default. So far Google has not announced when and if this will be the default on new devices:

There are no production Android devices available today or expected for the Android 15 release that support a 16 KB page size. https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html

greenrobot-team avatar Nov 18 '24 06:11 greenrobot-team

Just a quick update: internally, we made the first steps, e.g. we updated the NDK and added the NDK related options. However, it does not work on the x64 emulator with 16k pages, but that could be an emulator issue (it is not doing 16k pages properly... :disappointed: ). It will take some more time...

greenrobot avatar Nov 18 '24 09:11 greenrobot

Based on this documentation, I tested the libobjectbox-jni.so file using command-line tools, the result was:

WindowsPowerShell:

PS C:\Users\Parsian\AppData\Local\Android\Sdk\ndk\28.0.12433566\toolchains\llvm\prebuilt\windows-x86_64\bin> .\llvm-objdump.exe -p lib\libobjectbox-jni.so | Select-String -Pattern "LOAD"

    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**12
    LOAD off    0x0000000000216a50 vaddr 0x0000000000217a50 paddr 0x0000000000217a50 align 2**12
    LOAD off    0x00000000002238e8 vaddr 0x00000000002258e8 paddr 0x00000000002258e8 align 2**12

Check the output lines to ensure that the load segments don't have values less than 2**14. If any load segments are 2**13, 2**12, or lower values, you'll need to update the packaging for those libraries, then recompile your app and retest by following the steps in this section.

hysapp avatar Nov 18 '24 16:11 hysapp

@hysapp Thanks. This is expected as we did not release any fixes.

greenrobot avatar Nov 19 '24 09:11 greenrobot

https://developer.android.com/about/versions/16/behavior-changes-all#16-kb-compatibility-mode

@greenrobot changes for android 16

andrew-ld avatar Mar 04 '25 10:03 andrew-ld

this Issue seems to be fixed with release 4.1.0+ tested on emulators with 16 KB pagesize

kknappe avatar Apr 30 '25 12:04 kknappe

@kknappe Thanks for the update! ~~While 4.1.0 and onward do not support 16KB page sizes, the Android Maven artifacts are built with a newer Android Gradle Plugin (release 8.7) and NDK 27. Which maybe makes the Android plugin do something to prevent a crash?~~ Update: actually 4.1.0 and onward should have support for 16 KB page sizes, but we could not properly verify this, yet (due to issues with the emulator at the time).

Anyhow, as andrew-ld noted above, Android 16 introduced a compatibility mode that may be helpful for testing on devices that use 16KB pages (which again, there are still none that have it enabled by default).

greenrobot-team avatar May 05 '25 07:05 greenrobot-team

@greenrobot-team Any update on this. It seems that Google Playstore requires new app to be 16KB compatible this coming November.

https://android-developers.googleblog.com/2025/05/prepare-play-apps-for-devices-with-16kb-page-size.html?m=1

poldz123 avatar May 08 '25 18:05 poldz123

@poldz123 Did you update to the latest version as @kknappe suggested? For us it fixed the crash on startup.

Faltenreich avatar May 09 '25 06:05 Faltenreich

@Faltenreich, did you check the app bundle explorer in Google Play to see whether it still reports objectbox as not supporting 16 KB?

sebastianharder avatar May 09 '25 06:05 sebastianharder

@sebastianharder We have not yet uploaded a version with ObjectBox 4.1.0+, but we will report back when this changes.

Faltenreich avatar May 09 '25 08:05 Faltenreich

@sebastianharder @Faltenreich Looks like latest version does in fact support 16KB

Image

poldz123 avatar May 10 '25 23:05 poldz123

I have to update my previous statement: actually version 4.1.0 and onward should have support for 16 KB page sizes, but we could not properly verify and test this, yet (due to issues with the emulator at the time).

For our reference, this is internal issue objectbox#1094

greenrobot-team avatar May 12 '25 07:05 greenrobot-team

当我使用4.0.1版本的时候,Android studio 提示:arm64-v8a/libobjectbox-jni.so is not 16 KB aligned ,详见下图 Translation: When I use version 4.0.1, Android studio prompts: arm64-v8a/libobjectbox-jni.so is not 16 KB aligned , see the following picture for details

Image

但当我升级到最新版4.3.0 时,该提示就消失了,详见下图 Translation: But when I upgraded to the latest version 4.3.0, the message disappeared, as shown in the following picture

Image

請問现在是已经做适配了吗? Translation: May I ask if the adaptation has been done now?

yykou avatar May 30 '25 09:05 yykou