Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/github-actions-web-browser-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: web-browser-smoke
# The web viewer's unit tests draw against a stand-in for deck.gl; this one
# opens the live viewer and a saved report in Chrome and checks that a tile is
# drawn (//openroad/web/test:browser_smoke_test, tagged manual).
on:
pull_request:
branches:
- master
paths:
- openroad/web/**
- MODULE.bazel
- MODULE.bazel.lock
- .github/workflows/github-actions-web-browser-smoke.yml
permissions:
contents: read
# A new push to the PR cancels the run still building the last one.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
Web-Browser-Smoke:
runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted-ubuntu-26.04' || 'ubuntu-26.04' }}
steps:
- name: Check out repository code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Set up bazel
uses: bazel-contrib/setup-bazel@f34d6a05eae3c24acab7fa54587492daeaeffdab # 0.19.2
with:
bazelisk-version: 1.x
bazelisk-cache: true
- name: Install Chrome when the runner has none
run: |
if ! command -v google-chrome >/dev/null; then
curl -fsSLo "${RUNNER_TEMP}/chrome.deb" \
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get update
sudo apt-get install -y "${RUNNER_TEMP}/chrome.deb"
fi
google-chrome --version
- name: Draw the layout in Chrome
env:
BAZEL_CACHE_LOGIN: ${{ secrets.BAZEL_CACHE_LOGIN }}
run: |-
# Same remote cache as github-actions-clang-tidy-bazel.yml: authed
# when the secret is there, the .bazelrc anonymous read otherwise.
LOGIN="${BAZEL_CACHE_LOGIN}"
REMOTE_FLAGS=()
if [ -n "${LOGIN}" ]; then
TOKEN_B64=$(printf '%s' "${LOGIN}" | base64 | tr -d '\n')
echo "::add-mask::${TOKEN_B64}"
REMOTE_FLAGS=(
--remote_cache=grpcs://bazel.precisioninno.com:443
--experimental_remote_downloader=grpcs://bazel.precisioninno.com:443
--remote_upload_local_results=true
--remote_header="Authorization=Basic ${TOKEN_B64}"
)
fi
set -x
bazel test \
"${REMOTE_FLAGS[@]}" \
--test_output=errors \
--test_env=CHROME="$(command -v google-chrome)" \
//openroad/web/test:browser_smoke_test
9 changes: 7 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,17 @@ npm_web.npm_translate_lock(
pnpm_lock = "//openroad/web:pnpm-lock.yaml",
)

# sax ships its licence as LICENSE.md, which the default "basic" preset strips
# with every other *.md; //openroad/web:third_party_licenses needs it.
# sax and gl-matrix ship their license as LICENSE.md, which the default "basic"
# preset strips with every other *.md; //openroad/web:third_party_licenses
# needs it.
npm_web.npm_exclude_package_contents(
package = "sax",
presets = [],
)
npm_web.npm_exclude_package_contents(
package = "gl-matrix",
presets = [],
)
use_repo(npm_web, "npm_web")

# Regenerate //openroad/web:pnpm-lock.yaml after editing //openroad/web:package.json:
Expand Down
7 changes: 4 additions & 3 deletions openroad/web/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ npm_link_all_packages(name = "node_modules")
# What the bundle carries, with their dependencies, and so whose licences ship
# with it.
_BUNDLED_PACKAGES = [":node_modules/" + p for p in [
"@deck.gl/core",
"@deck.gl/extensions",
"@deck.gl/layers",
"golden-layout",
"leaflet",
"lit",
"netlistsvg",
"three",
Expand All @@ -57,13 +59,12 @@ js_library(
deps = _BUNDLED_PACKAGES,
)

# The stylesheets import Golden Layout's and Leaflet's CSS.
# The stylesheets import Golden Layout's CSS.
js_library(
name = "css",
srcs = glob(["src/*.css"]),
deps = [
":node_modules/golden-layout",
":node_modules/leaflet",
],
)

Expand Down
26 changes: 22 additions & 4 deletions openroad/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,17 @@ The module has two parts:
Tiles are rendered from ODB geometry and encoded as PNG using lodepng.

- **JavaScript frontend** (`src/main.js`, `src/index.html`, `src/style.css`) —
A single-page application using Leaflet.js for the map and GoldenLayout for
resizable panels. Communicates with the server over a binary WebSocket
protocol.
A single-page application using deck.gl (WebGL) for the layout view and lit
components for the panels. Communicates with the server over a binary
WebSocket protocol.

## Browser requirements

The layout view is drawn with WebGL 2, in the live viewer and in a saved
report alike. A browser without WebGL 2 shows the panels but no layout, and
says so; one that runs WebGL 2 in software, without the GPU, draws more slowly
and says that too. Current Chrome, Edge, Firefox, and Safari all have WebGL 2,
but may lose it when hardware acceleration is turned off in the browser.

## Browser libraries

Expand All @@ -727,7 +735,7 @@ the result, so the browser only talks to the OpenROAD process.

| Package | Used for |
| --- | --- |
| `leaflet` | the tiled layout view |
| `@deck.gl/core`, `@deck.gl/layers`, `@deck.gl/extensions` | the layout view, drawn with WebGL through `deck-global.js` |
| `golden-layout` | the dockable panel layout |
| `netlistsvg` | the schematic, laid out by its own `elkjs` |
| `three` | the 3D viewer, through `three-subset.js` |
Expand Down Expand Up @@ -776,6 +784,16 @@ There are a set of regression tests in `./test`.
bazelisk test //openroad/web/test/...
```

`browser_smoke_test` opens the live viewer and a saved report, the report from
disk with the network off, in a real Chrome and checks that a tile is drawn.
It is tagged manual, since Chrome is not part of the build; CI runs it, and
locally it needs Chrome with WebGL 2 (software rendering is enough):

```shell
bazelisk test //openroad/web/test:browser_smoke_test \
--test_env=CHROME=$(command -v google-chrome)
```

## License

BSD 3-Clause License. See [LICENSE](../../LICENSE) file.
49 changes: 35 additions & 14 deletions openroad/web/docs/server-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ canonical JSON type; sending any other type for a present field yields a
on the wire, which the server tolerates for double-typed fields only.
- Strings are JSON strings; arrays are JSON arrays.
- Two narrow exceptions documented inline:
- `select.zoom` accepts `int` or `double` (Leaflet's `zoomSnap: 0`
permits fractional zoom values).
- `select.zoom` accepts `int` or `double` (a client may send a
fractional zoom value).
- `set_heatmap.value` for `int`-typed settings accepts `int` or
`double` and rounds (the JS frontend always uses `parseFloat`).

Expand All @@ -171,13 +171,16 @@ simply listening on the WebSocket; there's no opt-in.

| `type` field | Trigger | Body |
| -------------- | ----------------------------------------------------------------------- | ------------------------------- |
| `refresh` | Initial spatial-index build finished after a connection / `web_server`. | `{"type":"refresh"}` |
| `config` | Once per connection, before any reply to a request. | `{"type":"config","max_in_flight":16}` |
| `refresh` | A connection's init finished, or the design was edited: redraw. | `{"type":"refresh"}` |
| `log` | Buffered server log lines being flushed to clients. | `{"type":"log","text":"<lines>"}` |
| `debug_paused` | The graphics-debug pause hook entered (e.g. placer breakpoint). | `{"type":"debug_paused"}` |
| `debug_resumed`| Pause hook exited. | `{"type":"debug_resumed"}` |
| `debug_refresh`| Debug overlay needs a re-render. | `{"type":"debug_refresh"}` |
| `shutdown` | Server is exiting; client should not auto-reconnect. | `{"type":"shutdown"}` |

`config.max_in_flight` is how many requests the client keeps on the wire.

---

## Tile rendering
Expand All @@ -204,30 +207,43 @@ Render a single 256×256 PNG tile of the layout.

| Field | Type | Required | Description |
| ---------------- | -------- | :------: | ----------- |
| `layer` | `string` | ✓ | Layer name (`metal1`, `metal2`, …) or one of the synthetic layers `_instances`, `_modules`, `_clusters`, `_pins`, or `_overlay`. |
| `z` | `int` | ✓ | Leaflet tile zoom level (0 = whole design). |
| `layer` | `string` | ✓ | Layer name (`metal1`, `metal2`, …) or a synthetic layer: `_instances`, `_pins`, `_modules`, `_clusters`, or one of the overlays the `tech` response lists. |
| `z` | `int` | ✓ | Tile zoom level (0 = whole design). |
| `x` | `int` | ✓ | Tile column at zoom `z`. |
| `y` | `int` | ✓ | Tile row at zoom `z`. |
| `visible_layers` | `string[]` | ✓ | Tech layers currently visible, the union over the dies; an empty array hides them all. Read only by `_pins` and by the overlays whose `layers_by` group is on (see `tech`); every other tile ignores it, and it is left out of their cache key. |
| `chiplet` | `string` | — | Chiplet path (as in the `tech` response's `chiplets[].path`) of the die a tech-layer tile draws. Two dies can share a layer name; omitted draws every visible chiplet. |
| `chiplet_hidden_layers` | `object` | — | `{ "<chiplet path>": ["<layer>", …] }`: layers hidden on that die only, while `visible_layers` still lists them. Read by the same tiles as `visible_layers`; a tech-layer tile names its die with `chiplet` instead. |
| `visible_chiplets` | `string[]` | — | Chiplet paths currently shown; a chiplet not listed is not drawn. Omitted draws every chiplet. |
| `renderer_host` | `bool` | — | Default `false`. On a tile that names its die with `chiplet`, also draw the debug renderers' pass for this layer name; the client sets it on one row per name. |
| *visibility flags* | `bool` | per-flag default | See *TileVisibility flags* below. Any flag may be omitted to take the default. |
| `site_<name>` | `bool` | — | Per-row-site visibility. Only consulted when `rows == true`. |
| `pattern` | `int` | — | Fill pattern for the layer's shapes: `0` none, `1` solid (default), `2` diagonal, `3` cross, `4` dots. Out-of-range values mean solid. |

**Response:** PNG image (frame type `1`), or frame type `3` with no body
when the layer has nothing to draw in this tile.

**Caching:** the server caches the response under the tile, the rendered `dpr`
and `tile_px`, the design and chiplet revisions, and the parsed fields that can
change this layer's pixels. Selectability fields, keys the server does not
parse, and fields this layer does not read (for example `pin_markers` outside
`_pins`, the routing flags and `pattern` outside the tech layers, or
`visible_layers` outside `_pins`, `_access_points`, and, while pin names are
shown, `_inst_labels`) do not split the cache. Tiles that depend on per-session state (a session's own
module or group colors, focused nets, debug renderers) are not cached; the
default color palette is.

### `overlay_tile`

Render one tile of the highlight overlay — selection, hover, timing paths,
DRC markers, route guides, flight lines and user labels — on a transparent
background, on the same tile grid as `tile`. Kept separate from the layer
tiles so a selection change repaints one pane instead of re-rendering every
tiles so a selection change repaints the overlay instead of re-rendering every
layer's geometry.

| Field | Type | Required | Description |
| --------------------- | ---------- | :------: | ----------- |
| `z` | `int` | ✓ | Leaflet tile zoom level, as for `tile`. |
| `z` | `int` | ✓ | Tile zoom level, as for `tile`. |
| `x` | `int` | ✓ | Tile column at zoom `z`. |
| `y` | `int` | ✓ | Tile row at zoom `z`. |
| `visible_layers` | `string[]` | — | Tech layers currently visible. Consulted so route guides respect layer visibility; omitted means draw guides on every layer. |
Expand All @@ -236,6 +252,7 @@ layer's geometry.
| `focused_nets_guides` | `bool` | — | Default `false`. Draw route guides for the focused nets. |
| `draw_labels` | `bool` | — | Default `true`. Draw user labels (`add_label`). |
| `debug_renderers` | `bool` | — | Default `false`. Debug renderers are active, so the highlight must be re-derived every frame to track instances that move between them. |
| `poly_decomp` | `bool` | — | Default `false`. The Options > "Show polygon decomposition" setting, which changes the shapes an ITerm/MTerm highlight draws. A change re-derives the highlights, as with `flywires_only`. |

**Response:** PNG image (frame type `1`), or frame type `3` with no body
when nothing is highlighted in this tile — which is the usual case, since
Expand All @@ -262,15 +279,17 @@ No request fields beyond the envelope.
```json
{
"bounds": [[yMin, xMin], [yMax, xMax]],
"fit_bounds": [[yMin, xMin], [yMax, xMax]],
"shapes_ready": true,
"pin_max_size": 200
}
```

`bounds` is in DBU. `shapes_ready` indicates whether the spatial index
finished building (the `refresh` push fires when this flips to true).
`pin_max_size` is the largest BPin dimension in DBU, used by the client
to size the pin-marker overlay.
`bounds` is in DBU and georeferences the tile grid; `fit_bounds` is the
rect to zoom to fit, `bounds` without the pin-label margin. `shapes_ready`
indicates whether the spatial index finished building (the `refresh` push
fires when this flips to true). `pin_max_size` is the largest BPin dimension
in DBU, used by the client to size the pin-marker overlay.

### `layer_extents`

Expand Down Expand Up @@ -377,7 +396,7 @@ No request fields.

`overlays` lists the self-painting pseudo layers this design can draw (an
overlay with nothing to draw, such as `_regions` in a design without regions,
is left out), each a `tile` layer of its own: `z_index` is its pane order
is left out), each a `tile` layer of its own: `z_index` is its draw order
against the tech layers (`3` upwards), `_instances` (`0`) and `_pins` (`1`).
`shown_by` and `layers_by` are groups of `tile` visibility keys, on when every
key of any one group is on: the overlay draws anything when `shown_by` is on,
Expand All @@ -397,7 +416,7 @@ overlapping objects on repeated calls at the same point.
| ---------------- | -------- | :------: | ----------- |
| `dbu_x` | `int` | ✓ | X coordinate in DBU. |
| `dbu_y` | `int` | ✓ | Y coordinate in DBU. |
| `zoom` | `int` or `double` | ✓ | Current Leaflet zoom level. Server truncates fractional values. |
| `zoom` | `int` or `double` | ✓ | Current view zoom level. Server truncates fractional values. |
| `visible_layers` | `string[]`| ✓ | Same semantics as `tile`. |
| `chiplet_hidden_layers` | `object` | — | Same as `tile`: a layer hidden on one die is not picked there. |
| `chiplet_nonselectable_layers` | `object` | — | `{ "<chiplet path>": ["<layer>", …] }`: layers made unselectable on that die only, while `selectable_layers` still lists them. |
Expand Down Expand Up @@ -1250,7 +1269,9 @@ request gets a `kError` response, the rest of the session continues.
conversion failure, internal `runtime_error`, …): `kError` body
`server error: <exception what()>`.

Every `kError` response logs a server-side warning:
Every `kError` response logs a server-side warning, except the routine ones:
the busy reply while a script runs and `cancelled` for a request the client
cancelled:

```
[WARNING WEB-0043] request id=<id> type=<type> failed: <body>
Expand Down
29 changes: 27 additions & 2 deletions openroad/web/esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,41 @@ const elkBrowserBuild = {
},
};

// loaders.gl fetches worker scripts and codec libraries from unpkg when it has
// no copy of its own, so that fallback is pointed at nothing remote. Only a
// saved report's path overlay loads through it: a data: URL, decoded in page.
const kLoadersCdn = 'https://unpkg.com/@loaders.gl';
const noLoadersCdn = {
name: 'no-loaders-cdn',
setup(build) {
build.onLoad({ filter: /[\\/]@loaders\.gl[\\/].*\.js$/ },
async ({ path }) => {
const text = await readFile(path, 'utf8');
if (!text.includes(kLoadersCdn)) {
return undefined;
}
return {
contents: text.replaceAll(kLoadersCdn,
'loaders.gl-cdn-disabled'),
loader: 'js',
};
});
},
};

export default {
// iife: one self-contained script whose top-level names stay out of the
// page's global scope, however the page loads it.
format: 'iife',
platform: 'browser',
target: ['es2022'],
// deck.gl's builds without WebGPU; the viewer draws with WebGL only.
// Custom conditions drop esbuild's default 'module', so it is listed too.
conditions: ['visgl:webgl-only', 'module'],
loader: {
// leaflet.css and the golden-layout themes reach icons through relative
// The golden-layout stylesheets reach icons through relative
// url(); inlined, the page needs no file besides the bundles.
'.png': 'dataurl',
},
plugins: [compactSvg, elkBrowserBuild],
plugins: [compactSvg, elkBrowserBuild, noLoadersCdn],
};
2 changes: 1 addition & 1 deletion openroad/web/include/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool tokenAllowed(const std::map<std::string, std::string>& params,
bool requestTokenAllowed(std::string_view target, std::string_view expected);

// The redirect for a redeemed ticket: the request's raw query with `ticket`
// swapped for `token`, so viewer options like ?mergetiles=0 survive.
// swapped for `token`, so viewer options like ?preservebuffer=1 survive.
std::string authRedirectTarget(std::string_view target, std::string_view token);

// What presenting a launch ticket got. kReused is the right ticket after it
Expand Down
11 changes: 10 additions & 1 deletion openroad/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
"type": "module",
"description": "Browser libraries for the web viewer, bundled by esbuild into the assets embedded in the OpenROAD binary (issue #11065).",
"dependencies": {
"@deck.gl/core": "9.4.0",
"@deck.gl/extensions": "9.4.0",
"@deck.gl/layers": "9.4.0",
"golden-layout": "2.6.0",
"leaflet": "1.9.4",
"lit": "^3.3.3",
"netlistsvg": "1.0.2",
"three": "0.160.0"
},
"pnpm": {
"onlyBuiltDependencies": [],
"overrides": {
"@deck.gl/core>@types/offscreencanvas": "-",
"@deck.gl/layers>@types/geojson": "-",
"@loaders.gl/schema-utils>@types/geojson": "-",
"@loaders.gl/schema>@types/geojson": "-",
"@luma.gl/core>@types/offscreencanvas": "-",
"apache-arrow>@types/node": "-",
"lit-html>@types/trusted-types": "-",
"netlistsvg>@types/clone": "-",
"netlistsvg>@types/json5": "-",
"netlistsvg>@types/lodash": "-",
Expand Down
Loading
Loading