perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

Difference in behavior of --txt vs binary trace config parsing for unknown fields

Open sashwinbalaji opened this issue 7 months ago • 4 comments

They behave differently when the config references a field we don't know about:

--txt: hard-fails as:

error: No field named "experimental_mode" in proto BufferConfig
experimental_mode: TRACE_BUFFER_V2
^~~~~~~~~~~~~~~~~
[008.272] perfetto_cmd.cc:683 The trace config is invalid, bailing out.  

Binary config: parses fine. The unknown field is silently dropped and we use the default value if any.

Should we log a warning when we drop unknown tag numbers ?

sashwinbalaji avatar Apr 20 '26 10:04 sashwinbalaji

This is WAI and intended to prevent silent issues when people use incompatible in txt mode (as txt was always designed for non human use)

If we want to fix this, we should land something like https://github.com/google/perfetto/pull/4043 with a new flag instead.

LalitMaganti avatar Apr 20 '26 10:04 LalitMaganti

Ahh yes, thanks I vaguely remembered there was some PR. Tagging it as fixit

sashwinbalaji avatar Apr 20 '26 10:04 sashwinbalaji

i'm very torn on what's the right thing to do longer term for --txt. On one hand this is going to cause breakages along the way, which would go silent if we used proto binary instead. OTOH just silently swallowing errors can hide other problems (typos etc)

A few thoughs for a fixit:

Thought #1) for --txt, we could maintain a set of "deprecated" fields, so in future if we remove experimental_mode, and somebody still set it, we can safely go "yeah this was not wrong, but it's useless, so we don't break you". Same for renames (altough going forward we should just avoid them). We'd have to remember to maintain this list updated as we deprecate fields but with some AI we could do it.

Thought #2) even in the case of proto we could keep track - and report in the trace - about unknown fields in the config. I would do nothing about them, but expose the, in the overview page and in TP for future debugging (without making them analysis erorrs or anything)

I'm more lukewarm on #2, maybe #1 has more merits

primiano avatar Apr 20 '26 13:04 primiano

#4043 landed, we now have --txt-lossy for human convenience.

rsavitski avatar Jul 13 '26 17:07 rsavitski