Merge "Add displays to layers trace"

This commit is contained in:
Nataniel Borges
2021-08-27 11:24:12 +00:00
committed by Android (Google) Code Review
5 changed files with 66 additions and 26 deletions

View File

@@ -306,7 +306,7 @@ const FILE_DECODERS = {
decoder: protoDecoder,
decoderParams: {
type: FILE_TYPES.ACCESSIBILITY_TRACE,
protoType: AccessibilityTraceMessage,
objTypeProto: AccessibilityTraceMessage,
transform: transform_accessibility_trace,
timeline: true,
},
@@ -316,7 +316,7 @@ const FILE_DECODERS = {
decoder: protoDecoder,
decoderParams: {
type: FILE_TYPES.WINDOW_MANAGER_TRACE,
protoType: WmTraceMessage,
objTypeProto: WmTraceMessage,
transform: WindowManagerTrace.fromProto,
timeline: true,
},
@@ -327,7 +327,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.SURFACE_FLINGER_TRACE,
mime: 'application/octet-stream',
protoType: SfTraceMessage,
objTypeProto: SfTraceMessage,
transform: SurfaceFlingerTrace.fromProto,
timeline: true,
},
@@ -338,7 +338,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.WAYLAND_TRACE,
mime: 'application/octet-stream',
protoType: WaylandTraceMessage,
objTypeProto: WaylandTraceMessage,
transform: transform_wayland_trace,
timeline: true,
},
@@ -349,8 +349,8 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.SURFACE_FLINGER_DUMP,
mime: 'application/octet-stream',
protoType: SfDumpMessage,
transform: SurfaceFlingerDump.fromProto,
objTypeProto: [SfDumpMessage, SfTraceMessage],
transform: [SurfaceFlingerDump.fromProto, SurfaceFlingerTrace.fromProto],
timeline: true,
},
},
@@ -360,7 +360,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.WINDOW_MANAGER_DUMP,
mime: 'application/octet-stream',
protoType: WmDumpMessage,
objTypeProto: WmDumpMessage,
transform: WindowManagerDump.fromProto,
timeline: true,
},
@@ -371,7 +371,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.WAYLAND_DUMP,
mime: 'application/octet-stream',
protoType: WaylandDumpMessage,
objTypeProto: WaylandDumpMessage,
transform: transform_wl_outputstate,
timeline: true,
},
@@ -391,7 +391,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.TRANSACTIONS_TRACE,
mime: 'application/octet-stream',
protoType: SfTransactionTraceMessage,
objTypeProto: SfTransactionTraceMessage,
transform: transform_transaction_trace,
timeline: true,
},
@@ -402,7 +402,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.PROTO_LOG,
mime: 'application/octet-stream',
protoType: ProtoLogMessage,
objTypeProto: ProtoLogMessage,
transform: transformProtolog,
timeline: true,
},
@@ -413,7 +413,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.SYSTEM_UI,
mime: 'application/octet-stream',
protoType: SystemUiTraceMessage,
objTypeProto: SystemUiTraceMessage,
transform: transform_sysui_trace,
timeline: true,
},
@@ -424,7 +424,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.LAUNCHER,
mime: 'application/octet-stream',
protoType: LauncherTraceMessage,
objTypeProto: LauncherTraceMessage,
transform: transform_launcher_trace,
timeline: true,
},
@@ -435,7 +435,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.IME_TRACE_CLIENTS,
mime: 'application/octet-stream',
protoType: InputMethodClientsTraceMessage,
objTypeProto: InputMethodClientsTraceMessage,
transform: transform_ime_trace_clients,
timeline: true,
},
@@ -446,7 +446,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.IME_TRACE_SERVICE,
mime: 'application/octet-stream',
protoType: InputMethodServiceTraceMessage,
objTypeProto: InputMethodServiceTraceMessage,
transform: transform_ime_trace_service,
timeline: true,
},
@@ -457,7 +457,7 @@ const FILE_DECODERS = {
decoderParams: {
type: FILE_TYPES.IME_TRACE_MANAGERSERVICE,
mime: 'application/octet-stream',
protoType: InputMethodManagerServiceTraceMessage,
objTypeProto: InputMethodManagerServiceTraceMessage,
transform: transform_ime_trace_managerservice,
timeline: true,
},
@@ -467,7 +467,7 @@ const FILE_DECODERS = {
decoder: protoDecoder,
decoderParams: {
type: FILE_TYPES.TAG_TRACE,
protoType: TagTraceMessage,
objTypeProto: TagTraceMessage,
transform: TagTrace.fromProto,
timeline: true,
},
@@ -477,7 +477,7 @@ const FILE_DECODERS = {
decoder: protoDecoder,
decoderParams: {
type: FILE_TYPES.ERROR_TRACE,
protoType: ErrorTraceMessage,
objTypeProto: ErrorTraceMessage,
transform: ErrorTrace.fromProto,
timeline: true,
},
@@ -523,11 +523,33 @@ function modifyProtoFields(protoObj, displayDefaults) {
}
function decodeAndTransformProto(buffer, params, displayDefaults) {
const decoded = params.protoType.decode(buffer);
modifyProtoFields(decoded, displayDefaults);
const transformed = params.transform(decoded);
return transformed;
var objTypesProto = [];
var transforms = [];
if (!Array.isArray(params.objTypeProto)) {
objTypesProto = [params.objTypeProto];
transforms = [params.transform];
} else {
objTypesProto = params.objTypeProto;
transforms = params.transform;
}
// each trace or dump may have different processors, for example, until S, SF dumps
// returne a list of layers and winscope built a [LayerTraceEntry] from them.
// From S onwards, returns a LayerTrace object, iterating over multiple items allows
// winscope to handle both the new and legacy formats
// TODO Refactor the decode.js code into a set of decoders to clean up the code
for (var x = 0; x < objTypesProto.length; x++) {
const objType = objTypesProto[x];
const transform = transforms[x];
try {
const decoded = objType.decode(buffer);
modifyProtoFields(decoded, displayDefaults);
const transformed = transform(decoded);
return transformed;
} catch (e) {
// check next parser
}
}
throw new UndetectableFileType('Unable to parse file');
}
function protoDecoder(buffer, params, fileName, store) {

View File

@@ -36,7 +36,8 @@ export default class SurfaceFlinger extends DumpBase {
static fromProto(proto: any): LayersTrace {
const source = null;
const entry = LayersTraceEntry.fromProto(
/*protos */ proto.layers,
/* protos */ proto.layers,
/* displays */ proto.displays,
/* timestamp */ 0,
/* hwcBlob */ ""
);

View File

@@ -22,6 +22,7 @@ LayersTrace.fromProto = function (proto: any): LayersTrace {
for (const entryProto of proto.entry) {
const transformedEntry = LayerTraceEntry.fromProto(
/* protos */ entryProto.layers.layers,
/* displays */ entryProto.displays,
/* timestamp */ entryProto.elapsedRealtimeNanos,
/* hwcBlob */ entryProto.hwcBlob);

View File

@@ -66,6 +66,8 @@ const Matrix = require('flicker').com.android.server.wm.traces.common.layers.
Transform.Matrix;
const Transform = require('flicker').com.android.server.wm.traces.common.
layers.Transform;
const Display = require('flicker').com.android.server.wm.traces.common.
layers.Display;
// Common
const Size = require('flicker').com.android.server.wm.traces.common.Size;
@@ -236,6 +238,7 @@ export {
LayersTrace,
Transform,
Matrix,
Display,
// Tags
Tag,
TagState,

View File

@@ -14,13 +14,15 @@
* limitations under the License.
*/
import { LayerTraceEntry, LayerTraceEntryBuilder } from "../common"
import { Display, LayerTraceEntry, LayerTraceEntryBuilder, toRect, toSize, toTransform } from "../common"
import Layer from './Layer'
import { VISIBLE_CHIP, RELATIVE_Z_PARENT_CHIP, MISSING_LAYER } from '../treeview/Chips'
LayerTraceEntry.fromProto = function (protos: any[], timestamp: number, hwcBlob: string, where: string = ''): LayerTraceEntry {
LayerTraceEntry.fromProto = function (protos: any[], displayProtos: any[],
timestamp: number, hwcBlob: string, where: string = ''): LayerTraceEntry {
const layers = protos.map(it => Layer.fromProto(it));
const builder = new LayerTraceEntryBuilder(timestamp, layers, hwcBlob, where);
const displays = (displayProtos || []).map(it => newDisplay(it));
const builder = new LayerTraceEntryBuilder(timestamp, layers, displays, hwcBlob, where);
const entry: LayerTraceEntry = builder.build();
updateChildren(entry);
@@ -63,4 +65,15 @@ function updateChildren(entry: LayerTraceEntry) {
});
}
function newDisplay(proto: any): Display {
return new Display(
proto.id,
proto.name,
proto.layerStack,
toSize(proto.size),
toRect(proto.layerStackSpaceRect),
toTransform(proto.transform)
)
}
export default LayerTraceEntry;