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

Prepare a Graal-based iOS AOT Compilation #1611

Open
MeFisto94 opened this issue Sep 30, 2021 · 6 comments
Open

Prepare a Graal-based iOS AOT Compilation #1611

MeFisto94 opened this issue Sep 30, 2021 · 6 comments
Labels

Comments

@MeFisto94
Copy link
Member

MeFisto94 commented Sep 30, 2021

Due to the sunset of bintray, the SDK cannot easily access the avian build anymore, that I manually did painfully on a Mac OS X machine and stored it on bintray.

Now while I could try to get this running on Github Actions, it's still discontinued and based on java 7.
Instead Graal provides an industry grade support for general AOT compilation and should be supported for a much longer time.

The scope of this issue is to determine the steps required to get a working iOS Build and potentially yield further issues to implement engine-side improvements for that.

I guess @Ali-RS already had Graal Native image running?

Edit: Potentially even running some example in Github Actions to verify all the issues from https://hub.jmonkeyengine.org/t/native-compilation-graalvm-native-image/43820/ don't arise

@Ali-RS
Copy link
Member

Ali-RS commented Sep 30, 2021

Atm, I do not have GraalVM installed. My experience with Graal was with a non-JME hello world sample on Linux but it was from long ago.

One of the restrictions of GraalVM native-image on mobile is that at the moment it only supports 64bit phones.

There are two Gradle plugins for using GraalVM native-image.

https://github.com/graalvm/native-build-tools (Java)

or

https://github.com/gluonhq/gluonfx-gradle-plugin (Java/JavaFX)

I guess the most complicated part is with writing the configuration files. For auto-generating configuration files for JNI, Reflection,... they have developed a tracing agent. (have not used). It runs the app in a regular JVM and detects the JNI, Reflection,... configuration at runtime. This might be feasible for a desktop app with LWJGL backend but I am not sure how we can run tracing agent with GLES backend on Mac to create the correct JNI configuration file for iOS!

@stephengold stephengold added this to the Future Release milestone Oct 23, 2021
@tlf30
Copy link
Contributor

tlf30 commented Nov 13, 2021

About 6 months ago, I invested quite a bit a time in trying to get jme graalvm images to build. I never was actually successful. Some of the LWJGL magic was causing is to explode. Iirc I may have a slightly older forum post about it. If someone can get it working even for a desktop build of jme I would love to know.

@Ali-RS
Copy link
Member

Ali-RS commented Nov 14, 2021

There is a Graal VM example using LibGdx + LWJGL which might worth looking.
https://github.com/ByerN/libgdx-graalvm-example

Also, note that for iOS we do not require LWJGL.

@Ali-RS
Copy link
Member

Ali-RS commented Mar 23, 2023

By the way, there is also RoboVM https://github.com/MobiVM/robovm
But I do not know if they support newer java language features.

Edit:
MobiVM/robovm#582

@joliver82
Copy link
Contributor

Hi guys!

I got some spare time and managed to get a simple jme3.6.1 app to compile and run successfully with graalvm's native image. I've uploaded the sample to github so you can have a look: https://github.com/joliver82/jme3-graalvm-sample-project

Although this is a good first step forward, iOS compatibility will require a lot more work to be done, at least:

  • Recover and update (if required) jme-ios and the native code previously hosted at both jme3 and jme3-sdk repos
  • Create both the java lib and natives from them
  • Add to graalvm's native-image configurations most (if not all) jni calls for iOS in jni-config.json and also the dylibs in resource-config.json
  • Modify gradle to create ios binary instead of current desktop os and arch and use the new libraries

Once these tasks are accomplished I think we should be able to have a graalvm ios build and run it on a device.

I'm not sure what will happen regarding touch input, device rotation and maybe other stuff. Previously it was managed in https://github.com/jMonkeyEngine/sdk/blob/v3.2/jme3-ios/ios-data/templates/project/jme-ios/jmeAppDelegate.m getting the events from native and sending them to the jme harness

@stephengold
Copy link
Member

That's encouraging.

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

No branches or pull requests

5 participants