Status Update
Comments
pe...@gmail.com <pe...@gmail.com> #2
sg...@google.com <sg...@google.com>
cl...@google.com <cl...@google.com> #3
From the log:
2024-08-23 08:24:16,009 [70180461] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 2000 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getAccessibleRole(Unknown Source)
2024-08-23 08:24:16,423 [70180875] WARN - #c.i.d.PerformanceWatcherImpl - UI was frozen for 7314ms, details saved to /Users/bhergert/Library/Logs/Google/AndroidStudio2024.1/threadDumps-freeze-20240823-082414-AI-241.18034.62.2412.12169539-ComponentManagerImpl$getComponentAdapter$1.invoke-7sec
2024-08-23 08:24:21,005 [70185457] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1023 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.accessibilityHitTest(Unknown Source)
2024-08-23 08:24:23,000 [70187452] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1995 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getAccessibleRole(Unknown Source)
2024-08-23 08:24:25,005 [70189457] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 2002 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.accessibilityHitTest(Unknown Source)
2024-08-23 08:24:25,256 [70189708] WARN - #c.i.d.PerformanceWatcherImpl - UI was frozen for 8741ms, details saved to /Users/bhergert/Library/Logs/Google/AndroidStudio2024.1/threadDumps-freeze-20240823-082421-AI-241.18034.62.2412.12169539-AndroidPsiTreeChangeListener.computeModulesToInvalidateAttributeDefinitions-8sec
2024-08-23 08:24:28,006 [70192458] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1245 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.accessibilityHitTest(Unknown Source)
2024-08-23 08:24:30,003 [70194455] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1997 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getAccessibleRole(Unknown Source)
2024-08-23 08:24:32,004 [70196456] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1999 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.accessibilityHitTest(Unknown Source)
2024-08-23 08:24:33,614 [70198066] WARN - #c.i.d.PerformanceWatcherImpl - UI was frozen for 8220ms, details saved to /Users/bhergert/Library/Logs/Google/AndroidStudio2024.1/threadDumps-freeze-20240823-082430-AI-241.18034.62.2412.12169539-HashMap.putVal-8sec
Do you still have the thread dumps in ~/Library/Logs/Google/AndroidStudio2024.1/
? If yes, can you please attach them?
Also, do you have any accessibility features enabled? Because I see various calls to java.desktop/sun.lwawt.macosx.CAccessibility
flagged for timeouts.
cl...@google.com <cl...@google.com> #4
pu...@gmail.com <pu...@gmail.com> #5
I checked under Settings > Appearance > Accessibility and nothing is enabled. Is there anywhere else I should check?
sg...@google.com <sg...@google.com> #6
I'm not sure, I just can't get to reach the CAccessibility.accessibilityHitTest
method (running under a debugger). But in any case, it doesn't seem like it is causing the freeze, quite the opposite: it's giving up posting the AWT event because the UI is frozen.
All three freeze reports point to similar stacks in the AWT thread:
at java.base@17.0.11/java.util.HashSet.add(Unknown Source)
at com.intellij.util.graph.impl.GraphAlgorithmsImpl.collectOutsRecursively(GraphAlgorithmsImpl.java:141)
at org.jetbrains.android.util.AndroidUtils.getSetWithBackwardDependencies(AndroidUtils.java:603)
at com.android.tools.idea.res.AndroidPsiTreeChangeListener.computeModulesToInvalidateAttributeDefinitions(AndroidPsiTreeChangeListener.kt:228)
at com.android.tools.idea.res.AndroidPsiTreeChangeListener.childrenChanged(AndroidPsiTreeChangeListener.kt:151)
at com.intellij.psi.impl.PsiManagerImpl.notifyPsiTreeChangeListener(PsiManagerImpl.java:414)
at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:357)
at com.intellij.psi.impl.PsiManagerImpl.childrenChanged(PsiManagerImpl.java:306)
at com.intellij.pom.tree.events.impl.ChangeInfoImpl.childrenChanged(ChangeInfoImpl.java:122)
at com.intellij.pom.tree.events.impl.ChangeInfoImpl.fireEvent(ChangeInfoImpl.java:72)
at com.intellij.pom.tree.events.impl.TreeChangeImpl.fireEvents(TreeChangeImpl.java:143)
at com.intellij.pom.tree.events.impl.TreeChangeEventImpl.fireEvents(TreeChangeEventImpl.java:130)
at com.intellij.pom.wrappers.PsiEventWrapperAspect.update(PsiEventWrapperAspect.java:32)
at com.intellij.pom.core.impl.PomModelImpl.updateDependentAspects(PomModelImpl.java:167)
[...]
(corresponding internal
There were two more freeze reports in the attached archive (thanks!) which point to
pu...@gmail.com <pu...@gmail.com> #8
to...@yahoo.com <to...@yahoo.com> #9
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug Feature Drop | 2024.2.2 Canary 3
- Android Gradle Plugin 8.8.0-alpha03
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
bi...@google.com <bi...@google.com> #10
Hung, I guess you have more context on this "check"?
hu...@google.com <hu...@google.com> #11
Could you provide a small example project to help us debug this issue?
@Clément: Do you know the difference between com.android.tools:desugar_jdk_libs_nio:2.0.4
and 2.1.1
?
to...@yahoo.com <to...@yahoo.com> #12
Could you provide a small example project to help us debug this issue?
I'll check if I can minimize some of my project tomorrow.
hu...@google.com <hu...@google.com> #13
This issue happens when D8 reports to AGP (via com.android.tools.r8.D8Command.Builder#setDesugarGraphConsumer
) that there is a dependency from the current project's classes to android.jar
. But with minSdk >= 24
, such a dependency shouldn't exist (desugaring shouldn't require a classpath when minSdk >= 24
).
@R8 team: Could you confirm whether it is possible to have a (desugaring) dependency between the project's classes and android.jar
when minSdk >= 24
?
hu...@google.com <hu...@google.com> #14
Re
to...@yahoo.com <to...@yahoo.com> #15
I tried last week... but I can't reproduce it in a brand new project (app + java-library). I can only reproduce it in my full project. My best guess is that the 'app' part uses more android classes and thereby triggers the faulty behaviour in the desugar code.
Not sure how to proceed - but I'm quite happy to try out any custom/beta build you might have?
Depending on time, I'll have another go later this week.
hu...@google.com <hu...@google.com> #16
It would be great to track down the root cause first before we come up with a fix.
Could you generate an
./gradlew :app:mergeLibDexDebug -Dcom.android.tools.r8.dumpinputtodirectory=.
make sure the build fails with the above error, and send us dumpNNNN.zip
(s) (possibly in a restricted comment)?
pu...@gmail.com <pu...@gmail.com> #17
I also have a project producing this error, but noticed it only happens in debug. In release, it builds fine. I can attach a r8dump.zip for it if necessary. Although in the zip produced, library.jar and program.jar are corrupted.
hu...@google.com <hu...@google.com> #18
Please run the build with -Dcom.android.tools.r8.dumpinputtodirectory=.
instead of -Dcom.android.tools.r8.dumpinputtofile
, hopefully it will not be corrupted.
Make sure the build fails with The given file ... is located outside the root directory
, and send us the dumpNNNN.zip
files. Thanks a lot!
to...@yahoo.com <to...@yahoo.com> #19 Restricted
to...@yahoo.com <to...@yahoo.com> #20
I can confirm #18 (thanks!, didn't think of trying that)
The failure only happens in debug builds (as uploaded in previous) while it builds fine and deploys without an issue in release builds.
hu...@google.com <hu...@google.com> #21
That's great, thanks! (Release builds use a different pipeline, so it doesn't hit this code path.)
@Clément: Could you take a look at the dump above and see why in the desugaring graph (see com.android.tools.r8.D8Command.Builder#setDesugarGraphConsumer)
D8 reports an edge to/from android.jar
and whether that is expected?
If the behavior is correct in D8, I will fix this issue in AGP.
hu...@google.com <hu...@google.com> #22
Update: By patching AGP with the input dump above, I can see that D8 reports the following dependency to AGP (via com.android.tools.r8.DesugarGraphConsumer#accept
):
dependent = {ArchiveEntryOrigin@25758} "dump12086563528200/program.jar:com/.../.../channels/io/MyPipedInputStream.class"
dependency = {ArchiveEntryOrigin@25759} "Sdk/platforms/android-35/android.jar:java/io/InputStream.class"
Do we know why D8 reports that dependency given minSdk >= 24
(26 in the input dump)?
(It would be great to track this down before beta branching that's happening today.)
hu...@google.com <hu...@google.com> #23
Steps to reproduce
Based on the input dump above, I've managed to reproduce this issue in a project (see attached):
- Create a project with
app
andlib
(Android library), using AGP 8.5.2 to 8.7.1, minSdk = 24+ - In
app
, setisCoreLibraryDesugaringEnabled = true
andcoreLibraryDesugaring("com.android.tools:desugar_jdk_libs_nio:2.1.0")
- In
lib
, create a class that implementsjava.io.InputStream
orjava.io.PipedInputStream
:
class ExampleClass(pipeSize: Int) : java.io.PipedInputStream(pipeSize)
- Run
./gradlew :app:mergeLibDexDebug
, the build will fail with:
> Transform bundleLibRuntimeToDirDebug (project :lib) with DexingNoClasspathTransform
ERROR: D8: java.lang.IllegalStateException: The given file 'Sdk/platforms/android-34/android.jar' is located outside the root directory 'MyApplication/lib/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug'
Root cause
The issue is a combination of 2 factors:
- AGP doesn't expect desugaring dependencies between project's classes and
android.jar
- D8 in some cases reports dependencies between the
ExampleClass
above andjava.io.InputStream(RetargetInterface)
inandroid.jar
Workarounds
- Use
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs_nio:2.0.4")
instead of2.1.0+
Fix
- AGP: Ignore dependencies between project's classes and
android.jar
- D8: Investigate root cause #2 and see why the behavior is inconsistent between
desugar_jdk_libs_nio:2.0.4
and2.1.0+
hu...@google.com <hu...@google.com> #24
- AGP: Ignore dependencies between project's classes and android.jar
We've done this in
Thanks a lot for this report and for helping us debug this issue!
Follow up
I'm closing this issue now, but it would be great if R8 team could verify the following, as it may indicate some bug in D8.
- D8: Investigate root cause #2 and see why the behavior is inconsistent between desugar_jdk_libs_nio:2.0.4 and 2.1.0+
ch...@google.com <ch...@google.com> #25
Bugjuggler: wait until 20241120 -> clementbera
an...@google.com <an...@google.com> #26
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug Feature Drop | 2024.2.2 Canary 9
- Android Gradle Plugin 8.8.0-alpha09
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
ch...@google.com <ch...@google.com> #27
I opened
pu...@gmail.com <pu...@gmail.com> #28
Confirming it is fixed in Canary 9.
However, Canary 9 introduced a new unrelated issue for me:
to...@yahoo.com <to...@yahoo.com> #29
I don't get the error described, but any source code changes are not reflected when I hit "Debug". I have to manually build first.
I added myself to the newest issue...
cl...@google.com <cl...@google.com> #30
Could you confirm whether it is possible to have a (desugaring) dependency between the project's classes and android.jar when minSdk >= 24?
That is possible when using desugared library. Most desugaring happen below 24, but some methods are desugared up to latest android.
I see java.io.InputStream#transferTo(java.io.OutputStream)
is desugared with desugared library up to android 32 so that makes sense.
to...@yahoo.com <to...@yahoo.com> #31
meerkat / agp 8.9.x and suga 2.1.3 .... seems to build again ok.
thanks!
Description
Build failure after upgrading the desugar library to 2.1.0 It works in AGP 8.4.x.