gluonhq / gluonfx-maven-plugin

Plugin that simplifies creating native images for Java/JavaFX maven projects
BSD 3-Clause "New" or "Revised" License
194 stars 39 forks source link

Android build via GitHub Actions on GitHub runner fails due to memory constraints #356

Open mipastgt opened 3 years ago

mipastgt commented 3 years ago

I've modified my whole build process to use GitHub Actions to build all artifacts but building a mobile version of my software for Android fails. First the whole build is awfully slow. Locally on macOS it just takes 3 minutes but on the GitHub runner (Ubuntu -> Android) it takes 45 minutes until it fails with an OutOfMemoryError. Due to earlier experience I'd say the slowness is also due to the too tight memory constraints. According to the documentation a Linux runner has only 7 GB of memory and I'd say this is not enough to build any serious application with JavaFX for Android.

...
2021-07-27T09:22:13.6449596Z [Tue Jul 27 09:22:13 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]     (clinit):   1,227.75 ms,  4.55 GB
2021-07-27T09:22:13.8117682Z [Tue Jul 27 09:22:13 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]   (typeflow):  55,669.58 ms,  4.55 GB
2021-07-27T09:22:13.8123344Z [Tue Jul 27 09:22:13 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]    (objects): 184,007.58 ms,  4.55 GB
2021-07-27T09:22:13.8141852Z [Tue Jul 27 09:22:13 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]   (features):   3,774.59 ms,  4.55 GB
2021-07-27T09:22:13.8144373Z [Tue Jul 27 09:22:13 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]     analysis: 247,164.93 ms,  4.55 GB
2021-07-27T09:22:37.3824292Z [Tue Jul 27 09:22:37 UTC 2021][INFO] [SUB] # Printing call tree to: /home/runner/work/mpCoPilotApps/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/call_tree_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_092237.txt
2021-07-27T09:22:45.0421360Z [Tue Jul 27 09:22:45 UTC 2021][INFO] [SUB] # Printing list of used methods to: /home/runner/work/mpCoPilotApps/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_methods_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_092245.txt
2021-07-27T09:22:45.3515814Z [Tue Jul 27 09:22:45 UTC 2021][INFO] [SUB] # Printing list of used classes to: /home/runner/work/mpCoPilotApps/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_classes_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_092245.txt
2021-07-27T09:22:45.4439593Z [Tue Jul 27 09:22:45 UTC 2021][INFO] [SUB] # Printing list of used packages to: /home/runner/work/mpCoPilotApps/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_packages_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_092245.txt
2021-07-27T09:23:02.2137011Z [Tue Jul 27 09:23:02 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]     universe:  16,697.72 ms,  5.14 GB
2021-07-27T09:23:27.8630918Z [Tue Jul 27 09:23:27 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]      (parse):  25,077.33 ms,  4.83 GB
2021-07-27T09:27:11.8962283Z [Tue Jul 27 09:27:11 UTC 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:3895]     (inline): 223,671.44 ms,  4.83 GB
2021-07-27T09:55:06.8491733Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB] [thread:1] scope: main
2021-07-27T09:55:06.8502495Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]     [thread:1] scope: main.Operation.Compiling
2021-07-27T09:55:06.8593478Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]     Context: StructuredGraph:718043{HostedMethod<ZipFile$Source.release -> AnalysisMethod<java.util.zip.ZipFile$Source.release -> HotSpotMethod<ZipFile$Source.release(ZipFile$Source)>>>}
2021-07-27T09:55:06.8599069Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]     Context: HostedMethod<ZipFile$Source.release -> AnalysisMethod<java.util.zip.ZipFile$Source.release -> HotSpotMethod<ZipFile$Source.release(ZipFile$Source)>>>
2021-07-27T09:55:06.8600794Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]       [thread:1] scope: main.Operation.Compiling.GraalCompiler
2021-07-27T09:55:06.8602901Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]       Context: StructuredGraph:718043{HostedMethod<ZipFile$Source.release -> AnalysisMethod<java.util.zip.ZipFile$Source.release -> HotSpotMethod<ZipFile$Source.release(ZipFile$Source)>>>}
2021-07-27T09:55:06.8604831Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]         [thread:1] scope: main.Operation.Compiling.GraalCompiler.BackEnd
2021-07-27T09:55:06.8607067Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]         Context: StructuredGraph:718043{HostedMethod<ZipFile$Source.release -> AnalysisMethod<java.util.zip.ZipFile$Source.release -> HotSpotMethod<ZipFile$Source.release(ZipFile$Source)>>>}
2021-07-27T09:55:06.8609189Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]           [thread:1] scope: main.Operation.Compiling.GraalCompiler.BackEnd.CodeGen
2021-07-27T09:55:06.8611601Z [Tue Jul 27 09:55:06 UTC 2021][INFO] [SUB]           Exception raised in scope main.Operation.Compiling.GraalCompiler.BackEnd.CodeGen: java.lang.OutOfMemoryError: GC overhead limit exceeded
...

