Skip to content

Web GUI: replace Leaflet with deck.gl in the layout viewer - #11712

Open
jorge-ferreira-pii wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-Web-GUI-library
Open

jorge-ferreira-pii wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-Web-GUI-library

Conversation

@jorge-ferreira-pii

@jorge-ferreira-pii jorge-ferreira-pii commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

The layout viewer now renders with deck.gl instead of Leaflet.js and removes Leaflet entirely.

Zoom and pan are smoother: the previous view stays on screen until the new one is ready, so the layout no longer flashes or shows blank areas. Fit glides to the whole design instead of jumping, and trackpad pinch and scroll zoom follow the fingers.

It also fixes the saved HTML report, clicks on the zoom buttons, and the mouse wheel on macOS. On the server side, there is an optional mode that sends several layers in one tile, and the tile cache is now limited in size.

Fix #11340

@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces Leaflet.js with deck.gl (WebGL) for the 2D layout view, introducing a new layout view architecture (including layout-view.js, view-math.js, tile-grid.js, tile-sources.js, zoom-swap.js, and view-input.js) and updating the C++ backend to support server-side composited tile groups and optimized caching. The review feedback highlights a critical out-of-bounds read vulnerability in TileGenerator::generateGroupTile when handling empty layer buffers, potential memory leaks in main.js from undisposed view and input listener instances during panel recreation, and cross-platform path separator issues on Windows in embed_report_assets.py.

