Fixed
Status Update
Comments
ha...@google.com <ha...@google.com>
jh...@gmail.com <jh...@gmail.com> #2
Correction:
So, the end result is that usb_write() sometimes sends a ZLP when it doesn't need to
should be
So, the end result is that usb_write() sometimes sends a ZLP when it doesn't need to, and sometimes neglects to send a ZLP when it should
So, the end result is that usb_write() sometimes sends a ZLP when it doesn't need to
should be
So, the end result is that usb_write() sometimes sends a ZLP when it doesn't need to, and sometimes neglects to send a ZLP when it should
aa...@google.com <aa...@google.com> #3
Note that the CHECK_LE has since been replaced with HandleError(), which causes adbd to not abort...but that stowaway amessage header is being dropped all the same...and so the behavior is pretty much undefined, I imagine. I'm not sure the switch to HandleError was a good idea, since it more or less swept the real problem under the rug.
ry...@idrnd.net <ry...@idrnd.net> #4
good bug report, thanks! i'm assuming this isn't darwin-specific either --- it looks like we have similar logic using masks in the linux and windows backends and in the libusb backend too.
I'm not sure the switch to HandleError was a good idea, since it more or less swept the real problem under the rug.
yeah, i know what you mean, but it's also hard to argue with this logic in the commit message that made that change:
These CHECKs are expected to happen if the client does the wrong thing,
so we probably shouldn't be aborting in adbd.
a CHECK in the client (as you suggested earlier) would probably have been the best idea... postel's law and all that :-)
aa...@google.com <aa...@google.com> #5
Thanks for the quick response.
Indeed, I see similar logic in usb_write() in usb_linux. maxPacketSize is 512 (a power of 2) on my Ubuntu environment, so all good there as far as runtime behavior. It sure is odd that on macOS it's 5120, which happens to be exactly 10x the linux value. Seem suspicious, doesn't it?
Yeah, on the CHECK thing... I guess I see the client and server as a closed system in that the code is developed and distributed together. That said, obviously anyone can write their own adb client/server, so in that respect, I agree with the disagreement :-)
Indeed, I see similar logic in usb_write() in usb_linux. maxPacketSize is 512 (a power of 2) on my Ubuntu environment, so all good there as far as runtime behavior. It sure is odd that on macOS it's 5120, which happens to be exactly 10x the linux value. Seem suspicious, doesn't it?
Yeah, on the CHECK thing... I guess I see the client and server as a closed system in that the code is developed and distributed together. That said, obviously anyone can write their own adb client/server, so in that respect, I agree with the disagreement :-)
aa...@google.com <aa...@google.com> #6
We've been discussing it here some more and we have a theory:
5120 is likely not really the maxPacketSize on our Macs. It's probably 512. And a burst is probably 10 packets.
Note that usb_osx.cpp calculates the maxPacketSize as follows
if (maxBurst != 0)
// bMaxBurst is the number of additional packets in the burst.
maxPacketSize /= (maxBurst + 1);
If the theory about packet size truly being 512 is correct, then it means the real bug is in GetPipePropertiesV2() returning zero for maxBurst instead of 9. If it returned 9, then maxPacketSize would be 512 (again, a power of 2), and the zero_mask expression would work out just fine. All situations where we've had our adbd abort because of the unexpected stowaway amessage header in a packet are ones where the sent buffer are an integer multiple of 512. None are an integer multiple of 5120.
Still there's no denying that the unchecked assumption of maxPacketSize being a power of 2 is a bug. Changing the code to use modulus operation instead of a bit-mask check would be technically more correct, but wouldn't fix the broken behavior in our case, since ultimately, it appears the maxPacketSize adb is getting is wrong. But if you had an assert in the client/server on macPacketSize being a power of 2, then that would at least have brought the incorrect maxPacketSize issue front and center.
5120 is likely not really the maxPacketSize on our Macs. It's probably 512. And a burst is probably 10 packets.
Note that usb_osx.cpp calculates the maxPacketSize as follows
if (maxBurst != 0)
// bMaxBurst is the number of additional packets in the burst.
maxPacketSize /= (maxBurst + 1);
If the theory about packet size truly being 512 is correct, then it means the real bug is in GetPipePropertiesV2() returning zero for maxBurst instead of 9. If it returned 9, then maxPacketSize would be 512 (again, a power of 2), and the zero_mask expression would work out just fine. All situations where we've had our adbd abort because of the unexpected stowaway amessage header in a packet are ones where the sent buffer are an integer multiple of 512. None are an integer multiple of 5120.
Still there's no denying that the unchecked assumption of maxPacketSize being a power of 2 is a bug. Changing the code to use modulus operation instead of a bit-mask check would be technically more correct, but wouldn't fix the broken behavior in our case, since ultimately, it appears the maxPacketSize adb is getting is wrong. But if you had an assert in the client/server on macPacketSize being a power of 2, then that would at least have brought the incorrect maxPacketSize issue front and center.
an...@google.com <an...@google.com> #7
Finally, I forced my macOS server to use 512 for maxPacketSize instead of the suspicious (and almost certainly wrong) 5120...and the daemon no longer aborts because it eventually receives a stowaway amessage header in UsbFfsConnection::ProcessRead(). This gives further credence to our theory that the root cause of our problem is that the macOS adb server isn't querying/calculating the max packet size correctly, at least on our MacBook Pros with Big Sur on them.
Description
1. Describe the bug or issue that you're seeing.
Font size in a logcat becomes is too big in comparison with the previous version of Android Studio. I didn't change the settings, so it looks strange. I've tried to change the font size in the settings but in the same time the font size in a code editor is changed which is undesirable behaviour.
3. If you know what they are, write the steps to reproduce:
3A. Open any project in Android Studio.
3B. Connect any device/emulator.
3C. Open a Logcat window
3D. Visually compare a font size with a font size in a code editor
Build: AI-251.23774.16.2511.13244498, 202503200826
AS: Narwhal | 2025.1.1 Canary 2
AI-251.23774.16.2511.13244498, JRE 21.0.6+-13119726-b895.91x64 JetBrains s.r.o., OS Mac OS X(aarch64) v15.3.2, screens 2704x1756 (200%), 2560x1440 (100%)
Android Gradle Plugin: 8.3.1
Gradle: 8.4
Gradle JDK: JetBrains Runtime 21.0.6 - aarch64
NDK: from local.properties: (not specified), latest from SDK: 27.2.12479018
CMake: from local.properties: (not specified), latest from SDK: 3.31.1-g0a10cd6, from PATH: 3.25.3
```