Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2ca3078 authored by Kirill Timofeev's avatar Kirill Timofeev
Browse files

Fix Perfetto SDK instrumentation for the MessageQueue 'message_queue_send' event.

This CL eliminates the negative 'message_delay_ms' value being reported
sometimes.

The reason why the negative time value was reported is as follows: When
we send an event, the 'when' value indicates some timestamp in the
future, when it should be proceed. When we call the
'incAndTraceMessageCount' method, we use 'when -
SystemClock.uptimeMillis()' to calculate the expected delay (interval
between the when and now). If the now is not the same millisecond as
when the event was sent we got the negative delay (instead of a zero
delay).

Because of this we also sometimes report the 'message_queue_send' being
less than the expected 'delayMillis' passed to e.g
(Handler#sendMessageDelayed), but this is fine: we want to report the
actual delay in the queue, not the requested. The only thing we
absolutely don't want to do is to report the negative timestamps.

The following SQL command is used to get all the 'message_queue_send'
events with the negative 'message_delay_ms' value:
```
SELECT *
FROM slice JOIN args USING (arg_set_id)
WHERE
name = 'message_queue_send'
and flat_key == 'message_queue.message_delay_ms'
and int_value < 0;
```

Test: atest FrameworksCoreTests:PerfettoTraceTest
Bug: 303199244
Flag: android.os.perfetto_sdk_tracing_v2
Change-Id: Iba347c76898e3083861d3ea025c0e63acba662c6
parent 4caf1ac0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment