#GraalVM called by gluonfx:compile stucked

185 messages · Page 1 of 1 (latest)

lyric halo
#

Problem:
I did mvn -Pandroid gluonfx:compile in a project and it follows the steps properly, but when GraalVM is called and it gets to "Garbage collector: Serial GC", it simply gets stucked and don't move to the next step.

Environment info:

-OS: Ubuntu 22.04.3 desktop amd64 running in VMware 16 with classic instalation, with 2,25 GB of RAM.
-Dependecies: Installed OpenJDK 19 with apt. Installed "GraalVM SVM java17 Linux Gluon 22.1.0.1" and "Apache Maven-3.8.6", which are in /opt/graalvm and /opt/maven.
-Project: I used the archetype from NetBeans: "Gluon - Single View Project" and changed nothing from it and its pom.xml

Log:
[Sat Dec 09 12:49:54 BRT 2023][INFO] We will now compile your code for aarch64-linux-android. This may take some time. [Sat Dec 09 12:49:57 BRT 2023][INFO] [SUB] Warning: Ignoring server-mode native-image argument --no-server. [Sat Dec 09 12:50:07 BRT 2023][INFO] [SUB] ======================================================================================================================== [Sat Dec 09 12:50:07 BRT 2023][INFO] [SUB] GraalVM Native Image: Generating 'com.gluonpadrao.gluonpadrao' (shared library)... [Sat Dec 09 12:50:07 BRT 2023][INFO] [SUB] ======================================================================================================================== [Sat Dec 09 12:50:14 BRT 2023][INFO] [SUB] [1/7] Initializing...
(14.2s @ 0.15GB) [Sat Dec 09 12:50:14 BRT 2023][INFO] [SUB] Version info: 'GraalVM 22.1.0.1 Java 17 CE' [Sat Dec 09 12:50:14 BRT 2023][INFO] [SUB] Garbage collector: Serial GC

raw vaporBOT
#

⌛ This post has been reserved for your question.

Hey @lyric halo! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

warped wing
#

How long is it stuck?

lyric halo
warped wing
#

oh and 2.25GB RAM is probably not enough

#

it might work with a hello world but native-image is very resource-hungry

#

I have a somewhat big Spring application but compiling that with native-image struggles with 8GB of memory (on the CI)

lyric halo
warped wing
#

but in most cases, I would try to have at least 8GB of memory

#

if there's not sufficient memory, the following things can happen

  • it takes ages because the GC needs to stop the application clean up stuff constantly, that can take up most of the time while compiling it
  • native-image detects that the application was almost exclusively doing GC work in the last phase and stops the build with an error as it thinks it's pointless to continue
  • it crashes with an OutOfMemoryError
#

I think I had all of these cases with native-image lol

#

but I could check compiling a hello world with 2GB

lyric halo
#

I don't know exactly how to use GraalVM, as it is being called by gluonfx and not directly by me, but I'll check it out. It seems plausible to me that the cause is the first possibility.

warped wing
#

ok a hello world seems to work well with 2GB

#

but that doesn't say much

#

I would give it more memory

lyric halo
#

@warped wing strange, I put 3.5 GB and tried to use the same maven goal in the same project and it advanced in the process of compilation, but somehow my terminal simply disappeared

#

I saw too that the maximum memory used by java process was 2.1 GB (even though there was more space to use)

warped wing
lyric halo
#

Maybe

warped wing
lyric halo
warped wing
#

actually I don't know

#

maybe you could try -JXmX=2G or something like that

lyric halo
#

ChatGPT yesterday recommended something that: MAVEN_OPTS="-Xmx3G" mvn -Pandroid gluonfx:compile

#

I'm going to try that now

warped wing
#

I think adding -J-Xmx3G to the native-image options should work

#

I think MAVEN_OPTS only changes it for Maven, not for native-image

#

well maybe it doesn't work

lyric halo
#

Makes sense. Is it possible to change universally the native-image options?

warped wing
warped wing
lyric halo
#

Right, Imma search about it

warped wing
#

What options are available in the <configuration> of the gluon javafx plugin?

#

oh there's nativeImageArgs

#
<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>gluonfx-maven-plugin</artifactId>
    <version>1.0.22</version>
    <configuration>
        <nativeImageArgs>-J-Xmx3G</nativeImageArgs>
      <!-- ... -->
#

though if you set it to 3G, I think it would use slightly less than that

#

but try it

#

but you could try setting both xmx and xms to the same value

#

<nativeImageArgs>-J-Xmx3G -J-Xms3G</nativeImageArgs>

iron carbonBOT
#

These are the arguments, Imma change them as you said:

        <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>gluonfx-maven-plugin</artifactId> ```
            <version>${gluonfx.plugin.version}</version>
            <configuration>
                <target>${gluonfx.target}</target>
                <attachList>
                    <list>display</list>
                    <list>lifecycle</list>
                    <list>statusbar</list>
                    <list>storage</list>
                </attachList>
                <mainClass>${mainClassName}</mainClass> ```
            </configuration>
        </plugin>

This message has been formatted automatically. You can disable this using /preferences.

warped wing
#

