-
Notifications
You must be signed in to change notification settings - Fork 529
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
Fix #3773: Fix for junit and roboelectric tests not running in android studio artic fox #3783
Conversation
@yash10019coder Please add before/after screenshot of test on robolectirc and espresso here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here.
Thanks @yash10019coder for filing & investigating this! I've hit the GC limit when running from Gradle CLI (I mainly use Bazel for development within AS), with Arctic Fox running. Do we know why this is tied to Arctic Fox? That doesn't make much sense to me since Gradle runs outside it. Maybe it's just Arctic Fox is consuming more resources & we're already close to breaking the 1024MB limit?
Either way, the change seems reasonable. My main concern is this will have a higher chance of locking people's systems if they're running with low ram, but 4G is a reasonable ask for an Android development environment, I think.
Had a couple of other comments.
app/build.gradle
Outdated
@@ -56,7 +56,7 @@ android { | |||
unitTests { | |||
includeAndroidResources = true | |||
all { | |||
maxHeapSize = "1024m" | |||
maxHeapSize = "4024m" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should use 4096 (it's generally conventional to use multiples of '1024').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
gradle.properties
Outdated
org.gradle.jvmargs=-Xmx1024m | ||
|
||
#org.gradle.jvmargs=-Xmx1024m | ||
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why enable HeapDumpOnOutOfMemoryError?
Also, do we need both MaxPermSize & Xmx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use it as if heap runs out of memory it gives us the error and also dumps the memory out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would we use it for? It's probably a really expensive operation, and the memory dump presumably uses a large amount of disk space. We probably shouldn't enable it if it isn't needed.
I'm actually wondering if all we need here is the 'Xmx' setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'm using then only -Xmx
gradle.properties
Outdated
@@ -9,8 +9,8 @@ | |||
|
|||
# Specifies the JVM arguments used for the daemon process. | |||
# The setting is particularly useful for tweaking memory settings. | |||
org.gradle.jvmargs=-Xmx1024m | |||
|
|||
#org.gradle.jvmargs=-Xmx1024m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer not to comment out code--remove/update it instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@yash10019coder and @BenHenning FYI this solution did not work for @darkmat13r and he was facing same errors. |
@rt4914 @darkmat13r can you please provide the error log |
Hi @yash10019coder, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 3 days, it will be automatically closed so that others can take up the issue. |
@rt4914 or @darkmat13r can you please follow up with #3783 (comment)? I'm kind of keen to get this in because it's affected me as well. Gradle builds are really non-performant in AS Arctic Fox at the moment (to the point where they can actually stall indefinitely for larger build/test runs). |
@yash10019coder Now getting this Error |
Hi @yash10019coder, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
@yash10019coder is this something that you're still working on? It would be really nice to see this get wrapped up since it's affecting contributors. If you don't have the bandwidth to take this, please let us know (reassigning the base issue is no problem, we just want to make sure that folks assigned are actively working on their issues). |
Hi. FYI I've been out the last couple of weeks, so I'm working to catch up on my reviews. I might be delayed a couple of days, but I'll be reviewing this soon. Thanks for your patience! |
@yash10019coder apologies for the delay on reviewing this. I noticed that my latest discussion comment wasn't replied to--can you make sure all open threads are replied to before sending this back for a follow-up review? It's hard for me to know whether you decided not to change per my suggestion & why that's the correct choice without an explanation. |
…roid-studio-artic-fox' of github.com:yash10019coder/oppia-android into fix-for-junit-and-roboelectric-tests-not-running-in-android-studio-artic-fox
…s-not-running-in-android-studio-artic-fox
sorry for this I forgot the above threads from now onward I will reply to every comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BenHenning mentioned all the comments all the tests are working and pasing for all of us only for @darkmat13r this isn't happening everthing else is clean PTAL.
Thanks
Hi @darkmat13r @BenHenning I ran the tests for espresso junit in my windows 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yash10019coder. LGTM!
@yash10019coder Android Studio changed how it manages JUnit tests in this version, and there are now some compatibility issues. We may need to document these differences (I was hoping that Bazel would be farther along since then we could switch to it since the Android Studio with Bazel plugin is unaffected by this change, but we'll be in this in-between state for a while longer yet). /cc @FareesHussain as FYI since it's likely we'll see more people confused by how to run JUnit tests in Arctic Fox+ as more people install the latest version of Android Studio. |
Is it just oppia or all projects? |
What about using command line? |
I think it has to do with the fact that we define shared Robolectric/Espresso tests, so running JUnit tests directly from the editor just fails. CLI would work, but it makes debugging a lot harder so I think instead we might want to consider updating the testing instructions to have a step-by-step guide for how to add/run JUnit tests in Arctic Fox (this needs some investigation--I forget what the exact issues are since I rarely use Gradle in development). |
@yash10019coder @BenHenning I think the issue i am getting must be due to fact that I installed android studio from jetbrains toolbox which installs the android in the folder of its data folder so it create a long path for command line that throws error (Command line is too long) in default configuration for the tests. I will install the android studio from installer and see if thats the case. |
Ah interesting @darkmat13r. Is that a usual way to install Android Studio? I thought most people just installed it from the downloadable installer from the Android Studio download page. Also, is it an option for you to reinstall AS using the installer? It sounds like that might fix the problem that you're seeing. |
@BenHenning No, I just prefer jetbrains toolbox because its easier to update the IDEs and I use other IDE from jetbrains also. |
@yash10019coder @BenHenning I am getting this error after running from downloadable android studio |
@darkmat13r are using the shorten command line option i mentioned above? |
Yes, Same configuration as yours |
Explanation
Fixes #3773
Added a line in gradle.property due to which heap size is increased and also increased the heap size for unitTest in gradle build app
Error code for the old code when running the tests
java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtilRt.loadBytes(FileUtilRt.java:847)
at org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil.loadBytes(FileUtil.java:1409)
at org.jetbrains.kotlin.com.intellij.openapi.vfs.impl.ZipHandlerBase.contentsToByteArray(ZipHandlerBase.java:146)
at org.jetbrains.kotlin.com.intellij.openapi.vfs.impl.jar.CoreJarVirtualFile.contentsToByteArray(CoreJarVirtualFile.java:127)
at org.jetbrains.kotlin.com.intellij.openapi.vfs.VirtualFile.contentsToByteArray(VirtualFile.java:606)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl$1.findInnerClass(ClsFileImpl.java:622)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl$1.findInnerClass(ClsFileImpl.java:612)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.StubBuildingVisitor.visitInnerClass(StubBuildingVisitor.java:270)
at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:662)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl.buildFileStub(ClsFileImpl.java:574)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClassFileStubBuilder.lambda$buildStubTree$1(ClassFileStubBuilder.java:69)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClassFileStubBuilder$$Lambda$269/1237933695.get(Unknown Source)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClassFileStubBuilder.setContentAndCompute(ClassFileStubBuilder.java:105)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClassFileStubBuilder.buildStubTree(ClassFileStubBuilder.java:57)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClassFileStubBuilder.buildStubTree(ClassFileStubBuilder.java:24)
at org.jetbrains.kotlin.com.intellij.psi.stubs.BinaryFileStubBuilder$CompositeBinaryFileStubBuilder.buildStubTree(BinaryFileStubBuilder.java:53)
at org.jetbrains.kotlin.com.intellij.psi.stubs.StubTreeBuilder.buildStubTree(StubTreeBuilder.java:105)
at org.jetbrains.kotlin.com.intellij.psi.stubs.StubTreeBuilder.buildStubTree(StubTreeBuilder.java:90)
at org.jetbrains.kotlin.com.intellij.psi.stubs.CoreStubTreeLoader.readOrBuild(CoreStubTreeLoader.java:48)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl.getStubTree(ClsFileImpl.java:480)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl.getStub(ClsFileImpl.java:452)
at org.jetbrains.kotlin.com.intellij.psi.impl.compiled.ClsFileImpl.getClasses(ClsFileImpl.java:133)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl$Companion.findClassInPsiFile(KotlinCliJavaFileManagerImpl.kt:261)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl$Companion.access$findClassInPsiFile(KotlinCliJavaFileManagerImpl.kt:257)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.findPsiClassInVirtualFile(KotlinCliJavaFileManagerImpl.kt:227)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.access$findPsiClassInVirtualFile(KotlinCliJavaFileManagerImpl.kt:48)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl$findPsiClass$1.invoke(KotlinCliJavaFileManagerImpl.kt:70)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl$findPsiClass$1.invoke(KotlinCliJavaFileManagerImpl.kt:48)
at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.findPsiClass(KotlinCliJavaFileManagerImpl.kt:69)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.findClass(KotlinCliJavaFileManagerImpl.kt:135)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiElementFinderImpl.findClass(PsiElementFinderImpl.java:44)
Essential Checklist
For UI-specific PRs only
If your PR includes UI-related changes, then: