Status Update
Comments
vs...@google.com <vs...@google.com> #2
Hmm
I can repro on API 33 but not on API 34
vs...@google.com <vs...@google.com> #3
Can't repro with API 24 as well.
vs...@google.com <vs...@google.com> #4
Can't repro with 21 or 32. Looks like issue is specific to API 33.
no...@google.com <no...@google.com> #5
And seems to have nothing to do with ByteBuffer.
fun testCpu() {
val random = Random(Date().time)
val nanoTime = measureNanoTime {
repeat(100_000) {
sin(random.nextDouble())
}
}
Log.d("SinTest", "100_000 * sin() loop took ${TimeUnit.NANOSECONDS.toMillis(nanoTime)}ms")
}
Results in:
2023-08-02 11:32:07.506 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 9ms
2023-08-02 11:32:08.417 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 2ms
2023-08-02 11:32:09.296 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
2023-08-02 11:32:09.992 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
2023-08-02 11:32:10.720 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
---------------------------- PROCESS ENDED (9391) for package com.alonalbert.myapplication ----------------------------
---------------------------- PROCESS STARTED (9463) for package com.alonalbert.myapplication ----------------------------
2023-08-02 11:32:27.663 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 78ms
2023-08-02 11:32:28.537 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 105ms
2023-08-02 11:32:29.262 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 103ms
2023-08-02 11:32:29.887 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 104ms
2023-08-02 11:32:30.663 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 104ms
sm...@google.com <sm...@google.com> #6
I can reproduce without Android Studio in the loop at all.
Do the following on an API 33 device or emulator, then on any other API level.
$ adb install -r slow-under-debugger.apk
$ # Start the app and observe
$ adb jdwp
14051
^C
$ adb forward tcp:5005 jdwp:14051
$ jdb -attach hostname=localhost,port=5005
$ Observe the app
On a API 33 device, the execution time jumps by a factor of about 50 when it's attached to the debugger.Note that when the debugger is detached, it returns to normal.
ac...@google.com <ac...@google.com> #7
Thanks Alon! I will take a look. There are several improvements which went into Android 34 around breakpoints. Though I am not aware of any particular regression in Android 33 when compared to Android 32.
vs...@google.com <vs...@google.com> #8
Actually, we had to cherrypick a fix to Android T to address slowness when debugger is attached:
I think any T release should have that fix included. So not sure if it's the same issue. I am trying to reproduce this locally.
From the initial description looks like it is also an issue with API 32?
Reproducible on Google Pixel 3a XL API 32 and API 33 x86_64 emulator.
Description