Add SkiaSharp SKP Debugger — Blazor WASM with native DebugCanvas#3583
Draft
mattleibow wants to merge 1 commit into
Draft
Add SkiaSharp SKP Debugger — Blazor WASM with native DebugCanvas#3583mattleibow wants to merge 1 commit into
mattleibow wants to merge 1 commit into
Conversation
A Blazor WebAssembly recreation of Google's Skia Debugger (https://debugger.skia.org/) using SkiaSharp. Loads .skp files and decomposes them into individual draw commands using Skia's native DebugCanvas, running entirely in the browser via WASM. Components: - SkiaSharp.Debugger library (netstandard2.0) - SKDebugCanvas: P/Invoke wrapper for native DebugCanvas - DebuggerState: Pure C# state management with filtering/stepping - Models/SkpCommandList: JSON deserialization for Skia command data - SkiaSharpDebugger Blazor WASM app (net10.0) - SKP file loading with real native introspection - Command list with filtering (positive/negative text filters) - Step-by-step rendering via DebugCanvas.DrawTo() - Playback controls (play/pause/step/jump) - Command histogram - Matrix/clip state display (live from native DebugCanvas) - Pixel inspector with RGBA values - 16x zoom view - Dark theme UI matching VS Code aesthetic - Overdraw visualization, clip region overlay, origin crosshair - 132 unit tests covering: - JSON command parsing - State management (filtering, stepping, range, histogram) - SKP generation and serialization - Native DebugCanvas integration (7 tests) Build changes: - native-shared.cake: SKIA_DEBUGGER env var / --debugger flag - native/macos/build.cake: enableDebugger variable (kept for reference) - externals/skia submodule: points to dev/debugger-c-api branch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
A Blazor WebAssembly recreation of Google's Skia Debugger using SkiaSharp. Loads
.skpfiles and decomposes them into individual draw commands using Skia's nativeDebugCanvas, running entirely in the browser via WASM — no server-side processing.Companion PR: mono/skia#174 (C API for DebugCanvas)
What It Does
Load any
.skpfile → see every draw command (DrawRect,Concat44,Save,ClipPath, etc.) → step through them one by one → watch the canvas build up progressively. The same experience as https://debugger.skia.org/ but powered by SkiaSharp in Blazor WASM.Features
DebugCanvasintrospection (not simulated)!Save Restorehides those)DebugCanvas.DrawTo(canvas, index)renders up to command NArchitecture
Layer 1: Native C API (
externals/skia/— see mono/skia#174)sk_debugger.h/cpp— 14 C API functions wrapping Skia'sDebugCanvasskia_build_for_debugger=trueGN flagSkiaKeeper.creferences prevent dead-strippingLayer 2: C# Library (
source/SkiaSharp.Debugger/)SKDebugCanvas.cs— P/Invoke wrapper withIDisposable,ObjectDisposedExceptionguards, UTF-8 JSON decodingDebuggerState.cs— Pure C# state management: filtering (positiveDraw/negative!Save Restore), range, stepping, histogram, toggleModels/SkpCommandList.cs— JSON deserialization for Skia's command JSON formatLayer 3: Blazor WASM App (
samples/Basic/BlazorWebAssembly/SkiaSharpDebugger/)Index.razor— Main page: loads SKP viaSKDebugCanvas, renders viaDrawTo(), syncs settingsDebuggerState.StateChangedfor reactive re-rendering.skpfiles inwwwroot/skp/How to Build
Prerequisites
wasm-toolsworkloadRun the app (using pre-built WASM natives)
Build native macOS library with debugger support
Build native WASM library with debugger support
The WASM
.amust include the debugger sources. Two approaches:Option A: Docker (Linux, recommended for CI)
Option B: Local macOS using .NET SDK's bundled Emscripten
Run tests
Generate sample SKP files (writes to wwwroot/skp/)
Files Changed
New Files
source/SkiaSharp.Debugger/SkiaSharp.Debugger/source/SkiaSharp.Debugger/SkiaSharp.Debugger.Tests/samples/Basic/BlazorWebAssembly/SkiaSharpDebugger/Modified Files
scripts/cake/native-shared.cakeSKIA_DEBUGGERenv var →skia_build_for_debuggerGN flagnative/macos/build.cakeenableDebuggervariable for macOS buildsexternals/skiadev/debugger-c-apibranch (mono/skia#174)