-
Notifications
You must be signed in to change notification settings - Fork 1
update perf monitor #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
update perf monitor #836
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@viamrobotics/motion-tools': patch | ||
| --- | ||
|
|
||
| Fix perf monitor in embedded environments with blocking CSPs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| name: verify | ||
| description: Build, launch, and drive the visualizer to verify a change end-to-end at its rendered surface. | ||
| --- | ||
|
|
||
| # Verify a change in the running visualizer | ||
|
|
||
| ## Build + launch | ||
|
|
||
| ```bash | ||
| pnpm run up # wireit: vite-build + go-build, then bun static server (5173) + draw-server (3030) | ||
| ``` | ||
|
|
||
| - **Never invoke it as bare `pnpm up`** — pnpm treats `up` as the built-in | ||
| `update` alias and mutates package.json/pnpm-lock.yaml instead of running | ||
| the wireit script. Always `pnpm run up` (`make up` does this). | ||
| - Server is ready when `curl -s http://localhost:5173/` returns 200 | ||
| (~30-60s cold build). | ||
| - The bun server serves exact files from `build/` — routes need `.html`: | ||
| `http://localhost:5173/snapshot.html` (self-contained demo scene, loads | ||
| `/visualization_snapshot.json`, no robot required). `/snapshot` 404s. | ||
|
|
||
| ## Drive it | ||
|
|
||
| Playwright is available via the repo's `@playwright/test` devDep. Scripts | ||
| must live inside the repo root for module resolution: | ||
|
|
||
| ```js | ||
| import { chromium } from '@playwright/test' | ||
| ``` | ||
|
|
||
| Useful selectors on the snapshot page: | ||
|
|
||
| - Dashboard buttons use `aria-label` = their description, e.g. | ||
| `[aria-label="Settings"]`. | ||
| - Settings panel tabs are text labels: Connection / Scene / Debug / etc. | ||
| - Debug tab has a "Render stats" `<Switch>` (toggles the three-perf | ||
| monitor, `#three-perf-ui`). | ||
| - Robot-query console errors (`[viam-svelte-sdk] error … getPose …`) are | ||
| expected offline noise on the snapshot page; the SvelteKit router also | ||
| logs one `Not found: /snapshot.html` — both harmless. | ||
|
|
||
| ## Gotchas | ||
|
|
||
| - Settings persist via localStorage per browser context; fresh Playwright | ||
| contexts start from defaults. | ||
| - Rendering is on-demand: after toggling scene settings give it ~1-2s | ||
| before screenshotting. | ||
| - Sentry replay, GLTF/basis, and the PCD loader pool create blob workers | ||
| at startup — don't mistake them for the code under test when | ||
| intercepting `window.Worker`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,4 @@ setup: | |
| @./etc/setup.sh | ||
|
|
||
| up: | ||
| @pnpm up | ||
| @pnpm run up | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| <script lang="ts"> | ||
| import { useStage, useTask, useThrelte } from '@threlte/core' | ||
| import { ThreePerf } from 'three-perf' | ||
|
|
||
| interface Props { | ||
| logsPerSecond?: number | ||
| showGraph?: boolean | ||
| memory?: boolean | ||
| enabled?: boolean | ||
| visible?: boolean | ||
| backgroundOpacity?: number | ||
| scale?: number | ||
| anchorX?: 'left' | 'right' | ||
| anchorY?: 'top' | 'bottom' | ||
| } | ||
|
|
||
| let { | ||
| logsPerSecond = 10, | ||
| showGraph = true, | ||
| memory = true, | ||
| enabled = true, | ||
| visible = true, | ||
| backgroundOpacity = 0.7, | ||
| scale = 1, | ||
| anchorX = 'left', | ||
| anchorY = 'top', | ||
| }: Props = $props() | ||
|
|
||
| const { dom, renderer, renderStage, mainStage } = useThrelte() | ||
|
|
||
| let perf: ThreePerf | ||
|
|
||
| $effect.pre(() => { | ||
| perf = new ThreePerf({ | ||
| domElement: dom, | ||
| renderer, | ||
| }) | ||
|
|
||
| // three-perf hardcodes `position: fixed`, which anchors the monitor to | ||
| // the viewport even when the visualizer is embedded in a larger page. | ||
| // Anchor it to Threlte's relative-positioned canvas wrapper instead. | ||
| perf.ui.wrapper.style.position = 'absolute' | ||
|
|
||
| // Overlay panels (Details, FloatingPanel) share this corner at z-4/z-5; | ||
| // keep the debug monitor above them so toggling it on is never a no-op, | ||
| // but below the top-layer fullscreen/file-drop overlays. | ||
| perf.ui.wrapper.style.zIndex = '10' | ||
|
|
||
| return () => perf.dispose() | ||
| }) | ||
|
|
||
| $effect.pre(() => { | ||
| perf.logsPerSecond = logsPerSecond | ||
| perf.showGraph = showGraph | ||
| perf.memory = memory | ||
| perf.enabled = enabled | ||
| perf.visible = visible | ||
| perf.backgroundOpacity = backgroundOpacity | ||
| perf.scale = scale | ||
| perf.anchorX = anchorX | ||
| perf.anchorY = anchorY | ||
| }) | ||
|
|
||
| useTask( | ||
| () => { | ||
| perf.begin() | ||
| }, | ||
| { | ||
| stage: useStage('monitor-begin', { | ||
| before: mainStage, | ||
| }), | ||
| } | ||
| ) | ||
|
|
||
| useTask( | ||
| () => { | ||
| perf.end() | ||
| }, | ||
| { | ||
| stage: useStage('monitor-end', { | ||
| after: renderStage, | ||
| }), | ||
| } | ||
| ) | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that claude is still $effect.pre happy, neither of these should be pre.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah can't seem to get it off them