web: add DRC viewer widget#10135
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive DRC (Design Rule Check) viewer widget for the web-based GUI, mirroring the functionality of the Qt-based DRCWidget. It includes a new frontend DrcWidget for category selection and violation tree navigation, alongside a backend DRCHandler to manage marker data, report loading, and overlay rendering. While the implementation successfully integrates DRC visualization into the tile-based rendering system, several performance and robustness issues were identified. Specifically, toggling category visibility triggers a flood of individual WebSocket requests, and the backend relies on inefficient ODB marker iterations (getAllMarkers) which can cause significant lag in designs with many violations. Additionally, the report loading logic uses a hardcoded category name, which will cause conflicts when attempting to load multiple reports.
| odb::dbMarker* DRCHandler::findMarkerById(SessionState& state, | ||
| odb::dbChip* chip, | ||
| int marker_id) | ||
| { | ||
| std::lock_guard<std::mutex> lock(state.drc_mutex); | ||
| if (state.active_drc_category.empty()) { | ||
| return nullptr; | ||
| } | ||
| odb::dbMarkerCategory* category | ||
| = chip->findMarkerCategory(state.active_drc_category.c_str()); | ||
| if (!category) { | ||
| return nullptr; | ||
| } | ||
| for (odb::dbMarker* marker : category->getAllMarkers()) { | ||
| if (static_cast<int>(marker->getId()) == marker_id) { | ||
| return marker; | ||
| } | ||
| } | ||
| return nullptr; | ||
| } |
There was a problem hiding this comment.
This function is inefficient for two reasons:
- It calls
category->getAllMarkers(), which in ODB allocates and populates a newstd::vectorcontaining all markers in the hierarchy every time it is called. For large reports, this is expensive. - It does not check if
marker_idis valid (e.g.,-1for deselect) before performing the linear scan.
Adding an early exit for invalid IDs and considering a more efficient lookup (like a map in SessionState) would improve responsiveness.
odb::dbMarker* DRCHandler::findMarkerById(SessionState& state,
odb::dbChip* chip,
int marker_id)
{
if (marker_id < 0) {
return nullptr;
}
std::lock_guard<std::mutex> lock(state.drc_mutex);
if (state.active_drc_category.empty()) {
return nullptr;
}
odb::dbMarkerCategory* category
= chip->findMarkerCategory(state.active_drc_category.c_str());
if (!category) {
return nullptr;
}
for (odb::dbMarker* marker : category->getAllMarkers()) {
if (static_cast<int>(marker->getId()) == marker_id) {
return marker;
}
}
return nullptr;
}| white_line}); | ||
| }; | ||
|
|
||
| for (odb::dbMarker* marker : category->getAllMarkers()) { |
There was a problem hiding this comment.
Calling getAllMarkers() inside refreshDRCOverlay causes a full iteration and vector allocation every time a single marker's visibility is toggled. For reports with a high volume of violations, this will lead to noticeable lag in the UI. Consider caching the marker list in SessionState when a category is first selected.
|
|
||
| odb::dbMarkerCategory* category = nullptr; | ||
| if (path.ends_with(".rpt") || path.ends_with(".drc")) { | ||
| category = odb::dbMarkerCategory::fromTR(chip, "DRC", path); |
There was a problem hiding this comment.
The category name "DRC" is hardcoded. If a user attempts to load a second DRC report, odb::dbMarkerCategory::fromTR will attempt to create another category with the same name, which will likely fail or throw an exception because ODB requires unique category names at the same level.
Consider using the filename (stem) to generate a unique category name or checking if the category already exists and prompting the user/overwriting it.
|
clang-tidy review says "All clean, LGTM! 👍" |
Add a DRC (Design Rule Check) viewer to the web UI with: - Server-side handlers for categories, markers, report loading, marker updates, and violation highlighting - Client-side DRC widget with category selector, violation tree, load/highlight, and file upload dialog - DRC overlay rendering in the tile generator - C++ and JS tests for the new functionality Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
75af34e to
77a9bfd
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
Summary
Add a DRC (Design Rule Check) viewer to the web UI with:
Type of Change
Impact
DRC viewer works
Verification
./etc/Build.sh).