Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work on arm64 despite having package for it #66

Open
micr0-dev opened this issue Jun 20, 2024 · 28 comments
Open

Doesn't work on arm64 despite having package for it #66

micr0-dev opened this issue Jun 20, 2024 · 28 comments

Comments

@micr0-dev
Copy link

~ ❯ flatpak run com.github.Anuken.Mindustry
[E] arc.util.ArcRuntimeException: Couldn't load shared library 'libarcarm64.so' for target: Linux, 64-bit
	at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:84)
	at arc.util.ArcNativesLoader.load(ArcNativesLoader.java:14)
	at arc.backend.sdl.SdlApplication.init(SdlApplication.java:107)
	at arc.backend.sdl.SdlApplication.<init>(SdlApplication.java:35)
	at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:39)
Caused by: arc.util.ArcRuntimeException: Unable to read file for extraction: libarcarm64.so
	at arc.util.SharedLibraryLoader.readFile(SharedLibraryLoader.java:93)
	at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:253)
	at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:81)
	... 4 more
OS: Fedora Linux Asahi Remix 40 (Workstation Edition) aarch64 
Host: Apple MacBook Air (13-inch, M2, 2022) 
Kernel: 6.8.10-400.asahi.fc40.aarch64+16k 

Packages: 2074 (rpm), 19 (flatpak) 
DE: GNOME 46.2 

Arm package should probably be removed until the project actually supports it

@TobTobXX
Copy link
Contributor

Huh, I'm not too sure, but I thought it was java / libGDX and thus crossplatform. Is libGDX not on arm...?

@k8ieone
Copy link

k8ieone commented Oct 20, 2024

It is unfortunate, but the developer is completely uninterested in bringing ARM support. There were a lot of issues open in the upstream repo about ARM support. All of them end like this one Anuken/Mindustry#4854

@k8ieone
Copy link

k8ieone commented Oct 20, 2024

The game uses a game framework based on libGDX called arc. Anuken/Arc#167 This is the real blocker.

TobTobXX added a commit to TobTobXX/com.github.Anuken.Mindustry that referenced this issue Oct 21, 2024
Mindustry does not support arm[0].
This enables only the build for x86_64[1].

Fixes flathub#66.

[0]: Anuken/Arc#167
[1]: https://docs.flathub.org/docs/for-app-authors/maintenance#limiting-the-set-of-architectures-to-build-on
@TobTobXX
Copy link
Contributor

Ok, thanks for collecting the links/infos. Submitted a PR to fix this. If aarch64 will be supported in the future, a new issue can be opened.

(btw, the issue may just go away if we can someday build it from source. It is not clear whether there are actual build issues when building for aarch64, there was an attempt, but I abandoned it because gradle is a PITA to generate flatpak modules from.)

@k8ieone
Copy link

k8ieone commented Oct 22, 2024

Building from source is preferred for Flatpak afaik, but I get it. IIRC I tried building the game on bare metal on x86_64 at some point but eventually gave up as well.

@k8ieone
Copy link

k8ieone commented Oct 22, 2024

I couldn't let this go so I tried getting an ARM build going today. My Arc fork with the necessary changes is here: https://github.com/k8ieone/Arc

I also found https://github.com/flatpak/flatpak-builder-tools/tree/master/gradle which means we should be able to build the Flatpak from source.

So far I was able to generate resources for both Arc and Mindustry. Unfortunately I wasn't able to generate it from the last release tag, only from the master branch. But at least it's a start. I'll try to move this along and modify the Flatpak manifest to build from source hopefully later this week.

You can find the generated resources in my fork: https://github.com/k8ieone/com.github.Anuken.Mindustry

Unfortunately I wasn't able to test the built jar file on my hardware. All my ARM systems run Alpine which is not supported so I won't be able to try this until I'm able to run it in Flatpak to avoid the musl incompatibility.

@TobTobXX
Copy link
Contributor

TobTobXX commented Oct 23, 2024

Wow, nice job getting Arc to compile on aarch64 too! Did you get it to work outside of Flatpak? If yes, then it would be nice if you submitted the PR to Arc.

