Status Update
Comments
su...@google.com <su...@google.com> #2
Hmm
I can repro on API 33 but not on API 34
so...@gmail.com <so...@gmail.com> #3
Can't repro with API 24 as well.
su...@google.com <su...@google.com> #4
Can't repro with 21 or 32. Looks like issue is specific to API 33.
su...@google.com <su...@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
so...@gmail.com <so...@gmail.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.
so...@gmail.com <so...@gmail.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.
su...@google.com <su...@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
This problem also only manifests on certain versions of Android. For example, the bug manifests on a Nexus 6P running Oreo (8.0.0 and 8.1.0), a Pixel 2 XL running Android 9 (security patch 2019-01-05, but not the original Android 9 release on the Pixel 2 XL), and a Pixel 5 running Android 13. It does not affect a Nexus 10 running Lolipop (5.1.1).
The symptom of the problem is that some of the context action menu actions that should be displayed as icons are not displayed when the context action menu is first created, but they are displayed if the context action menu is modified after initial display.
Here is a link to a video that demonstrates the behavior:
On this device, in portrait mode, thee icons should be displayed in the context action menu (two plus overflow menu). In landscape mode, five icons should be displayed (four plus overflow menu).
The video starts in the German language. One bookmark is selected. Only two icon are shown in the context action menu. *Bug*
Two bookmarks are then selected. Three icons are then displayed. *Correct*
The second bookmark is then deselected, leaving the original bookmark selected. Three icons are displayed. *Correct*
The context action menu is then dismissed and restarted by selecting one bookmark. Two icons are displayed. *Bug*
The screen is then rotated to landscape. Five icons are displayed. *Correct*
The screen is then rotated back to portrait. Three icons are displayed. *Correct*
The screen is then rotated to landscape and the context action menu is dismissed and restarted by selecting one bookmark. Three icons are displayed. *Bug*
A second bookmark is selected and deselected. Five icons are displayed. *Correct*
The language is then changed from German to English. Bookmarks are selected and the context action menu is correctly populated in portrait and landscape, showing that the bug does not manifest if the language is English (or any other language besides German that I have tested).
This buggy behavior can be verified by using the following APK:
Open the bookmarks drawer from the options menu. Add several bookmarks. Then open the *bookmarks activity* using the top floating action menu inside the bookmarks drawer.
The context action menu is populated using this XML file:
The code that populates the context action menu is in this file: