Android: am instrument proto test result architecture review

Anton Malinskiy
5 min readJan 13, 2021

I don’t know how code review is implemented in Google for the changes (f0c7198 and 50307d9) that will be reviewed here. I also can’t see the issue tracker for the particular problem that was being fixed. But since I’m affected by this change, I can only make this a public thing and hope for the best. If you don’t like to discuss or know about problems, read no further.

Disclaimer: I am in no way attacking Google or its employees. Everything expressed below are my personal opinions.

How it started

Working closely with the ddmlib project, I’ve noticed that the test status reported that had been used for years is now deprecated.

I was excited (at first). Finally, there is a proper format that can be easily parsed and has a known structure.

Problem #1

If you look at the proto definition, everything looks fine, until you start working with it. The first problem is that the Session and everything else is written to the stdout directly.

This means that you never know how much data you need to parse the message on the client's side. This leads to the following on the ddmlib’s side:

As you can imagine, throwing and catching the exception is not a cheap operation. Why does this happen? Because protobuf is not enough on its own. The fragmentation of a byte stream can happen on the transport layer (USB/TCPIP), and the Session instance can be fragmented into several packets. This is a known problem, and the solution to this is the framing of the packets. The simplest way of implementing framing is to send a fixed number of bytes to indicate the packet's length and then send the actual packet (as mentioned in the docs)…

--

--

Anton Malinskiy

Software engineer & IT conference speaker; Landscape photographer + occasional portraits; Music teacher: piano guitar violin; Bike traveller, gymkhana