vtm icon indicating copy to clipboard operation
vtm copied to clipboard

VTM does not run on Android 15 with 16 KB page size

Open devemux86 opened this issue 1 year ago • 7 comments

VTM does not run on 16 KB page size based Android 15.

It probably needs to rebuild the native libraries for Android.

  • https://developer.android.com/guide/practices/page-sizes
  • https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html

devemux86 avatar May 18 '24 20:05 devemux86

Are you sure it doesn't work? For me it sounds like it's just an option to use 16 KB pages instead of 4 KB, but not a hard requirement.

SammysHP avatar May 19 '24 12:05 SammysHP

@SammysHP

Set up the Android Emulator with a 16-KB-based, Android 15 system image and VTM does not work: https://developer.android.com/guide/practices/page-sizes#16kb-emulator

(it works with regular Android 15 system image)

devemux86 avatar May 19 '24 12:05 devemux86

Even if it was compatible, I just found this notice:

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

(https://developer.android.com/about/versions/15/behavior-changes-all)

SammysHP avatar May 19 '24 14:05 SammysHP

I updated the process of building native libraries with #1126.

However, even if we build 16 KB-aligned native libraries with Android instructions, it builds the same native libraries which do not run on Android 15 with 16 KB page size.


If someone knows better, you can try to build the native libraries:

  • Set environment variable NDK_HOME
  • Update ndk-build with Android instructions for 16 KB page size
  • Run JniBuilder

devemux86 avatar May 20 '24 11:05 devemux86

Hi, Can you tried to build JNI with gdx-jnigen 2.5.2 ? https://github.com/libgdx/gdx-jnigen/pull/73

ocsike avatar Sep 20 '24 13:09 ocsike

I do not currently have a working environment for creating native libraries.

You could try building them and if they work correctly, I could merge them. The instructions can be found above.

devemux86 avatar Sep 20 '24 16:09 devemux86

I think it works with 16 KB....

  1. I modified Android.mk and Application.mk then built libs with ndk-build. I modified JniBuilder.java too , but no need this case. In Android.mk add APP_PLATFORM := android-35 add APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true and modify LOCAL_LDLIBS := -lm -llog -Wl,-z,max-page-size=0x4000 I added this, but I think above line is enough LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 In Application.mk modify APP_PLATFORM := android-35

  2. Copy these libs into vtm-android\natives directory

  3. Modify build.gradle The androidCompileSdk() and androidTargetSdk() must be 35

  4. Build example app...

  5. I use x86_64 emulator image with 16kb pagesize. In the emulator's config.ini must add this line as google suggested: kernel.parameters = androidboot.page_shift=14

  6. Start emulator ,install example app and start it vtm2

ocsike avatar Sep 26 '24 09:09 ocsike

@ocsike could you provide those 16k libs?

ztNFny avatar Nov 01 '24 17:11 ztNFny

@ocsike could you provide those 16k libs?

@ztNFny vtmlibs.zip

This zip contains only .so files. I not tried physical device just only x86 emulator.

ocsike avatar Nov 02 '24 13:11 ocsike

@ocsike Thanks, I made a quick test on Android 15 emulator 16KB and they seem to work.

But are they only made for Android 15? They do not work on older versions like Android 5. Current .so files work on all Android versions.

Probably need to build them to support all Android versions.

devemux86 avatar Nov 03 '24 16:11 devemux86

Probably need to use the existing Application.mk with all ABI and platform an old Android.

devemux86 avatar Nov 04 '24 09:11 devemux86

I built these with the existing Application.mk. I tested on emulators going from Lollipop to Baklava with 16kb page size. Seems to work fine on all of them with the android example app.

Android MK:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
 
LOCAL_MODULE    := vtm-jni
LOCAL_C_INCLUDES := . libtess2/Include 
 
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -O2 -ffast-math -DNDEBUG
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -O2 -ffast-math -DNDEBUG
LOCAL_LDLIBS := -lm -llog -Wl,-z,max-page-size=0x4000
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
LOCAL_ARM_MODE  := arm
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
 
LOCAL_SRC_FILES := libtess2/Source/dict.c\
	libtess2/Source/tess.c\
	libtess2/Source/geom.c\
	libtess2/Source/bucketalloc.c\
	libtess2/Source/mesh.c\
	libtess2/Source/sweep.c\
	libtess2/Source/priorityq.c\
	gl/utils.c\
	org_oscim_utils_TessJNI.cpp
 
include $(BUILD_SHARED_LIBRARY)

vtmLibs.zip

git-bone avatar Jan 19 '25 19:01 git-bone

@git-bone Thanks! These libs seem to work. 👍

devemux86 avatar Jan 20 '25 08:01 devemux86

I tested on some old phones with android 9 and 14. Android 5 and 15 (16kb) on emulators. Everything worked fine.

git-bone avatar Jan 20 '25 12:01 git-bone

Current native libraries display triangle tessellation artifacts when zoom e.g. north of Boston, UK.

I updated the Libtess library and I created new Android native libraries that should fix tesselation:

  • https://github.com/mapsforge/vtm/pull/1178
  • https://github.com/mapsforge/vtm/pull/1179

devemux86 avatar Feb 28 '25 13:02 devemux86

hm. I'm using it now for a couple of weeks, haven't found any issues yet. Is this fix already available when i'm pulling master-snapshot from jitpack?

git-bone avatar Feb 28 '25 14:02 git-bone

@git-bone

@MotoUKRider reported this and I could reproduce it also on Android emulator with the mentioned map.

When the pull requests will be merged soon, the snapshot version on Maven and JitPack will include it too.


Technical info: the problem appears because we use themesh="true" tesselation option in land and sea.

We better avoid this option, but Mapsforge / OpenAndroMaps / Freizeitkarte maps use split land polygons that have empty grid space between the land tiles, more as we zoom in. (see image) Mapsforge map engine can easily fill it with stroke, but VTM currently cannot do this.

If we find a way to fix this for VTM, then we can remove the mesh="true" tesselation rule.

Image

devemux86 avatar Feb 28 '25 14:02 devemux86

@git-bone The triangle artifacts as they appear with the current native libraries north of Boston, UK:

devemux86 avatar Feb 28 '25 14:02 devemux86

yes, i can reproduce it now. It only seems to happen on certain zoom levels. Never noticed this before.

git-bone avatar Feb 28 '25 16:02 git-bone

@git-bone I merged https://github.com/mapsforge/vtm/pull/1179 with the new Android native libraries.

devemux86 avatar Mar 01 '25 11:03 devemux86

I published version 0.24.0 of VTM with the new Android native libraries on Maven and JitPack repositories.

devemux86 avatar Mar 03 '25 10:03 devemux86