Far-Beyond-Pulsar / Far-Beyond-Pulsar/WGPUI-Component

Profiling epic phase 7: flamegraph/inspector viewer UI

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
7
Forks
2
Avg merge
1m
Merged PRs (30d)
1

Description

Part of the profiling/replay epic: Far-Beyond-Pulsar/WGPUI#64. Depends on Far-Beyond-Pulsar/WGPUI#62 (replay engine) and the `flamegraph` feature landing in `gpui` (Far-Beyond-Pulsar/WGPUI#57-61).

## This issue moved here from WGPUI

The viewer belongs in this repo, not `gpui` itself — it's a **new tab in the existing Inspector panel** (`crates/ui/src/inspector.rs`), not a standalone example app. `gpui` core stays UI-agnostic; this repo already owns the devtools chrome.

## Where it plugs in

`crates/ui/src/inspector.rs` currently drives the Inspector panel off `gpui`'s own `InspectorTab` enum:

- `render_inspector_tabs` (`inspector.rs:544`) builds the tab strip from `InspectorTab::all()`.
- `render_tab_content` (`inspector.rs:578`) matches on the active `InspectorTab` (`Elements | Styles | Layout | EventListeners`) to pick which `render_*_tab` function runs.
- Tab selection state (`active_tab()` / `set_tab()`) lives on `gpui`'s core `Inspector` struct, so it's shared state, not something this crate can extend on its own.

Adding a "Profiler" tab therefore needs a small, matching change on the `gpui` side: extend `InspectorTab` with a `Profiler` variant, gated `#[cfg(feature = "flamegraph")]` specifically (not the broader `inspector`/`debug_assertions` gate the rest of the enum uses) so the tab only exists when the flamegraph feature is actually compiled in. `InspectorTab::all()` and `.label()` need a matching cfg'd arm.

On this side:
- `render_tab_content`'s match gets a `#[cfg(feature = "flamegraph")] InspectorTab::Profiler => render_profiler_tab(...)` arm.
- New `crates/ui/src/profiler.rs` (sibling to `inspector.rs`, following the precedent of `code_editor.rs`/`diagnostics.rs` being their own files rather than crammed into `inspector.rs`) holding the actual panel content.
- This crate's `Cargo.toml` needs `flamegraph = ["gpui/flamegraph"]` to forward the feature.

## What the tab shows

Built incrementally as the backing phases land in `gpui`:
- Flame chart (phase 1: Far-Beyond-Pulsar/WGPUI#57) — nested CPU+GPU spans, zoom/search/hover.
- Counters/memory strip (phases 2-3: Far-Beyond-Pulsar/WGPUI#58, Far-Beyond-Pulsar/WGPUI#59) — FPS, draw calls, memory graphs over the capture window.
- Resource inspector (phase 4: Far-Beyond-Pulsar/WGPUI#60) — click a draw call, see bound resources.
- Element tree scrubber (phases 5-6: Far-Beyond-Pulsar/WGPUI#61, Far-Beyond-Pulsar/WGPUI#62) — step frame-by-frame through a replayed capture, synced with the flame chart and the existing Elements/Styles/Layout tabs (clicking an element in the new tab should be able to jump into the existing element-inspection tabs, and vice versa — this tab isn't meant to be siloed from the rest of the panel).

## Files

`crates/ui/src/inspector.rs` (tab wiring), new `crates/ui/src/profiler.rs`, `crates/ui/Cargo.toml`. Upstream in `gpui`: `src/inspector.rs` (`InspectorTab::Profiler` variant, feature-gated).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading crates/ui/src/inspector.rs, especially render_inspector_tabs and render_tab_content, then inspect crates/ui/Cargo.toml and the upstream gpui src/inspector.rs. The work is done when the feature-gated Profiler tab is wired through both repositories, profiler.rs provides the viewer panel, and the tab can support the listed profiling and replay phases without becoming a standalone app.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.