Od 27 marca 2025 r. zalecamy używanie android-latest-release zamiast aosp-main do kompilowania i wspołtworzenia AOSP. Więcej informacji znajdziesz w artykule o zmianach w AOSP.
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Śledzenie Winscope jest częścią platformy Androida. Na tej stronie znajdziesz instrukcje pobierania, tworzenia i lokalnego uruchamiania przeglądarki śladów Winscope.
Lokalne kompilowanie Winscope
Aby skonfigurować komputer do uruchamiania narzędzia Winscope Tracer, wykonaj te czynności:
Aby zobaczyć listę dostępnych poleceń, uruchom: npm run
Utwórz wszystkie produkcyjne i testowe środowiska docelowe, korzystając z tych opcji:
npm run build:prod
Uruchom Winscope za pomocą:
npm run start
Tworzenie osobnych części
Poszczególne części Winscope możesz tworzyć oddzielnie za pomocą tych poleceń:
Polecenie
Opis
build:trace_processor
Pobiera i ponownie kompiluje najnowszą wersję Perfettotrace_processor.
build:protos
Ponownie kompiluje definicje proto.
Przeprowadzanie testów
Winscope zawiera testy jednostkowe i testy kompleksowe. Aby je uruchomić, użyj npm run
<command>:
Polecenie
Opis
test:unit:ci
Uruchamia testy jednostkowe w mniej szczegółowym formacie na potrzeby CI lub wstępnego sprawdzania.
test:unit:dev
Uruchamia testy jednostkowe w bardziej szczegółowym formacie na potrzeby
lokalnego programowania. W tym trybie śledzone są zmiany i
automatycznie ponownie uruchamiane są odpowiednie testy.
test:e2e
Uruchamia testy kompleksowe, takie jak testy protokołu
między narzędziami.
test:presubmit:quiet
Tworzy wszystkie testy jednostkowe przed przesłaniem, narzędzia do sprawdzania kodu i analizy grafów
w mniej szczegółowym formacie na potrzeby CI lub haka przed przesłaniem.
test:presubmit
Kompiluje wszystkie testy jednostkowe przed przesłaniem, narzędzia do sprawdzania kodu i analizę grafu
w bardziej szczegółowym formacie na potrzeby lokalnego
programowania.
test:all
Uruchamia wszystkie testy (jednostkowe i kompleksowe), narzędzia do sprawdzania kodu i
analizę grafu w bardziej szczegółowym formacie na potrzeby lokalnego
programowania.
Testy kompleksowe
Przed uruchomieniem testów kompleksowych musisz uruchomić narzędzie zdalne i zainstalować odpowiednią wersję sterownika Chrome. W tym fragmencie kodu polecenie
run test:e2e automatycznie instaluje sterownik Chrome.
W tabeli poniżej znajdziesz listę niezbędnych poleceń i ich opisy. Aby je uruchomić, użyj npm run command:
Polecenie
Opis
start:remote_tool_mock
Uruchamia pozorowane narzędzie zdalne do testowania protokołu między narzędziami.
install:chromedriver
Instaluje sterownik Chrome niezbędny do przeprowadzania testów kompleksowych.
Aktualizowanie mapowania @IntDef
@IntDef to adnotacja używana w Androidzie do ograniczania możliwych wartości liczby całkowitej. Winscope używa mapowania tych adnotacji, aby wyświetlać nazwę wartości zamiast liczby całkowitej.
Aby zaktualizować mapowanie @IntDef:
Skompiluj :framework-minus-apex-intdefs, aby uruchomić preprocesor adnotacji:
mp:framework-minus-apex-intdefs
Skopiuj wygenerowany plik intDefMapping.json do repozytorium prebuilts:
Prześlij zmiany w Winscope za pomocą ikony repo upload.
Inne polecenia
Oprócz funkcji kompilacji i testów skrypty Winscope zawierają inne możliwości, jak pokazano w tabeli. Aby je uruchomić, użyj npm run command:
Polecenie
Opis
format:check
Sprawdza problemy z formatowaniem kodu za pomocą narzędzia prettier.
format:fix
Sprawdza i automatycznie rozwiązuje problemy z formatowaniem kodu za pomocą prettier.
eslint:check
Sprawdza problemy z formatowaniem kodu za pomocą narzędzia eslint.
eslint:fix
Sprawdza i automatycznie rozwiązuje problemy z formatowaniem kodu za pomocą eslint.
tslint:check
Sprawdza problemy z formatowaniem kodu za pomocą narzędzia tslint.
tslint:fix
Sprawdza i automatycznie rozwiązuje problemy z formatowaniem kodu za pomocą tslint.
deps_graph:check_cycles
Analizuje kod pod kątem zależności cyklicznych.
Rozwiązywanie problemów
Aby rozwiązać problemy, skorzystaj z tych wskazówek:
Błąd ProtocolError: missing required '<FIELD>' lub TypeError: Cannot
read property '<PROP>' of null
Dzieje się tak, gdy plik śledzenia został utworzony z nową definicją protokołu zawierającą nowe wymagane pola.
Upewnij się, że otwierasz ślad w odpowiedniej wersji Winscope (master, S lub R).
Jeśli utworzysz nowe pole w pliku proto, ponownie skompiluj pliki proto w Winscope za pomocą polecenia npm run build:protos.
Niektóre zainstalowane wersje zależności są nieprawidłowe (kompilacja się nie powiodła)
Cofnij zmiany w przypadku package.json i package-lock.json. Usuń node_modules. Uruchom ponownie npm install.
W jednym z plików proto dodano nowe pole. Jak ją wyświetlić?
Winscope używa definicji protokołów z czasu kompilacji, więc nowe pola nie będą domyślnie widoczne. Aby wyświetlić nowe pola, ponownie skompiluj pliki proto za pomocą polecenia npm run build:protos.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-09-03 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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`."]]