Skip to content

Commit f50e479

Browse files
MediaPipe Teamcopybara-github
authored andcommitted
Adds documentation about graph runtime monitoring.
PiperOrigin-RevId: 731907001
1 parent 0d7edd9 commit f50e479

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/getting_started/troubleshooting.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ If some calculators or streams cannot reach state [`Timestamp::Done`] or
234234
called to terminate the graph run without waiting for all pending calculators
235235
and packets to complete.
236236

237+
To understand why a graph hangs/stalls,
238+
[graph runtime monitoring](#graph-runtime-monitoring) can provide valuable
239+
insights into input stream packet queues (understand where packets are queued up
240+
in the MediaPipe graph). This information reveals which calculators are waiting
241+
on their input queues for additional input before triggering their next
242+
Calculator::Process call.
243+
244+
For the specific monitoring of timestamp settlements of a specific calculator in
245+
your MediaPipe graph,
246+
[DebugInputStreamHandler](#monitor-calculator-inputs-and-timestamp-settlements)
247+
can be your friend.
248+
237249
## Output timing is uneven
238250

239251
Some realtime MediaPipe graphs produce a series of video frames for viewing as a
@@ -323,6 +335,62 @@ set for timestamp 1. In this case, the `DefaultInputStreamHandler` outputs:
323335
[INFO] SomeCalculator: Filled input set at ts: 1 with MISSING packets in input streams: INPUT_B:0:input_b.
324336
```
325337

338+
## Graph runtime monitoring
339+
340+
Graph runtime monitoring can be a helpful tool to debug stalled MediaPipe
341+
graphs. It utilizes a background thread to periodically capture a "snapshot" of
342+
the graph's calculators and input/output streams state at predetermined
343+
intervals.
344+
345+
The output begins by listing the calculators that are currently running
346+
(Calculator::Process runs),
347+
348+
```
349+
Running calculators: PacketClonerCalculator, RectTransformationCalculator
350+
```
351+
352+
followed by an overview of packets that are currently in flight, as well as
353+
those waiting in calculator input streams/queues to be processed.
354+
355+
```
356+
Running calculators: PacketClonerCalculator
357+
Num packets in input queues: 4
358+
GateCalculator_2 waiting on stream(s): :1:norm_start_rect
359+
MergeCalculator waiting on stream(s): :0:output_frames_gpu_ao, :1:segmentation_preview_gpu
360+
```
361+
362+
The monitoring output continues with a detailed overview of all calculator
363+
states, including timestamp bounds, time of last activity, and statistics about
364+
their input and output streams.
365+
366+
```
367+
PreviousLoopbackCalculator: (idle for 8.17s, ts bound : 0)
368+
Input streams:
369+
* LOOP:0:segmentation_finished - queue size: 0, total added: 0, ts bound: 569604400011
370+
* MAIN:0:input_frames_gpu - queue size: 0, total added: 2, ts bound: 569604400011
371+
Output streams:
372+
* PREV_LOOP:0:prev_segmentation_finished, total added: 0, ts bound: 569604400011
373+
```
374+
375+
Graph runtime monitoring can be enabled with the flag
376+
`enable_graph_runtime_info`. This enables the background capturing of graph
377+
runtime monitoring which is written to LOG(INFO).
378+
379+
```
380+
graph {
381+
runtime_info {
382+
enable_graph_runtime_info: true
383+
}
384+
...
385+
}
386+
```
387+
388+
Since adb logging might be throttled for larger graph runtime information, as an
389+
alternative, its output can be written to a file at the specified capture
390+
interval. This will overwrite the file each time. To enable this, use the flag
391+
`mp_graph_runtime_info_output_file`. Note: On Android, the output file may need
392+
to be created first to avoid permission issues.
393+
326394
## VLOG is your friend
327395

328396
MediaPipe uses `VLOG` in many places to log important events for debugging

0 commit comments

Comments
 (0)