A few while ago I already tried building the Flatpak from source (#39). The gradle module from flatpak-builder-tools was still a PR then and I used a modified script instead (instead of parsing the gradle stdio output, I tried listing the gradle cache after a build). However Mindustry uses (used?) some weird dynamic dependency injection and the build tool didn't catch on. I'd recommend to not get your hopes high before you can test the flatpak.

@k8ieone
Copy link

k8ieone commented Oct 23, 2024

Damn, thanks for letting me know. I'll still probably try it put while keeping in mind that it could end up not working.

About Arc, I did some more thinking on this and in its current state it needs to be built on ARM because I had issues getting SDL2 cross-compiled.

If we're able to solve this one little problem, I can see this getting accepted as a PR.

@TobTobXX
Copy link
Contributor

TobTobXX commented Oct 23, 2024

I had issues getting SDL2 cross-compiled.

I've never not had isssues with cross-compiling :).

it needs to be built on ARM
[...]
If we're able to solve this one little problem, I can see this getting accepted as a PR.

Hmm... Well GitHub has ARM-runners, so the CI would (should) actually work if it works on your machine. Maybe try running the GitHub actions on your own account and check if the generated jar is working on arm. If this works, it is possible that the PR can still be accepted, even though x-compiling doesn't work.

@k8ieone
Copy link

k8ieone commented Oct 23, 2024

Good point, I'll try that out.

@k8ieone
Copy link

k8ieone commented Oct 27, 2024

@TobTobXX I managed to work around the SDL cross-compile by using an ARM Docker container for the SDL build. The rest of the libraries cross-compile nicely.

I left a comment in the Arc repo.

@k8ieone
Copy link

k8ieone commented Oct 27, 2024

@TobTobXX Do you have a device that is a bit more modern where you could test it? The only device where I can easily try this is a Pinephone. I got GLXBadFBConfig which could be caused by the Pinephone's outdated hardware.

I had to set SDL_VIDEODRIVER=x11, otherwise I'd get Wayland unavailable.

GitHub didn't allow uploading it here, so here's a link to a file share.

https://cloud.mcld.eu/s/zwAgBwL7fEQjSAs

@k8ieone
Copy link

k8ieone commented Oct 27, 2024

Alright, I did some more digging and found LIBGL_ALWAYS_SOFTWARE=true, using this I was able to force software rendering and it works! This leads me to believe that the issues I encountered above were indeed caused by ancient hardware.

IMG_20241027_194653.jpg

@k8ieone
Copy link

k8ieone commented Oct 27, 2024

Jumping through a whole bunch of hoops, I was eventually able to launch the game inside an ARM Docker container running on my x86 PC as well.

Screencast.From.2024-10-27.20-11-13.webm

Of course it was extremely slow. Not only was it using software rendering (the ARM build of Mesa didn't have support for Iris graphics, because why would it xd) but it was going through QEMU so the emulation overhead killed it even more. But it works.

@TobTobXX
Copy link
Contributor

Wait... you can run Docker apps with a GUI???

But well done! Unfortunately I don't have any ARM devices. @micr0-dev opened the issue, so I suppose they have an arm-device. @micr0-dev if you could help k8ieone test this, that'd be nice.

@micr0-dev
Copy link
Author

yeah I do! I have an m2 macbook air running asahi linux fedora, i could test it!

I have both hyprland and gnome installed on it

@k8ieone
Copy link

k8ieone commented Oct 28, 2024

@TobTobXX It's janky, but you can 😄

@micr0-dev Awesome! I feel like I should warn you about installing random packages from the internet 😅

You can check the Flatpak's permissions by opening it in GNOME Software. I left them the same as the currently published Flatpak and those seem pretty tight to me.

Pinky promise it won't do anything evil 😉

@k8ieone
Copy link

k8ieone commented Oct 28, 2024

@micr0-dev Oh yea, it's built from the last git commit, so it could break your save. But I haven't tested that.

@Br0ad
Copy link

Br0ad commented Nov 14, 2024

I have hardware rendering support on the Raspberry Pi 4 if that helps. @k8ieone
20241114_13h56m48s_grim

@k8ieone
Copy link

k8ieone commented Nov 14, 2024

No way, that's awesome! Seeing it actually running without any hacks. I'll report back to the PR that it's been successfully tested.

Did you have to tweak anything to get it running? How is the performance?

@Br0ad
Copy link

Br0ad commented Nov 14, 2024

@k8ieone I was not expecting high performance in the first place... but turning off display effects will have it average around ~50-80 fps in multiple different maps I tested. I will note I dedicated a bit more vram (256mb total now) to the Pi 4's Broadcom VideoCore VI, but otherwise nothing else!

I can't wait for the Arc PR.

@k8ieone
Copy link

k8ieone commented Nov 14, 2024

That's awesome! Thanks for testing it out!

@Br0ad
Copy link

Br0ad commented Nov 15, 2024

any time!

@k8ieone
Copy link

k8ieone commented Nov 15, 2024

PR is open 🚀 Anuken/Arc#181

@TheEvilSkeleton
Copy link
Collaborator

@k8ieone you absolute legend, thanks a lot for working on it! For the record, I have a Xiaomi Redmi 5 Plus running postmarketOS, so I'll be able to test Mindustry on my phone once the arm64 package is working and submitted as a PR :)

@k8ieone
Copy link

k8ieone commented Dec 6, 2024

My PineTab 2 just arrived and I was able to properly test this myself. I was really excited to see the game launch and run smoothly on an ARM device.

That being said, Mindustry doesn't expect touch input on Linux devices. Navigating around menus works as expected but touch gestures like pinch zooming are ignored. Dragging in game is the same as clicking and holding with a mouse so there's no way to move around. The game tells you to use WASD to move around 😄 So currently the game is unplayable without a mouse and keyboard. A gamepad sounds like the most portable option but I'm not sure if those are supported by the game, I haven't tested that yet.

I'm thinking even when the PR gets merged, we'll have to wait until the next release before the ARM natives get included. We could "patch" the jar file here on Flathub to include them, but I don't know if that's going to work. The current Mindustry wasn't built against Arc main so there's going to be a version mismatch.

I'll try to come up with a PR that includes the ARM natives in the latest Mindustry release. When the next version comes out we can remove this workaround.

@k8ieone
Copy link

k8ieone commented Dec 6, 2024

Quick update: I tried using my Arc build with the latest Mindustry release and it doesn't work. I guess we'll have to wait until the next release.

@askorbinovaya-kislota
Copy link

So currently the game is unplayable without a mouse and keyboard.

try with Vars.mobile=true or Vars.testMobile=true

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 a pull request may close this issue.

6 participants