A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release anziché aosp-main per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
La traccia Winscope fa parte del framework Android. Questa pagina descrive i
passaggi necessari per scaricare, compilare ed eseguire il visualizzatore di tracce Winscope in locale.
Crea Winscope localmente
Per configurare il PC per eseguire lo strumento di tracciamento Winscope:
Per visualizzare un elenco dei comandi disponibili, esegui: npm run
Crea tutti i target di produzione e di test utilizzando:
npm run build:prod
Esegui Winscope utilizzando:
npm run start
Creare parti separate
Puoi creare singole parti di Winscope separatamente utilizzando i seguenti
comandi:
Comando
Descrizione
build:trace_processor
Estrae e ricompila l'ultima versione di trace_processor di Perfetto.
build:protos
Ricompila le definizioni proto.
Esegui test
Winscope contiene test unitari ed end-to-end. Per eseguirli, utilizza npm run
<command>:
Comando
Descrizione
test:unit:ci
Esegue i test unitari in un formato meno dettagliato per CI
o per il presubmit hook.
test:unit:dev
Esegue i test delle unità in un formato più dettagliato per
lo sviluppo locale. Questa modalità monitora le modifiche e
riesegue automaticamente i test corretti.
test:e2e
Esegue i test end-to-end, ad esempio quelli per il
protocollo cross-tool.
test:presubmit:quiet
Crea tutti i test unitari pre-invio, i linter e l'analisi del grafico
in un formato meno dettagliato per CI o hook pre-invio.
test:presubmit
Crea tutti i test unitari pre-invio, i linter e l'analisi del grafico
in un formato più dettagliato per lo sviluppo
locale.
test:all
Esegue tutti i test (unità e end-to-end), i linter e l'analisi del grafico in un formato più dettagliato per lo sviluppo locale.
Test end-to-end
Prima di eseguire i test end-to-end, devi avviare lo strumento remoto e installare la
versione corretta del driver Chrome. Nel seguente snippet di codice, il comando
run test:e2e installa automaticamente il driver di Chrome.
La tabella seguente elenca i comandi necessari e le relative descrizioni. Per eseguirli, utilizza npm run command:
Comando
Descrizione
start:remote_tool_mock
Avvia la simulazione dello strumento remoto per testare il protocollo tra strumenti.
install:chromedriver
Installa il driver di Chrome necessario per eseguire test end-to-end.
Aggiorna la mappatura @IntDef
@IntDef è un'annotazione utilizzata in Android per limitare i possibili valori di un
numero intero. Winscope utilizza una mappatura di queste annotazioni per visualizzare il nome del
valore anziché l'intero.
Per aggiornare il mapping di @IntDef:
Crea :framework-minus-apex-intdefs per l'esecuzione del preprocessor delle annotazioni:
mp:framework-minus-apex-intdefs
Copia il file intDefMapping.json generato nel repository precompilati:
Carica le modifiche in Winscope utilizzando repo upload.
Altri comandi
Oltre a build e test, gli script Winscope contengono altre funzionalità, come
mostrato nella tabella. Per eseguirli, utilizza npm run command:
Comando
Descrizione
format:check
Verifica la presenza di problemi di formattazione del codice utilizzando prettier.
format:fix
Controlla e corregge automaticamente i problemi di formattazione del codice utilizzando prettier.
eslint:check
Verifica la presenza di problemi di formattazione del codice utilizzando eslint.
eslint:fix
Controlla e corregge automaticamente i problemi di formattazione del codice utilizzando eslint.
tslint:check
Verifica la presenza di problemi di formattazione del codice utilizzando tslint.
tslint:fix
Controlla e corregge automaticamente i problemi di formattazione del codice utilizzando tslint.
deps_graph:check_cycles
Analizza il codice per rilevare dipendenze cicliche.
Risoluzione dei problemi
Per la risoluzione dei problemi, segui questi suggerimenti:
Errore ProtocolError: missing required '<FIELD>' o TypeError: Cannot
read property '<PROP>' of null
Ciò si verifica quando il file di traccia è stato creato con una nuova definizione proto,
contenente nuovi campi obbligatori.
Assicurati di aprire la traccia nella versione corretta di Winscope
(master, S o R).
Se crei il nuovo campo nel proto, ricompila i proto in
Winscope utilizzando npm run build:protos.
Alcune versioni delle dipendenze installate non sono corrette (la build non riesce)
Ripristina le modifiche a package.json e package-lock.json. Rimuovi
node_modules. Esegui di nuovo npm install.
Ho aggiunto un nuovo campo a uno dei file proto. Come faccio a visualizzarlo?
Winscope utilizza le definizioni proto del momento della compilazione, quindi i nuovi
campi non vengono visualizzati per impostazione predefinita. Per visualizzare i nuovi campi, ricompila i proto
utilizzando npm run build:protos.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-09-03 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-03 UTC."],[],[],null,["Winscope tracing is part of the Android framework. This page outlines the\nsteps required to download, build, and run the Winscope trace viewer locally.\n\nBuild Winscope locally\n\nFollow these steps to set up your PC to run the Winscope tracer:\n\n1. [Download the Android source](/docs/setup/build/building).\n2. Navigate to the Winscope folder:\n\n cd development/tools/winscope\n\n3. Install dependencies using:\n\n npm install\n\n To see a list of available commands, run: `npm run`\n4. Build all prod and test targets using:\n\n npm run build:prod\n\n5. Run Winscope using:\n\n npm run start\n\n| **Note:** You can also download and build Winscope to host on a standard web server to get a shareable link to the tool.\n\nBuild separate parts\n\nYou can build individual parts of Winscope separately using the following\ncommands:\n\n| Command | Description |\n|-------------------------|-----------------------------------------------------------------------------|\n| `build:trace_processor` | Checks out and rebuilds the latest version of Perfetto's `trace_processor`. |\n| `build:protos` | Recompiles the proto definitions. |\n\nRun tests **Tip:** Winscope doesn't build on Soong and can't be built by Tradefed, so it's recommended to have a local Git hook to the tests in your local environment.\n\nWinscope contains unit and end-to-end tests. To run them use `npm run\n\u003ccommand\u003e`:\n\n| Command | Description |\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `test:unit:ci` | Runs the unit tests in a less verbose format for CI or presubmit hook. |\n| `test:unit:dev` | Runs the unit tests in a more verbose format for local development. This mode watches for changes and automatically reruns the correct tests. |\n| `test:e2e` | Runs the end-to-end tests, such as those for the cross-tool protocol. |\n| `test:presubmit:quiet` | Builds all presubmit unit tests, linters, and graph analysis in a less verbose format for CI or presubmit hook. |\n| `test:presubmit` | Builds all presubmit unit tests, linters, and graph analysis in a more verbose format for local development. |\n| `test:all` | Runs all tests (unit and end-to-end), linters, and graph analysis in a more verbose format for local development. |\n\nEnd-to-end tests\n\nBefore running end-to-end tests, you must start the remote tool and install the\ncorrect version of the Chrome driver. In the following code snippet, the\n`run test:e2e` command automatically installs the Chrome driver. \n\n $ npm run start\n $ npm run start:remote_tool_mock\n $ npm run test:e2e\n\nThe following table lists the necessary commands and their descriptions. To run\nthem use `npm run `\u003cvar translate=\"no\"\u003ecommand\u003c/var\u003e:\n\n| Command | Description |\n|--------------------------|---------------------------------------------------------------|\n| `start:remote_tool_mock` | Starts the remote tool mock for testing cross tool protocol. |\n| `install:chromedriver` | Installs the Chrome driver necessary to run end-to-end tests. |\n\nUpdate @IntDef mapping\n\n`@IntDef` is an annotation used in Android to restrict the possible values of an\ninteger. Winscope uses a mapping of these annotations to display the name of the\nvalue instead of the integer.\n\nTo update the `@IntDef` mapping, do the following:\n\n1. Build `:framework-minus-apex-intdefs` for the annotation preprocessor to run:\n\n mp :framework-minus-apex-intdefs\n\n2. Copy the generated `intDefMapping.json` file to the prebuilts repository:\n\n $ python3 -c 'import sys,json,collections; print(json.dumps(collections.OrderedDict(sorted(collections.ChainMap(*map(lambda x:json.load(open(x)), sys.argv[1:])).items())), indent=2))' $(find out/soong/.intermediates/frameworks/base -iname intDefMapping.json) \u003e ./development/tools/winscope/src/common/intDefMapping.json\n\n3. Upload the changes in Winscope using `repo upload`.\n\nOther commands\n\nIn addition to build and tests, Winscope scripts contain other capabilities, as\nshown in the table. To run them use `npm run `\u003cvar translate=\"no\"\u003ecommand\u003c/var\u003e:\n\n| Command | Description |\n|---------------------------|----------------------------------------------------------------|\n| `format:check` | Checks for code formatting issues using `prettier`. |\n| `format:fix` | Checks and auto fixes code formatting issues using `prettier`. |\n| `eslint:check` | Checks for code formatting issues using `eslint`. |\n| `eslint:fix` | Checks and auto fixes code formatting issues using `eslint`. |\n| `tslint:check` | Checks for code formatting issues using `tslint`. |\n| `tslint:fix` | Checks and auto fixes code formatting issues using `tslint`. |\n| `deps_graph:check_cycles` | Analyzes the code for cyclical dependencies. |\n\nTroubleshoot\n\nUse the following tips for troubleshooting:\n\n- **Error `ProtocolError: missing required '\u003cFIELD\u003e'` or `TypeError: Cannot\n read property '\u003cPROP\u003e' of null`**\n\n - This occurs when the trace file was created with a new proto definition,\n containing new *required* fields.\n\n 1. Make sure you're opening the trace on the correct Winscope version (master, S, or R).\n 2. If you create the new field on the proto, recompile the protos in\n Winscope using `npm run build:protos`.\n\n | **Note:** You shouldn't need a new required field, because the protos should be backward compatible.\n- **Some installed dependency versions are wrong (build fails)**\n\n - Revert changes to `package.json` and `package-lock.json`. Remove `node_modules`. Run `npm install` again.\n- **I added a new field to one of the proto files. How do I display it?**\n\n - Winscope uses the proto definitions from when it was compiled, so new fields won't appear by default. To show new fields, rebuild the protos using `npm run build:protos`."]]