Is there any workaround or solution to this problem besides using a self hosted runner? Maybe the native-image memory limit could be increased because it does not seem to use all of the 7 GB which are available.

(Things would be much easier if I could just build for Android from my macOS development machine.)

mipastgt commented 3 years ago

Just for comparison. I have now built the Android version on a cloud server at Hetzner. The build succeeded within 3 minutes.

[Tue Jul 27 17:45:26 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]     (clinit):   1,322.01 ms,  7.05 GB
[Tue Jul 27 17:45:26 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]   (typeflow):  16,207.36 ms,  7.05 GB
[Tue Jul 27 17:45:26 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]    (objects):  52,131.35 ms,  7.05 GB
[Tue Jul 27 17:45:26 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]   (features):   3,424.43 ms,  7.05 GB
[Tue Jul 27 17:45:26 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]     analysis:  75,722.58 ms,  7.05 GB
[Tue Jul 27 17:45:50 CEST 2021][INFO] [SUB] # Printing call tree to: /home/mpaus/builds/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/call_tree_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_174550.txt
[Tue Jul 27 17:45:57 CEST 2021][INFO] [SUB] # Printing list of used methods to: /home/mpaus/builds/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_methods_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_174557.txt
[Tue Jul 27 17:45:57 CEST 2021][INFO] [SUB] # Printing list of used classes to: /home/mpaus/builds/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_classes_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_174557.txt
[Tue Jul 27 17:45:58 CEST 2021][INFO] [SUB] # Printing list of used packages to: /home/mpaus/builds/mpCoPilotApps/mpCoPilot-main-mobile/target/gluonfx/aarch64-android/gvm/mpCoPilotApp2/reports/used_packages_de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2_20210727_174558.txt
[Tue Jul 27 17:46:00 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]     universe:   2,736.90 ms,  7.03 GB
[Tue Jul 27 17:46:07 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]      (parse):   5,990.94 ms,  8.58 GB
[Tue Jul 27 17:46:12 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]     (inline):   4,368.28 ms,  7.89 GB
[Tue Jul 27 17:46:36 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]    (compile):  24,759.15 ms,  8.08 GB
[Tue Jul 27 17:46:39 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]      compile:  38,089.26 ms,  8.08 GB
[Tue Jul 27 17:46:49 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]        image:  10,553.15 ms,  8.20 GB
[Tue Jul 27 17:46:50 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]        write:     580.43 ms,  8.20 GB
[Tue Jul 27 17:46:50 CEST 2021][INFO] [SUB] [de.mpmediasoft.mpcopilot.main.mobile.gui.main.mpcopilotapp2:1242]      [total]: 164,368.96 ms,  8.20 GB
mipastgt commented 3 years ago

Making it possible to build for Android from macOS would also solve the GitHub action memory problem because according to supported-runners-and-hardware-resources a macOS GitHub runner gets 14 GB of RAM (instead of the 7 GB for Linux) which should be enough for most projects.

FDelporte commented 2 years ago

This build is working with the new GraalVM GitHub Action runner: https://github.com/FDelporte/JavaMagazineFXGL/blob/native/.github/workflows/maven-ubuntu-android.yml