nice try, @raw vapor

lyric halo
#

@warped wing I got "Invalid maximum heap size" error

warped wing
#

maybe you need to do something like

<nativeImageArgs>
  <nativeImageArg>-J-Xmx3G</nativeImageArg>
  <nativeImageArg>-J-Xms3G</nativeImageArg>
</nativeImageArgs>
``` if you want to set both xmx and xms
#

or just set xmx only and leave out xms

iron carbonBOT
#

Sorry for the delay, I had to leave, here it is:

[Sat Dec 09 15:24:54 BRT 2023][INFO] [SUB] Warning: Ignoring server-mode native-image argument --no-server.
[Sat Dec 09 15:24:54 BRT 2023][INFO] [SUB] Invalid maximum heap size: -Xmx3G -J-Xms3G
[Sat Dec 09 15:24:54 BRT 2023][INFO] [SUB] Error: Could not create the Java Virtual Machine.
[Sat Dec 09 15:24:54 BRT 2023][INFO] [SUB] Error: A fatal exception has occurred. Program will exit.
[Sat Dec 09 15:24:54 BRT 2023][INFO] [SUB] Error: Image build request failed with exit status 1
[Sat Dec 09 15:24:54 BRT 2023][SEVERE] Process compile failed with result: 1
Check the log files under /home/luiz/javaprojects/gluonpadrao/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Sat Dec 09 15:24:54 BRT 2023][INFO] Logging process [compile] to file: /home/luiz/javaprojects/gluonpadrao/target/gluonfx/log/process-compile-1702146294530.log
[Sat Dec 09 15:24:54 BRT 2023][SEVERE] Compiling failed.
Check the log files under /home/luiz/javaprojects/gluonpadrao/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

        <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>gluonfx-maven-plugin</artifactId> ```
            <version>${gluonfx.plugin.version}</version>
            <configuration>
                <target>${gluonfx.target}</target>
                <attachList>
                    <list>display</list>
                    <list>lifecycle</list>
                    <list>statusbar</list>
                    <list>storage</list>
                </attachList>
                <mainClass>${mainClassName}</mainClass> ```
                <nativeImageArgs>-J-Xmx3G -J-Xms3G</nativeImageArgs>
            </configuration>
        </plugin>

This message has been formatted automatically. You can disable this using /preferences.

warped wing
#

or only specify xmx and not both

#

i.e. <nativeImageArgs>-J-Xmx3G</nativeImageArgs>

lyric halo
lyric halo
warped wing
#

which is the maximum amount of memory that can be used for objects etc

#

and Xms is the default heal size, how much is reserved for it from the beginning on

#

When the error occured, it tried to supply both as a single argument

lyric halo
warped wing
#

xmx is the maximum amount it can use (it will likely use as much as it can get) so that's the important option to set

lyric halo
lyric halo
#

Ah, sorry, I did a little research and understood now

lyric halo
#

Put 3.8 GB for VM and things are getting insane here

lyric halo
#

Everytime it is crashing probably by running out of memory

#

Imma increase the swap size

warped wing
#

Can you show the logs of it crashing?

warped wing
lyric halo
warped wing
#

in the console

lyric halo
warped wing
#

then consider not giving all of the memory to native-image

#

and leaving some memory for the OS

lyric halo
#

I tried to see the log in/target/gluonfx/aarch64-android/gvm/log/client-debug0.log and didn't succed

lyric halo
warped wing
#

alternatively, you could try to pipe the output to a file

lyric halo
#

Outro 2048M and it is stuck in the line Garbage Collector: Serial GC again

@warped wing it seems that I have two solutions: buying more RAM or increasing swap

warped wing
#

You could try using a newer version of GraalVM

lyric halo
#

It doesn't seem to be compatible with gluonfx, but I'll give a try

#

@warped wing does it use less RAM than the previous versions?

warped wing
#

not really

#

but maybe you are running into a bug with the old version

#

Can you try native-image compiling a hello-world?

#

without JavaFX

#

e.g. just create a normal Java Hello World and compile it so you have a Hello.class and then run native-image Hello

raw vaporBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

lyric halo
#

luiz@luiz-vm:~/NetBeansProjects/helloworld/build/classes/helloworld$ native-image Helloworld

#

GraalVM Native Image: Generating 'helloworld' (executable)...

[1/7] Initializing... (0.0s @ 0.10GB)
Fatal error: java.lang.NoClassDefFoundError: helloworld/Helloworld (wrong name: Helloworld)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:291)
at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:287)
at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:296)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:343)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)
Error: Image build request failed with exit status 1

raw vaporBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

lyric halo
#

@warped wing

mint wing
#

It is written in error. Class Helloworld is not found. Make sure, you have set it up properly...

warped wing
lyric halo
warped wing
#

possible

lyric halo
#

luiz@luiz-vm:~/NetBeansProjects/HelloWorld$ native-image build/classes/helloworld/HelloWorld

GraalVM Native Image: Generating 'build/classes/helloworld/helloworld' (executable)...

[1/7] Initializing... (0.0s @ 0.09GB)
Error: Main entry point class 'build/classes/helloworld/HelloWorld' neither found on the classpath nor on the modulepath.
classpath: '/home/luiz/NetBeansProjects/HelloWorld:/opt/graalvm/lib/svm/library-support.jar'
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

#

@mint wing

mint wing
#

I have build native images only through maven plugin. Never used it in command line by hand :/

#

but from the error I can just say that it still can not find your HelloWorld class

lyric halo
#

Really strange. That path was found by pressing key and its extension is .class

mint wing
#

I will be back in 20 minutes, than I can help you...

lyric halo
warped wing
#

and then you run native-image HelloWorld in the same directory

lyric halo
warped wing
#

what happens?

#

I would use javac for compiling it btw

lyric halo
#

I tried that too.

luiz@luiz-vm:~$ cd NetBeansProjects/
luiz@luiz-vm:~/NetBeansProjects$ cd HelloWorld/
luiz@luiz-vm:~/NetBeansProjects/HelloWorld$ cd src/
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src$ cd helloworld/
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src/helloworld$ ls
HelloWorld.java
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src/helloworld$ javac HelloWorld.java
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src/helloworld$ ls
HelloWorld.class HelloWorld.java
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src/helloworld$ native-image HelloWorld

GraalVM Native Image: Generating 'helloworld' (executable)...

[1/7] Initializing... (0.0s @ 0.11GB)
Fatal error: java.lang.NoClassDefFoundError: helloworld/HelloWorld (wrong name: HelloWorld)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)

... (omitted)

#

@warped wing

warped wing
#

oh it is in a package

#

you need to go to the parent directory

#

and use native-image helloworld.HelloWorld I think

lyric halo
#

Makes sense, because in the file it has package declaration

#

luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src/helloworld$ cd ..
luiz@luiz-vm:~/NetBeansProjects/HelloWorld/src$ native-image helloWorld.HelloWorld

GraalVM Native Image: Generating 'helloworld.helloworld' (executable)...

[1/7] Initializing... (0.0s @ 0.09GB)
Error: Main entry point class 'helloWorld.HelloWorld' neither found on the classpath nor on the modulepath.
classpath: '/home/luiz/NetBeansProjects/HelloWorld/src:/opt/graalvm/lib/svm/library-support.jar'
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

lyric halo
#

@warped wing why is it written

classpath: '/home/luiz/NetBeansProjects/HelloWorld:/opt/graalvm/lib/svm/library-support.jar'
?

warped wing
#

because that's where it executes stuff from?

lyric halo
#

I got a really strange error

lyric halo
#

I solved it, I only had to do:
sudo apt-get install zlib1g-dev

#

@warped wing That is the console output:

#

3m 35s to compile the Hello World program

raw vaporBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

lyric halo
#

@warped wing

warped wing
#

ok yeah seems like it works with a hello world but you probably need more resources for your JavaFX application

#

and it did require more than 1.6GB of memory for the hello world

lyric halo
warped wing
#

also if zlib1g-dev was necessary for the hello world, it's also necessary for the JavaFX application

#

And as I said, you could also try with a newer JavaFX version

lyric halo
warped wing
#

though I don't think so

#

btw can you execute the application with GraalVM (without native-image) on that device?

warped wing
#

but make sure you use the java from GraalVM (you can check with java -version)

lyric halo
#

It is the same java (java 17)

warped wing
lyric halo
#

No

warped wing
#

if so, try running your JavaFX application with it

warped wing
#

What's the output of whereis native-image?

lyric halo
lyric halo
warped wing
warped wing
#

if that doesn't work then native-image is unlikely to work as well

#

even with more RAM

lyric halo
#

The javafx aplication works. Netbeans compile and run it by pressing build

#

@warped wing

warped wing
#

yeah ok

#

Did you try compiling it again after getting the hello world to work?

#

And as I said, I would redirect stdout and stderr to somewhere a file

#

so you still get the output in case the terminal crashes

lyric halo
#

I'm a bit confused, I have two applications: the hello world and the javafx application

#

The native-image worked to hello world, and the javafx can be compiled and executed without graalvm

warped wing
#

I am talking about compiling the javafx application with native-image

#

that's what you want to do, right?

#

the hello world was just to test whether native-image works

#

oh and are you using FXML?

#

if so, you might need to add reflective metadata configuration as well

lyric halo
warped wing
#

but you'll see that when running the native-image compiled application (once you get to that)

warped wing
lyric halo
#

There is a resource called icon.png

warped wing
#

you might need to tell native-image about that

lyric halo
warped wing
#

but maybe also not

#

native-image could maybe detect it automatically

#

but that would only become a problem when running the application I think

#

if you run into issues with resources like your icon.png, you might want to check out this message I have written: #1099004918007865404 message

mint wing
#

I saw you are using Gluon. Did you followed theirs guide for native image?

warped wing
#

oh btw you might be able to use a CI system like GitHub Actions for native-image

lyric halo
#

@warped wing I'll look more carefully later, I have to go out now. Thanks for all your help 🙂

raw vaporBOT
lyric halo
#

This bot is very smart

warped wing
#

e.g. it recognized "thank" in your message

lyric halo
warped wing