diff --git a/tools/winscope/README b/tools/winscope/README deleted file mode 100644 index f34b41376..000000000 --- a/tools/winscope/README +++ /dev/null @@ -1 +0,0 @@ -Tool for visualizing window manager traces \ No newline at end of file diff --git a/tools/winscope/README.md b/tools/winscope/README.md new file mode 100644 index 000000000..ca6c12b5d --- /dev/null +++ b/tools/winscope/README.md @@ -0,0 +1,19 @@ +# Tool for visualizing window manager traces + +## Developing WinScope +When the trace is enabled, Window Manager and Surface Flinger capture and +save current state to a file at each point of interest. +`frameworks/base/core/proto/android/server/windowmanagertrace.proto` +and `frameworks/native/services/surfaceflinger/layerproto/layerstrace.proto` +contain the proto definitions for their internal states. + +### Checking out code and setting up environment +* Install [Yarn](https://yarnpkg.com), a JS package manager +* [Download Android source](https://source.android.com/setup/build/downloading) +* Navigate to `development/tools/winscope` +* Run `yarn install` + +### Building & testing changes +* Navigate to `development/tools/winscope` +* Run `yarn run dev` + diff --git a/tools/winscope/package.json b/tools/winscope/package.json index 617f577db..da34b904c 100644 --- a/tools/winscope/package.json +++ b/tools/winscope/package.json @@ -5,8 +5,8 @@ "author": "Adrian Roos ", "private": true, "scripts": { - "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", - "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" + "dev": "cross-env AOSP=true NODE_ENV=development webpack-dev-server --open --hot", + "build": "cross-env AOSP=true NODE_ENV=production webpack --progress --hide-modules" }, "dependencies": { "vue": "^2.3.3", diff --git a/tools/winscope/src/decode.js b/tools/winscope/src/decode.js index 8d7fa78a7..9285d77f4 100644 --- a/tools/winscope/src/decode.js +++ b/tools/winscope/src/decode.js @@ -16,10 +16,10 @@ import jsonProtoDefs from 'frameworks/base/core/proto/android/server/windowmanagertrace.proto' -import jsonProtoLogDefs from 'frameworks/base/core/proto/android/server/protolog.proto' +import jsonProtoLogDefs from 'ProtoLogSafePath/protolog.proto' import jsonProtoDefsSF from 'frameworks/native/services/surfaceflinger/layerproto/layerstrace.proto' import jsonProtoDefsTrans from 'frameworks/native/cmds/surfacereplayer/proto/src/trace.proto' -import jsonProtoDefsWL from 'vendor/google_arc/libs/wayland_service/waylandtrace.proto' +import jsonProtoDefsWL from 'WaylandSafePath/waylandtrace.proto' import protobuf from 'protobufjs' import { transform_layers, transform_layers_trace } from './transform_sf.js' import { transform_window_service, transform_window_trace } from './transform_wm.js' diff --git a/tools/winscope/src/stubs/protolog.proto b/tools/winscope/src/stubs/protolog.proto new file mode 100644 index 000000000..dba82e3eb --- /dev/null +++ b/tools/winscope/src/stubs/protolog.proto @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; + +package com.android.server.protolog; + +message ProtoLogMessage {} +message ProtoLogFileProto {} \ No newline at end of file diff --git a/tools/winscope/src/stubs/services.core.protolog.json b/tools/winscope/src/stubs/services.core.protolog.json new file mode 100644 index 000000000..9eecd8f5b --- /dev/null +++ b/tools/winscope/src/stubs/services.core.protolog.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/tools/winscope/src/stubs/waylandtrace.proto b/tools/winscope/src/stubs/waylandtrace.proto new file mode 100644 index 000000000..bfe19ceed --- /dev/null +++ b/tools/winscope/src/stubs/waylandtrace.proto @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; + +package org.chromium.arc.wayland_composer; + +message TraceFileProto {} +message OutputStateProto {} \ No newline at end of file diff --git a/tools/winscope/src/transform_protolog.js b/tools/winscope/src/transform_protolog.js index 464ffda7c..78e7c3207 100644 --- a/tools/winscope/src/transform_protolog.js +++ b/tools/winscope/src/transform_protolog.js @@ -1,4 +1,20 @@ -import viewerConfig from "../../../../frameworks/base/data/etc/services.core.protolog.json" +/* + * Copyright 2020, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import viewerConfig from "ProtoLogJsonSafePath/services.core.protolog.json" import { nanos_to_string } from './transform.js' diff --git a/tools/winscope/webpack.config.js b/tools/winscope/webpack.config.js index 677391e3c..3a1b92db7 100644 --- a/tools/winscope/webpack.config.js +++ b/tools/winscope/webpack.config.js @@ -19,6 +19,29 @@ var webpack = require('webpack') var HtmlWebpackPlugin = require('html-webpack-plugin') var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin') +function getWaylandSafePath() { + if (process.env.AOSP) { + return path.resolve(__dirname, 'src/stubs'); + } + return path.resolve(__dirname, '../../../vendor/google_arc/libs/wayland_service'); +} + +// b/148409169 remove once proto log support is in AOSP. +function getProtoLogSafePath() { + if (process.env.AOSP) { + return path.resolve(__dirname, 'src/stubs'); + } + return path.resolve(__dirname, '../../../frameworks/base/core/proto/android/server'); +} + +// b/148409169 remove once proto log support is in AOSP. +function getProtoLogJsonSafePath() { + if (process.env.AOSP) { + return path.resolve(__dirname, 'src/stubs'); + } + return path.resolve(__dirname, '../../../frameworks/base/data/etc'); +} + module.exports = { entry: './src/main.js', output: { @@ -61,6 +84,11 @@ module.exports = { ] }, resolve: { + alias: { + WaylandSafePath: getWaylandSafePath(), + ProtoLogSafePath: getProtoLogSafePath(), + ProtoLogJsonSafePath: getProtoLogJsonSafePath(), + }, modules: [ 'node_modules', path.resolve(__dirname, '../../..')