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

Gradle Kotlin daemon infinite loop until JVM max memory runs out #193

Open
kalyncoose opened this issue Jan 26, 2023 · 8 comments
Open

Gradle Kotlin daemon infinite loop until JVM max memory runs out #193

kalyncoose opened this issue Jan 26, 2023 · 8 comments

Comments

@kalyncoose
Copy link

kalyncoose commented Jan 26, 2023

Hello, thank you react native community for supporting this Docker image!

Issue Environment:

  • Runtime: GitLab CI/CD Pipeline Job
  • Image: reactnativecommunity/react-native-android:latest (also tried 6.0 and 5.4)
  • Gradle: 7.5.1
  • Android SDK Level: 31
  • jvmargs: -Xmx16g -Xms2g \ -XX\:MetaspaceSize\=512m -XX\:MaxMetaspaceSize\=1g \ -XX\:NewSize\=256m -XX\:MaxNewSize\=3g \ -Dfile.encoding\=UTF-8
  • Dependencies: node_modules is downloaded from previous job which contains the necessary react native modules

Issue Description:
When attempting to run ./gradlew bundleRelease the Gradle daemon starts as expected but on the first task :react-native-gradle-plugin:compileKotlin causes an infinite loop with the Gradle kotlin daemon. When running with no options, the daemon runs out of memory (15.7GiB) and closes at about 15 minutes of running. With info or debug/stacktrace option, daemon runs out of memory and closes at about 45 minutes of running.

Issue Reproduction:
I cannot reproduce this issue locally, only in the pipeline pod which uses this Docker image. Please look through the debug/stacktrace log dump below.

Issue Logs:
job.log

I am grateful for any expert to provide a diagnosis on what could be causing this!

@cortinico
Copy link
Member

Please look through the debug/stacktrace log dump below.

Can you please provide the debug/stacktrace log?

@kalyncoose
Copy link
Author

@cortinico I've updated the issue with the log files. Sorry I took longer cleaning the security info from it, I did it the hard way. Going to write a Python script later to make it easier...

@kalyncoose
Copy link
Author

@cortinico Could you review the Gradle log sometime this week for any obvious issues?

@cortinico
Copy link
Member

Have you tried to run without the Gradle daemon (i.e. invoke the build with --nodaemon)?
https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:disabling_the_daemon

@kalyncoose
Copy link
Author

Unfortunately it appears to fail the same way, this time at 7 min 36 secs (due to no --info or --debug flag):
log-with-no-daemon-flag.log

@cortinico
Copy link
Member

Can you re-run with --nodaemon --info --scan and send me the Gradle build scan? Please make sure the scan is safe to share also.

@kalyncoose
Copy link
Author

I'm starting to think using Gradle at all in a GitLab CI/CD pipeline is just cursed.

First of all, very annoying that the Gradle docs you linked say --no-daemon but in their CLI example write --nodaemon completely missing a dash (unless it's designed to understand that too?). So I tried both flags and in the pipeline job it appears Gradle daemon starts anyway. Then I said screw it let's use org.gradle.daemon=false in the gradle.properties and STILL it appears the Gradle daemon starts anyway. Next I can't even get a scan to work in the pipeline job, but info flag does. I tried both:

  • ./gradlew --info --scan bundleRelease
  • ./gradlew bundleRelease --info --scan

I have this in my build.gradle as well:

if (hasProperty('buildScan')) {
    buildScan {
        termsOfServiceUrl = 'https://gradle.com/terms-of-service'
        termsOfServiceAgree = 'yes'
    }
}

The only thing that has been consistent across all of my attempts (across many docker image versions as well) is that these have all used Gradle version 7.5.1. One thing I can't find in these images is any specific Kotlin version.

This is my local Gradle which works 100% of the time with all commands:

------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------

Build time:   2022-08-05 21:17:56 UTC
Revision:     d1daa0cbf1a0103000b71484e1dbfe096e095918

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.17 (Azul Systems, Inc. 11.0.17+8-LTS)
OS:           Mac OS X 12.5 x86_64

At this point I don't even think it is possible to use the docker image. I just don't understand what is going on.

@cortinico
Copy link
Member

I'm starting to think using Gradle at all in a GitLab CI/CD pipeline is just cursed.

Yeah it seems specific to your CI setup at this point. I'm unsure how to help you at this point. Are you able to ssh inside the CI and run commands from there? That can help to debug

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

No branches or pull requests

2 participants