ryanrudolfoba / SteamOS-Waydroid-Installer

Script to easily install / uninstall Android via Waydroid on the Steam Deck running on SteamOS.
https://www.youtube.com/watch?v=06T-h-jPVx8
424 stars 22 forks source link

Include scripts to patch libhoudini/libndk for games compatibility #102

Closed h4xtvby2 closed 1 month ago

h4xtvby2 commented 3 months ago

Hello, qwerty12356-wart has made patches for libhoudini and libndk which fixes a few games that crashes like Blue Archive global (I've only tested Blue Archive global myself) and Wuthering Waves (according to another commenter - https://github.com/waydroid/waydroid/issues/788#issuecomment-2164856085). It might be helpful to include it in future versions of the installer.

What the patch actually does - https://github.com/waydroid/waydroid/issues/788#issuecomment-2162748229

libhoudini patch - https://github.com/waydroid/waydroid/issues/788#issuecomment-2162386712 libndk patch - https://github.com/waydroid/waydroid/issues/788#issuecomment-2167334937

qwerty12356-wart commented 3 months ago

I'm gonna elaborate more on what the patch actually does, because the original explanation is pretty vague. libhoudini and libndk by default block app from gaining WRITE permission when an app try to do mprotect or mmap on a region of memory to get write permission, leading to a Segfault when the app try to do its thing.

There are 3 patches in total for libhoudini and 2 patches for libndk For libhoudini, there are: mprotect patch, mprotect2 patch and map_library (or mmap) patch For libndk, there are only mprotect patch and map_library patch

The mprotect and map_library patch simply undo the default behavior of both library The mprotect2 patch is exclusive to libhoudini and only there for performance reason (It skips a function but i can't understand what the function does and if this patch is not applied, the game suffer performance wise)

ryanrudolfoba commented 3 months ago

The libndk patch, will this work for Roblox too? Currently using libndk-fixer for Roblox to work, but that breaks other app too like mantis.

Cant test for the next few weeks. Will give feedback soon.

qwerty12356-wart commented 3 months ago

The libndk patch, will this work for Roblox too? Currently using libndk-fixer for Roblox to work, but that breaks other app too like mantis.

Cant test for the next few weeks. Will give feedback soon.

No. Roblox crashed due to an entirely different issue, also affecting houdini.

I can try to reverse engineer what mumu do and implement it into a special patch library but i just don't have the motivation for roblox right now.

ryanrudolfoba commented 3 months ago

Maybe once you have the motivation please take a look at this -

https://github.com/Slappy826/libndk-fixer

qwerty12356-wart commented 2 months ago

Maybe once you have the motivation please take a look at this -

https://github.com/Slappy826/libndk-fixer

Thanks, i have already looked into it. But because libhoudini is vastly different from libndk_translation, the library prove to be less useful than i thought. I have implemented the patch (that mumu use) into my own patch library which you can found in my repo. Please note that i have not tested them yet and the patch is very much still experimental.

ryanrudolfoba commented 2 months ago

Yes I saw your repo gonna try it out soon. Thank you!

qwerty12356-wart commented 2 months ago

Yes I saw your repo gonna try it out soon. Thank you!

No, don't try it, i tried implementing almost every patch i possibly can from mumu into the patch library. Roblox still crash

qwerty12356-wart commented 2 months ago

Yes I saw your repo gonna try it out soon. Thank you!

Never mind you can test it now, I somehow made it working (though haven't joined a game yet)

Screenshot from 2024-07-06 11-55-22

ryanrudolfoba commented 2 months ago

@qwerty12356-wart - I've built your nb patches from ypur repo and it works!

Just a question though as I'm building for Steam Deck which uses AMD APU I used this build flags -

cmake . -B build -DCOMPILE_ARCH=x86_64 -DPATCHTOUSE=1 -DUSE_NATIVEBRIDGE=libndk_translation.so

PATCHTOUSE index 1 refers to NDK_TRANS13_R125_15853_INDEX‎

Is that for Android 13? We use Android 11 Waydroid image is that OK? It works just want to make sure I'm not doing anything wrong

qwerty12356-wart commented 2 months ago

@qwerty12356-wart - I've built your nb patches from ypur repo and it works!

Just a question though as I'm building for Steam Deck which uses AMD APU I used this build flags -

cmake . -B build -DCOMPILE_ARCH=x86_64 -DPATCHTOUSE=1 -DUSE_NATIVEBRIDGE=libndk_translation.so

PATCHTOUSE index 1 refers to NDK_TRANS13_R125_15853_INDEX‎

Is that for Android 13? We use Android 11 Waydroid image is that OK? It works just want to make sure I'm not doing anything wrong

No. Because I have not implemented the ndk patches for Roblox yet. And this patch is for Android 11 only. I'm too burnt out to port it to other versions.

qwerty12356-wart commented 2 months ago

I'm rewriting both of these library because the code base is a mess

qwerty12356-wart commented 1 month ago

I have finally rewritten the code. Should be stable. here

With this library, you dont need to use the patch script and only need to edit build.prop to point to the custom libnb.so. Also make Roblox not crash on waydroid.

ryanrudolfoba commented 1 month ago

Thanks I'll take a peek. Btw roblox made an x86 version of their apk so it works right away now it doesn't crash even when using the original libndk.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: qwerty12356-wart @.> Sent: Sunday, August 18, 2024 7:21:12 AM To: ryanrudolfoba/SteamOS-Waydroid-Installer @.> Cc: ryanrudolfoba @.>; Comment @.> Subject: Re: [ryanrudolfoba/SteamOS-Waydroid-Installer] Include scripts to patch libhoudini/libndk for games compatibility (Issue #102)

I have finally rewritten the code. Should be stable. herehttps://github.com/qwerty12356-wart/test_libnb

With this library, you dont need to use the patch script and only need to edit build.prop to point to the custom libnb.so. Also make Roblox not crash on waydroid.

— Reply to this email directly, view it on GitHubhttps://github.com/ryanrudolfoba/SteamOS-Waydroid-Installer/issues/102#issuecomment-2295225282, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXMTWIPN5BQKIKCDMJNYJ33ZSB7SRAVCNFSM6AAAAABJMHMQIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJVGIZDKMRYGI. You are receiving this because you commented.Message ID: @.***>

ryanrudolfoba commented 1 month ago

Spoke too soon - the readme says houdini. Unfortunately I can't test this as i use Steam Deck for my testing it uses libndk (AMD APU)

qwerty12356-wart commented 1 month ago

Spoke too soon - the readme says houdini. Unfortunately I can't test this as i use Steam Deck for my testing it uses libndk (AMD APU)

Try compiling the library with experimental patches. I need to test that patch on an AMD cpu

ryanrudolfoba commented 1 month ago

I was able to build it with experimental patch ON. Output is one libnb.so in build/src directory. I've copied this over to system/lib64 directory and made the appropriate changes to build.prop.

When i try to launch a game (Stand Off 2) it errors out + failed to load libmain.so

This game works fine using the regular libndk, and from your earlier test_nb_c repo.

I assume the new version still needs nbpatcher.so? I have it there and it didnt work either on the new version.

I've compiled nbpatcher.so with the libndk flag so maybe that's where it chokes?

qwerty12356-wart commented 1 month ago

I was able to build it with experimental patch ON. Output is one libnb.so in build/src directory. I've copied this over to system/lib64 directory and made the appropriate changes to build.prop.

When i try to launch a game (Stand Off 2) it errors out + failed to load libmain.so

This game works fine using the regular libndk, and from your earlier test_nb_c repo.

I assume the new version still needs nbpatcher.so? I have it there and it didnt work either on the new version.

I've compiled nbpatcher.so with the libndk flag so maybe that's where it chokes?

Sorry for not making it cleat on my original messages, but those experimental patches are for libhoudini only. There is a patch that i have not tested yet that (supposedly) improve performance on amd

ryanrudolfoba commented 1 month ago

I was able to build it with experimental patch ON. Output is one libnb.so in build/src directory. I've copied this over to system/lib64 directory and made the appropriate changes to build.prop. When i try to launch a game (Stand Off 2) it errors out + failed to load libmain.so This game works fine using the regular libndk, and from your earlier test_nb_c repo. I assume the new version still needs nbpatcher.so? I have it there and it didnt work either on the new version. I've compiled nbpatcher.so with the libndk flag so maybe that's where it chokes?

Sorry for not making it cleat on my original messages, but those experimental patches are for libhoudini only. There is a patch that i have not tested yet that (supposedly) improve performance on amd

i'll test it and provide feedback on your repo.

ryanrudolfoba commented 1 month ago

Waydroid Toolbox has been updated. it adds an option to apply / remove custom LIBNDK patches from qwerty12356-wart -

https://github.com/ryanrudolfoba/SteamOS-Waydroid-Installer/commit/77ac0f06e277e0ec8e71763414005602c4eef353