Comment thread src/web/src/tile_generator.cpp Outdated
Comment on lines +3547 to +3554
// Transparent pixels come back all-zero, so the bottom layer is already
// its own composite onto an empty tile.
if (composite.empty()) {
dim = bufferDim(layer_buffer);
composite = std::move(layer_buffer);
} else {
compositeTile(layer_buffer, dim, composite.data(), dim, 0, 0);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

If renderTileBuffer returns an empty vector (which happens when a layer has nothing to draw in the requested tile), layer_buffer will be empty. If composite is already non-empty, the code proceeds to the else branch and calls compositeTile(layer_buffer, dim, composite.data(), dim, 0, 0). Since layer_buffer is empty but dim is non-zero, compositeTile will attempt to read from layer_buffer out of bounds, leading to a segmentation fault or undefined behavior. Checking layer_buffer.empty() and skipping the iteration prevents this crash.

Suggested change
// Transparent pixels come back all-zero, so the bottom layer is already
// its own composite onto an empty tile.
if (composite.empty()) {
dim = bufferDim(layer_buffer);
composite = std::move(layer_buffer);
} else {
compositeTile(layer_buffer, dim, composite.data(), dim, 0, 0);
}
if (layer_buffer.empty()) {
continue;
}
// Transparent pixels come back all-zero, so the bottom layer is already
// its own composite onto an empty tile.
if (composite.empty()) {
dim = bufferDim(layer_buffer);
composite = std::move(layer_buffer);
} else {
compositeTile(layer_buffer, dim, composite.data(), dim, 0, 0);
}

Comment thread openroad/web/src/main.js
// boundaries mid-device-pixel and they show as dark hairlines; this nudges
// each tile container back onto the grid after every move.
installDeviceGridSnapping(app.map);
app.view = createLayoutView(mapDiv, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When createLayoutViewer is called (e.g., when the panel is recreated), a new LayoutView is instantiated and assigned to app.view. However, the previous app.view is never destroyed, which leaves its ResizeObserver active, its ZoomSwap undisposed, and its deck.gl instance finalized only when garbage collected (or potentially leaked if referenced elsewhere). Calling app.view?.destroy() before creating a new view ensures proper cleanup of WebGL contexts and observers.

Suggested change
app.view = createLayoutView(mapDiv, {
app.view?.destroy();
app.view = createLayoutView(mapDiv, {

Comment thread openroad/web/src/main.js
coordBar.textContent = '';
syncHud();
// Pointer input: wheel, keys, clicks, boxes. Drag-panning is the view's.
installViewInput(app.view, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The installViewInput function adds multiple event listeners to the global window object. Since createLayoutViewer is called every time the panel is recreated, these listeners will leak and accumulate on window over time, keeping old view instances alive in memory. Disposing of the previous viewInput instance before installing a new one prevents this memory leak.

Suggested change
installViewInput(app.view, {
app.viewInput?.dispose();
app.viewInput = installViewInput(app.view, {

Comment thread src/web/src/embed_report_assets.py Outdated
Comment on lines +138 to +164
def dependency_order(sources):
"""`sources` ([(path, content)]) with each file after the files it imports,
else in the given order: a file's top-level code runs as it is reached."""
by_name = {path.split("/")[-1]: (path, content) for path, content in sources}
done, visiting, ordered = set(), [], []

def visit(name):
if name in done:
return
if name in visiting:
cycle = visiting[visiting.index(name) :] + [name]
sys.exit("embed_report_assets: import cycle " + " -> ".join(cycle))
visiting.append(name)
for dep in local_imports(by_name[name][1]):
if dep not in by_name:
sys.exit(
f"embed_report_assets: {name} imports {dep}, "
"which is not in --js"
)
visit(dep)
visiting.pop()
done.add(name)
ordered.append(by_name[name])

for path, _ in sources:
visit(path.split("/")[-1])
return ordered

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using path.split("/")[-1] to extract the filename can fail on Windows where the path separator is \\. This will cause by_name keys to contain backslashes, while local_imports returns filenames with forward slashes, leading to key mismatches and build failures on Windows. Normalizing the path separators by replacing backslashes with forward slashes before splitting ensures cross-platform compatibility.

def dependency_order(sources):
    """`sources` ([(path, content)]) with each file after the files it imports,
    else in the given order: a file's top-level code runs as it is reached."""
    def get_basename(p):
        return p.replace('\\', '/').split('/')[-1]

    by_name = {get_basename(path): (path, content) for path, content in sources}
    done, visiting, ordered = set(), [], []

    def visit(name):
        if name in done:
            return
        if name in visiting:
            cycle = visiting[visiting.index(name) :] + [name]
            sys.exit('embed_report_assets: import cycle ' + ' -> '.join(cycle))
        visiting.append(name)
        for dep in local_imports(by_name[name][1]):
            if dep not in by_name:
                sys.exit(
                    f'embed_report_assets: {name} imports {dep}, '
                    'which is not in --js'
                )
            visit(dep)
        visiting.pop()
        done.add(name)
        ordered.append(by_name[name])

    for path, _ in sources:
        visit(get_basename(path))
    return ordered

Comment thread src/web/src/embed_report_assets.py Outdated
sources.append((path, f.read()))
js_parts = []
for path, content in dependency_order(sources):
js_parts.append(f'// ── {path.split("/")[-1]} ──')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Normalize the path separators here as well to ensure the filename is correctly extracted on Windows.

Suggested change
js_parts.append(f'// ── {path.split("/")[-1]} ──')
js_parts.append(f'// ── {path.replace("\\", "/").split("/")[-1]} ──')

Comment thread openroad/web/src/main.js
Comment on lines 141 to +142
const app = {
map: null,
// Zoom-to-fit box in latlng, Qt's 5% margin per dimension already added
// (computeBoundsTransforms). Anything wanting the design's own extent
// has to work from the DBU rects, not from this.
fitBounds: null,
lastSelectionBounds: null, // Leaflet bounds of the last selected object
view: null, // the layout view (layout-view.js)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add a placeholder for viewInput to the app state object to track the active input listener instance and prevent memory leaks on panel recreation.

Suggested change
const app = {
map: null,
// Zoom-to-fit box in latlng, Qt's 5% margin per dimension already added
// (computeBoundsTransforms). Anything wanting the design's own extent
// has to work from the DBU rects, not from this.
fitBounds: null,
lastSelectionBounds: null, // Leaflet bounds of the last selected object
view: null, // the layout view (layout-view.js)
const app = {
view: null, // the layout view (layout-view.js)
viewInput: null,

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Also catches Mesa software renderers and missing WebGL. The warning stays in the bottom-right corner until closed, and can be silenced.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
luma.gl names a GPU maker the private repository's hook rejects; rename it at build time without changing behavior.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Brings in master and the tile-cache, generator-lifetimes and ws-replies
branches, drops tile_group, fixes the viewer and panel issues found since
the review, and regenerates dist.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@jorge-ferreira-pii
jorge-ferreira-pii marked this pull request as ready for review October 28, 2026 12:55
@jorge-ferreira-pii
jorge-ferreira-pii requested a review from a team as a code owner October 28, 2026 12:55
jorge-ferreira-pii and others added 4 commits November 3, 2026 22:28
Ports the per-die layer rows of The-OpenROAD-Project#12061 to the deck.gl viewer and keys
cached tiles by die; drops the checked-in dist that master removed.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

# Conflicts:
#	src/web/src/main.js
#	src/web/src/ui-utils.js
#	src/web/test/js/test-ui-utils.js
Ports master's gated pseudo layers and cluster overlay to the deck.gl
viewer, and keys cached tiles by their owner colors.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Fixes stale tiles in saved reports, jumps in anchored zooms, label-mode
clicks and tiles requested before the per-die state is restored.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@openroad-ci
openroad-ci requested review from a team as code owners November 17, 2026 01:15
jorge-ferreira-pii and others added 3 commits November 17, 2026 02:11
Use std::scoped_lock, drop a nested conditional and add a trailing comma
to the tile key initializer.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Follows master's src/ to openroad/ rename; the Leaflet files the viewer
replaced stay deleted.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: Rendering and navigation are glitchy

2 participants