Ab dem 27. März 2025 empfehlen wir, android-latest-release anstelle von aosp-main zu verwenden, um AOSP zu erstellen und Beiträge dazu zu leisten. Weitere Informationen finden Sie unter Änderungen am AOSP.
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Winscope-Tracing ist Teil des Android-Frameworks. Auf dieser Seite wird beschrieben, wie Sie den Winscope-Trace-Viewer lokal herunterladen, erstellen und ausführen.
Winscope lokal erstellen
So richten Sie Ihren PC für die Ausführung des Winscope-Tracers ein:
Installieren Sie die Abhängigkeiten mit folgendem Befehl:
npm install
Führen Sie den folgenden Befehl aus, um eine Liste der verfügbaren Befehle aufzurufen: npm run
Erstellen Sie alle Produktions- und Testziele mit folgendem Befehl:
npm run build:prod
Führen Sie Winscope mit folgendem Befehl aus:
npm run start
Separate Teile erstellen
Mit den folgenden Befehlen können Sie einzelne Teile von Winscope separat erstellen:
Befehl
Beschreibung
build:trace_processor
Checkt die neueste Version von Perfettotrace_processoraus und erstellt sie neu.
build:protos
Kompiliert die Proto-Definitionen neu.
Tests ausführen
Winscope enthält Unit- und End-to-End-Tests. Verwenden Sie npm run
<command>, um sie auszuführen:
Befehl
Beschreibung
test:unit:ci
Führt die Einheitentests in einem weniger ausführlichen Format für CI oder den Vorabtest-Hook aus.
test:unit:dev
Führt die Einheitentests in einem ausführlicheren Format für die lokale Entwicklung aus. In diesem Modus wird auf Änderungen gewartet und
die richtigen Tests werden automatisch noch einmal ausgeführt.
test:e2e
Führt die End-to-End-Tests aus, z. B. für das -Protokoll für die toolübergreifende Zusammenarbeit.
test:presubmit:quiet
Erstellt alle Vorabtest-Unit-Tests, Linter und die Graph -Analyse in einem weniger ausführlichen Format für CI- oder Vorabtest- -Hooks.
test:presubmit
Erstellt alle Presubmit-Einheitentests, Linter und die Graph -Analyse in einem ausführlicheren Format für die lokale -Entwicklung.
test:all
Führt alle Tests (Unit- und End-to-End-Tests), Linter und die -Grafikanalyse in einem ausführlicheren Format für die lokale -Entwicklung aus.
End-to-End-Tests
Bevor Sie End-to-End-Tests ausführen, müssen Sie das Remote-Tool starten und die richtige Version des Chrome-Treibers installieren. Im folgenden Code-Snippet wird der Chrome-Treiber mit dem Befehl run test:e2e automatisch installiert.
In der folgenden Tabelle sind die erforderlichen Befehle und ihre Beschreibungen aufgeführt. So führen Sie sie mit npm run command aus:
Befehl
Beschreibung
start:remote_tool_mock
Startet den Mock für das Remote-Tool zum Testen des Tool-übergreifenden Protokolls.
install:chromedriver
Installiert den Chrome-Treiber, der zum Ausführen von End-to-End-Tests erforderlich ist.
@IntDef-Zuordnung aktualisieren
@IntDef ist eine Annotation, die in Android verwendet wird, um die möglichen Werte einer Ganzzahl einzuschränken. Winscope verwendet eine Zuordnung dieser Anmerkungen, um anstelle der Ganzzahl den Namen des Werts anzuzeigen.
So aktualisieren Sie die @IntDef-Zuordnung:
Erstellen Sie :framework-minus-apex-intdefs, damit der Annotations-Vorprozessor ausgeführt werden kann:
mp:framework-minus-apex-intdefs
Kopieren Sie die generierte Datei intDefMapping.json in das Prebuilts-Repository:
Laden Sie die Änderungen in Winscope mit repo upload hoch.
Weitere Befehle
Neben Build- und Testfunktionen enthalten Winscope-Skripts auch andere Funktionen, wie in der Tabelle dargestellt. Verwenden Sie npm run command, um sie auszuführen:
Befehl
Beschreibung
format:check
Prüft mit prettier auf Probleme bei der Codeformatierung.
format:fix
Überprüft und behebt Probleme mit der Codeformatierung mithilfe von prettier automatisch.
eslint:check
Prüft mit eslint auf Probleme bei der Codeformatierung.
eslint:fix
Überprüft und behebt Probleme mit der Codeformatierung mithilfe von eslint automatisch.
tslint:check
Prüft mit tslint auf Probleme bei der Codeformatierung.
tslint:fix
Überprüft und behebt Probleme mit der Codeformatierung mithilfe von tslint automatisch.
deps_graph:check_cycles
Analysiert den Code auf zyklische Abhängigkeiten.
Fehlerbehebung
Folgende Tipps können bei der Fehlerbehebung hilfreich sein:
Fehler ProtocolError: missing required '<FIELD>' oder TypeError: Cannot
read property '<PROP>' of null
Dieser Fehler tritt auf, wenn die Tracedatei mit einer neuen Proto-Definition erstellt wurde, die neue erforderliche Felder enthält.
Achten Sie darauf, dass Sie den Trace in der richtigen Winscope-Version (Master, S oder R) öffnen.
Wenn Sie das neue Feld im Proto erstellen, kompilieren Sie die Protos in Winscope mit npm run build:protos neu.
Einige installierte Abhängigkeitsversionen sind falsch (Build schlägt fehl)
Machen Sie die Änderungen an package.json und package-lock.json rückgängig. Entfernen Sie node_modules. Führen Sie npm install noch einmal aus.
Ich habe einer der Proto-Dateien ein neues Feld hinzugefügt. Wie wird sie angezeigt?
Winscope verwendet die Proto-Definitionen aus der Kompilierungszeit. Neue Felder werden daher nicht standardmäßig angezeigt. Wenn Sie neue Felder anzeigen möchten, erstellen Sie die Protos mit npm run build:protos neu.
Alle Inhalte und Codebeispiele auf dieser Seite unterliegen den Lizenzen wie im Abschnitt Inhaltslizenz beschrieben. Java und OpenJDK sind Marken oder eingetragene Marken von Oracle und/oder seinen Tochtergesellschaften.
Zuletzt aktualisiert: 2025-09-03 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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`."]]