Skip to content

Link nativewindow instead of android on Android - #9

Merged
utkarshdalal merged 1 commit into
releasefrom
layer-drop-libandroid
Oct 23, 2026
Merged

utkarshdalal merged 1 commit into
releasefrom
layer-drop-libandroid

Conversation

@utkarshdalal

Copy link
Copy Markdown

The layer links libandroid.so but uses nothing from it on release (its only Android import is __android_log_print, from liblog). Inside a Wine guest, libandroid's ~200 system dependencies look up their own libraries through LD_LIBRARY_PATH, so they bind to imagefs libraries with the same name. On Samsung (libsqlite needs BoringSSL's libcrypto) and Xiaomi HyperOS (libjpeg-hyper needs the system libjpeg) that fails to link, the Vulkan loader cannot load the layer, and LSFG silently does nothing.

This links nativewindow instead. It has no effect on release, which needs neither, but android-gen8-fixes calls AHardwareBuffer_allocate / AHardwareBuffer_release, and those live in libnativewindow.so. Its 31-library tree shares no names with imagefs.

Tested on a POCO F6 with libandroid forced to fail the way it does on Samsung (stub libsqlite.so first on LD_LIBRARY_PATH), Blazing Chrome with LSFG armed:

  • current layer: dlopen fails (cannot locate symbol "sqlite3_extended_errcode" referenced by libandroid_runtime.so) and the layer never runs
  • this change: the layer is mapped into the game process

Built with scripts/build/android.sh's flags (NDK r27d) plus -ffile-prefix-map for the source path. Dynamic exports are identical to the layer currently shipped in GameNative.

libandroid.so pulls in ~200 system libraries, and inside a Wine guest they
resolve their own dependencies through LD_LIBRARY_PATH, so they bind to
imagefs libraries of the same name. On Samsung and Xiaomi HyperOS that fails
to link, and the Vulkan loader then cannot load the layer at all.

The layer only needs AHardwareBuffer from the Android libraries, which
libnativewindow.so exports, and its dependencies share no names with imagefs.
utkarshdalal pushed a commit to utkarshdalal/GameNative that referenced this pull request Oct 23, 2026
Built from GameNative/lsfg-vk-android#9 (release + link nativewindow instead
of android) instead of patching the old binary.
@utkarshdalal
utkarshdalal merged commit d33cace into release Oct 23, 2026
8 checks passed
utkarshdalal added a commit to utkarshdalal/GameNative that referenced this pull request Oct 23, 2026
* Stop the DNS shim and LSFG layer from loading libandroid.so

libandroid.so pulls in ~200 system libraries that look up their own
dependencies through the guest's LD_LIBRARY_PATH, so they bind to imagefs
libraries of the same name and fail to link on Samsung (libsqlite needs
BoringSSL's libcrypto) and Xiaomi HyperOS (libjpeg-hyper needs the system
libjpeg).

DNS shim: res_query() returned ENOSYS for every query when that dlopen
failed, and Wine's Android dnsapi, which dlsyms android_res_nquery from its
own failed libandroid handle, called a NULL pointer. Call resNetworkQuery and
resNetworkResult from libnetd_client.so (what libandroid's wrappers do) and
export android_res_nquery/android_res_nresult with libandroid's behaviour so
dnsapi finds them through RTLD_DEFAULT. android_getaddrinfofornetwork(0, ...)
is the same call as getaddrinfo(), so use that.

LSFG layer: drop its unused DT_NEEDED on libandroid.so (it only imports
__android_log_print from liblog) and bump the runtime version so containers
reinstall it.

* Rebuild the LSFG layer from source against libnativewindow

Built from GameNative/lsfg-vk-android#9 (release + link nativewindow instead
of android) instead of patching the old binary.

---------

Co-authored-by: Utkarsh Dalal <utkarsh.dalal@toptal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant