From a45b4465264aca200a88d7e6a00262506b20263a Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Thu, 17 Mar 2022 11:03:48 +0100 Subject: [PATCH] Fix Lazy layers trace parsing in winscope Plus some uncaught exceptions in the log Bug: 211049519 Test: build winscope and open a trace Change-Id: I04f52258069667e0da6342dabbcf2d46810804d3 --- tools/winscope/src/DataInput.vue | 44 +++++++++---------- tools/winscope/src/flickerlib/common.js | 6 +-- .../flickerlib/layers/LayerTraceEntryLazy.ts | 4 +- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/tools/winscope/src/DataInput.vue b/tools/winscope/src/DataInput.vue index 57fcb9810..c4f1cf082 100644 --- a/tools/winscope/src/DataInput.vue +++ b/tools/winscope/src/DataInput.vue @@ -373,9 +373,9 @@ export default { const selectedFile = this.getMostLikelyCandidateFile(dataType, files); - const frozenData = Object.freeze(selectedFile.data); - delete selectedFile.data; - selectedFile.data = frozenData; + if (selectedFile.data) { + selectedFile.data = Object.freeze(selectedFile.data); + } this.$set(this.dataFiles, dataType, Object.freeze(selectedFile)); @@ -592,28 +592,26 @@ export default { let lastError; for (const filename in content.files) { - if (content.files.hasOwnProperty(filename)) { - const file = content.files[filename]; - if (file.dir) { - // Ignore directories - continue; + const file = content.files[filename]; + if (file.dir) { + // Ignore directories + continue; + } + + const fileBlob = await file.async('blob'); + // Get only filename and remove rest of path + fileBlob.name = filename.split('/').slice(-1).pop(); + + try { + const decodedFile = await this.decodeFile(fileBlob); + + decodedFiles.push(decodedFile); + } catch (e) { + if (!(e instanceof UndetectableFileType)) { + lastError = e; } - const fileBlob = await file.async('blob'); - // Get only filename and remove rest of path - fileBlob.name = filename.split('/').slice(-1).pop(); - - try { - const decodedFile = await this.decodeFile(fileBlob); - - decodedFiles.push(decodedFile); - } catch (e) { - if (!(e instanceof UndetectableFileType)) { - lastError = e; - } - - console.error(e); - } + console.error(e); } } diff --git a/tools/winscope/src/flickerlib/common.js b/tools/winscope/src/flickerlib/common.js index 7538d233d..cca16f464 100644 --- a/tools/winscope/src/flickerlib/common.js +++ b/tools/winscope/src/flickerlib/common.js @@ -56,8 +56,8 @@ const WindowToken = require('flicker').com.android.server.wm.traces.common. // SF const Layer = require('flicker').com.android.server.wm.traces.common. layers.Layer; -const AbstractLayerTraceEntry = require('flicker').com.android.server.wm.traces.common. - layers.AbstractLayerTraceEntry; +const BaseLayerTraceEntry = require('flicker').com.android.server.wm.traces.common. + layers.BaseLayerTraceEntry; const LayerTraceEntry = require('flicker').com.android.server.wm.traces.common. layers.LayerTraceEntry; const LayerTraceEntryBuilder = require('flicker').com.android.server.wm.traces. @@ -272,7 +272,7 @@ export { WindowManagerTrace, WindowManagerState, // SF - AbstractLayerTraceEntry, + BaseLayerTraceEntry, Layer, LayerTraceEntry, LayerTraceEntryBuilder, diff --git a/tools/winscope/src/flickerlib/layers/LayerTraceEntryLazy.ts b/tools/winscope/src/flickerlib/layers/LayerTraceEntryLazy.ts index 035cee7e1..393e97caa 100644 --- a/tools/winscope/src/flickerlib/layers/LayerTraceEntryLazy.ts +++ b/tools/winscope/src/flickerlib/layers/LayerTraceEntryLazy.ts @@ -15,10 +15,10 @@ */ -import { AbstractLayerTraceEntry } from "../common"; +import { BaseLayerTraceEntry } from "../common"; import LayerTraceEntry from "./LayerTraceEntry"; -class LayerTraceEntryLazy extends AbstractLayerTraceEntry { +class LayerTraceEntryLazy extends BaseLayerTraceEntry { private _isInitialized: boolean = false; private _layersProto: any[]; private _displayProtos: any[];