AMF – Errata and other ramblings

I’ve been doing a lot of research into the AMF protocol recently. I’ve had the pleasure of reading the AMF0, and AMF3 standards cover-to-cover several times, with a view to understanding them well enough to write my own debugging tools. More about those projects another time.

Not only are the standards fairly brief, but they contain errors. I’ve not managed to find an official errata, so here’s my starter for 10.

1.3.1 Variable Length Unsigned 29-bit Integer Encoding (U29)

The standard states that the largest unsigned integer permitted is pow(2,29)-1, which would be 0x1FFFFFFF, but then goes on to state that the range of a 4 byte value goes up to 0x3FFFFFFF. This looks like a typo, unless I am missing something critical!

The AMF standard is supposed to be platform independent [ish], so it doesn’t talk about Flash [much]; but it’s worth noting that the Flash Player uses U29 for serializing signed integers, making its useful range -0x10000000 -> 0x0FFFFFFF. Flash serializes all integers outside this range as a doubles, even when the AS type is uint; because the AMF protocol does not support an unsigned data type.

I find this data type a bit pointless. It is designed cut down on redundancy, but surely this could be achieved with different integer markers, 8-bit, 16-bit, etc.. The range of the integer wouldn’t have to be restricted and it would probably deserialize faster too.

1.3.2 Strings and UTF-8

There appears to be a typo in the third paragraph which contradicts the grammar notation below. It states that a zero flag indicates a string literal, although it says below that a zero value indicates a reference. The latter seems correct and is the same convention used in other parts of the standard.

More to come …