Add a workaround to prevent duplicate layers in traces

Track and skip any duplicate layers before adding it to the trace. Capture the transaction trace to disk when we detect this issue to help
identify the root cause.

CL also fixes offscreen layers to capture the layers from the hierarchy.

Flag: EXEMPT bugfix
Bug: 335383156
Test: capture active layers trace
Change-Id: If7158a19b2d090bb35af4c3a143c105b4be3d5bc
4 files changed