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

ARM processor support #385

Closed
SimonSchubert opened this issue Apr 16, 2020 · 15 comments
Closed

ARM processor support #385

SimonSchubert opened this issue Apr 16, 2020 · 15 comments

Comments

@SimonSchubert
Copy link

Congratulation for successfully merging the desktop and mobile codebase in version 0.8.0 🥳 .

I was hoping that after the merge the game would run on my Pinephone. But executing the jar file gives me a NPE.

java -jar ShatteredPD-v0.8.0-Desktop.jar 

Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread "main"

ARM is generally supported by libgdx, right? Do you know what the reason for the NPE is?

Here some info:
https://www.pine64.org/pinephone/

OS: Debian GNU/Linux bullseye/sid aarch64
Kernel: 5.5-pinephone
DE: Wayland

java --version
openjdk 11.0.7-ea 2020-04-14
OpenJDK Runtime Environment (build 11.0.7-ea+9-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.7-ea+9-post-Debian-1, mixed mode)

I'm happy to provide more information if needed.

@00-Evan
Copy link
Owner

00-Evan commented Apr 16, 2020

I'm not aware of whether LibGDX supports Linux ARM. Obviously the Java code should work, but there may be missing native libraries.

There should be more information in the crash than just that though, can you run the JAR from the command line and let me know if more info is printed out?

@SimonSchubert
Copy link
Author

I did run the JAR from command line and posted the output in the first code block above. It gives no stack trace.

Here is the output for the previous version:

$ java -jar ShatteredPD-v0.7.5f-Desktop.jar                              
Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'libgdx.so' for target: Linux, 32-bit
	at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125)
	at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)
	at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(LwjglNativesLoader.java:47)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:83)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:71)
	at com.watabou.pd.desktop.DesktopLauncher.main(DesktopLauncher.java:78)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: /tmp/libgdxdebian/cf7da266/libgdx.so: /tmp/libgdxdebian/cf7da266/libgdx.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
	at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:321)
	at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:121)
	... 5 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/libgdxdebian/cf7da266/libgdx.so: /tmp/libgdxdebian/cf7da266/libgdx.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
	at java.base/java.lang.Runtime.load0(Runtime.java:768)
	at java.base/java.lang.System.load(System.java:1834)
	at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:327)
	at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:296)
	... 6 more

@00-Evan
Copy link
Owner

00-Evan commented Apr 17, 2020

Hmm, well at the very least it seems like the new desktop version is eating the full error message, so I will look into that.

Unfortunately that pretty clearly points toward missing native libs. It looks like LibGDX only supports ARM in the context of mobile OSes. It's worth noting that the old desktop version also uses LibGDX, just a slightly different implementation based on the older LWJGL2 desktop backend. This new desktop version is LWJGL3 based, but the LibGDX native are probably similar or the same.

@bernhardreiter
Copy link

It would be cool to have support for desktop builds, so to run shattered on the Raspberry pi4.
I had similar issues in the past trying to get it to run there.

There seem to be some ports allowing LibGDX on GNU/Linux arm systems, so far I haven't have enough time to try everything, but here for reference:

https://www.raspberrypi.org/forums/viewtopic.php?t=249098&p=1524338

@bernhardreiter
Copy link

bernhardreiter commented May 2, 2020

The https://github.com/LWJGL/lwjgl3/releases/tag/3.2.3 release says that they've

Added support for ARM builds.

  • 32-bit: ARMv7/armhf architecture. Maven classifier: linux-arm32
  • 64-bit: ARMv8/AArch64 architecture. Maven classifier: linux-arm64

which should be the two architectures for the pinephone and raspberry pi.

For reference, here is my test:

  • Saving the example code from https://www.lwjgl.org/guide as HelloWorld.java.
  • Downloading a custom version of LWJGL with everything, arm32 as zip (took several minutes to generate).
  • unpacked the zip file in to a directory unpacked
  • compiled the application with javac -cp unpacked\* HelloWorld.java
  • ran it with java -cp .:unpacked\* HelloWorld

@SimonSchubert, this should work for you on the pinephone, too, if you use arm64. (It is my understanding that this is a test to see if the native building block of libgdx is running).

@bernhardreiter
Copy link

bernhardreiter commented May 2, 2020

Looks like libgdx/libgdx@5fa5f61
adds the arm32 and arm64 targets of the latest LWJGL to libgdx master. So it is not part of a libgdx release, but in theory just building the native libgdx for these platforms should work.

@00-Evan
Copy link
Owner

00-Evan commented May 4, 2020

That's good to hear, Assuming there aren't any issues (there's murmurs of increasing the minimum android version in 1.9.11) I'll likely update to 1.9.11 when it's properly released.

@bernhardreiter
Copy link

(One a side note: please to not raise the necessary Android version, as it makes the game less accessible, there are many devices around that only support elder versions for good).

@00-Evan
Copy link
Owner

00-Evan commented May 5, 2020

I try to avoid dropping support for old Android versions wherever possible. Because Shattered depends on more libraries these days (LibGDX everywhere, several Google libs on Google Play) it's not always possible though, I did already drop support for Android 2.2 about a year back.

I try to avoid dropping old Android support unless it's absolutely necessary though, and Android 2.3 is still used by a small but significant number of players. I already employ a few tricks to keep supporting Android 2.3 and 4.0 on Google Play.

@00-Evan
Copy link
Owner

00-Evan commented May 5, 2020

Actually after checking it seems 100% certain that LibGDX 1.9.11+ will require a minimum of android 4.0 (API level 14). For that reason I may delay updating LibGDX for some time.

@00-Evan
Copy link
Owner

00-Evan commented Jun 12, 2020

Going to defer this as it looks like I won't be updating to LibGDX 1.9.11 anytime soon, due to it being unreleased and dropping Android 2.3 support.

I might look into whether the platform can be supported while sticking to LibGDX 1.9.10, but I suspect that'll involve using a fork of libGDX or similar.

@moxvallix
Copy link

For anyone on the PinePhone wanting to play SPD, I hacked together a version that runs on Linux ARM. I forked the game into this repo: https://github.com/moxvallix/shattered-pixel-dungeon-pinephone.
I have very little experience with Java, but from some quick testing my port seems to work (maybe minus scrolling). Hope this helps anyone that wants a good game to play on their PinePhone, that isn't Chess or 2048.

@00-Evan
Copy link
Owner

00-Evan commented Jul 21, 2021

Shattered is now set to be updated to libGDX 1.10.0 in the next update.

@00-Evan
Copy link
Owner

00-Evan commented Aug 17, 2021

Shattered should support arm processors on the desktop build as of v1.0.0, let me know if there's an issue with that.

Relevant commit: 9b63eb5

@bernhardreiter
Copy link

Hereby I confirm that v1.0.3 (the jar) directly works on Raspian OS in a Raspberry Pi4. Thanks again!
(As a small return I've fixed three DE translations. ;) )

Whoever reads this and likes the ARM support, consider becoming a patron to support the game!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants