|
| 1 | +# JBrowse 2 WebGL/WebGPU Migration — Project Requirements Document |
| 2 | + |
| 3 | +**Branch:** `webgl-poc` **Last updated:** 2026-03-17 **Status:** Active |
| 4 | +development — many features working, significant polish and testing needed |
| 5 | + |
| 6 | +> **Note:** When items are completed, move them to `COMPLETED.md`. |
| 7 | +
|
| 8 | +--- |
| 9 | + |
| 10 | +## Executive Summary |
| 11 | + |
| 12 | +JBrowse 2 is being migrated from its block-based HTML canvas rendering to a |
| 13 | +unified GPU-accelerated rendering pipeline supporting three backends: |
| 14 | +**WebGPU**, **WebGL 2.0**, and **HTML5 Canvas** (fallback + SVG export). The |
| 15 | +branch has working implementations for most track types with known bugs and gaps |
| 16 | +documented below. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Priority 1 — Critical / Blocking |
| 21 | + |
| 22 | +These issues block production readiness or affect the majority of users. |
| 23 | + |
| 24 | +### P1.3 Expand Browser Test Suite |
| 25 | + |
| 26 | +**Requirements:** |
| 27 | + |
| 28 | +- WebGPU does not work on CI action runners — tests must work with WebGL and |
| 29 | + Canvas fallback |
| 30 | + |
| 31 | +### P1.4 Demo Session Loading |
| 32 | + |
| 33 | +- Many shared session links fail to load or load with incorrect settings. This |
| 34 | + is the primary way users encounter the app. |
| 35 | + |
| 36 | +### Extra ideas |
| 37 | + |
| 38 | +Make curvy breakpoint split view lines in the alignments track for link |
| 39 | +paired/supp reads |
| 40 | + |
| 41 | +- Idea: The 'Link supplementary alignments has the concept of connecting reads |
| 42 | + using a single line. But, we have logic in breakpoint split view for properly |
| 43 | + linking the ORIENTATION of the reads using curved lines. evaluate whether we |
| 44 | + can do this in the Linked paired end/supplementary reads mode in the normal |
| 45 | + alignments track. If might be a separate mode from Link supplementary reads, |
| 46 | + like "Link paired/supp reads with curved lines" |
| 47 | + |
| 48 | +## Priority 4 — Low / Future Enhancements |
| 49 | + |
| 50 | +### P4.3 Loading old configs |
| 51 | + |
| 52 | +- Ensure all old renderer configuration settings e.g. PileupRenderer (which were |
| 53 | + all effectively removed) are mapped to new display model settings (e.g. to |
| 54 | + LinearAlignmentsDisplay) |
| 55 | + |
| 56 | +## Architecture Notes |
| 57 | + |
| 58 | +### Current Rendering Backends |
| 59 | + |
| 60 | +``` |
| 61 | +┌─────────────────────────────────────────────┐ |
| 62 | +│ Track Display Model │ |
| 63 | +│ (prepares data, layout) │ |
| 64 | +└──────────────┬──────────────────────────────┘ |
| 65 | + │ |
| 66 | + ┌──────────┴──────────┐ |
| 67 | + ▼ ▼ |
| 68 | +┌────────┐ ┌────────┐ ┌────────────┐ |
| 69 | +│ WebGPU │ │WebGL2 │ │ Canvas 2D │ ← COMPLETE (all track types) |
| 70 | +│ (WGSL) │ │(GLSL) │ │ (fallback) │ |
| 71 | +└────────┘ └────────┘ └────────────┘ |
| 72 | + │ |
| 73 | + ┌────┴────┐ |
| 74 | + ▼ ▼ |
| 75 | + ┌────────┐ ┌───────┐ |
| 76 | + │ Screen │ │ SVG │ (via SvgCanvas.ts) |
| 77 | + └────────┘ │Export │ |
| 78 | + └───────┘ |
| 79 | +``` |
| 80 | + |
| 81 | +### Backend Selection |
| 82 | + |
| 83 | +- `?gpu=webgpu` — force WebGPU |
| 84 | +- `?gpu=webgl` — force WebGL2 |
| 85 | +- `?gpu=off` — disable GPU (uses Canvas 2D fallback) |
| 86 | +- Default: auto-detect (WebGPU → WebGL2 → Canvas 2D) |
| 87 | + |
| 88 | +### Test Infrastructure |
| 89 | + |
| 90 | +- Puppeteer-based browser tests in `products/jbrowse-web/browser-tests/` |
| 91 | +- **21 test suites** with **~120 test cases** covering: alignments, bigwig, |
| 92 | + variants, synteny, dotplot, HiC, canvas2d-fallback (8 tests: features, |
| 93 | + multi-track, zoom, alignments+coverage, SNP coverage, arcs, sequence, wiggle), |
| 94 | + canvas2d-variants, rendering-backends (16 tests: VCF, GFF3, wiggle, BAM/CRAM |
| 95 | + pileup, SNP coverage, multi-wiggle, SV, JEXL, sequence, alignments+coverage, |
| 96 | + arcs, synteny LGV, synteny linear, dotplot), color-by-tag, wiggle-color, |
| 97 | + workspaces, session-spec, demo-inventory, svg-export, authentication, |
| 98 | + main-thread-rpc, custom-url, redraw, basic-lgv, misc |
| 99 | +- Screenshot comparison via pixelmatch (threshold 0.1) |
| 100 | +- Backend-specific golden snapshots in `__snapshots__/{webgl,webgpu,canvas2d}/` |
| 101 | +- `--backend=webgl|webgpu|canvas2d` flag, `--filter=` for running subsets |
| 102 | +- `compare-backends.ts` for cross-backend visual regression (categories: |
| 103 | + identical, similar <5%, different ≥5%) |
| 104 | +- Unit tests co-located with source (`*.test.ts`) using Jest with jsdom — **157 |
| 105 | + tests across 15 suites** in modified plugins |
| 106 | +- Canvas 2D renderer unit tests use mock canvas context pattern (20 tests |
| 107 | + including picking) |
| 108 | +- Density-based feature limit unit tests (7 tests covering all threshold |
| 109 | + scenarios) |
| 110 | +- Strand swap coordinate tests (4 tests covering all strand×reversed |
| 111 | + combinations) |
| 112 | +- `copyView.renameIds()` unit tests (8 tests verifying ID uniqueness) |
| 113 | +- Fetch autorun tests include error recovery via `reload()` flow |
| 114 | +- Interbase indicator tests (7 tests for `computeNoncovCoverage` threshold |
| 115 | + logic, depth boundaries, dominant type selection) |
| 116 | +- Interbase frequency tests (6 tests for `computePositionFrequencies` |
| 117 | + edge/cliff/offset cases) |
| 118 | +- Depth-dependent threshold tests (2 tests for `applyDepthDependentThreshold` |
| 119 | + interbase mode) |
| 120 | +- `featureFrequencyThreshold` tests (5 tests covering step boundaries, |
| 121 | + interpolation, monotonicity) |
| 122 | +- Floating label regression test verifying description data stability across |
| 123 | + zoom levels |
| 124 | +- Browser test runner forwards `[alignments]` and `[webgl-wiggle]` console logs |
| 125 | + for debugging |
| 126 | + |
| 127 | +## Next Steps |
| 128 | + |
| 129 | +### Cross-Backend Testing |
| 130 | + |
| 131 | +1. **Cross-backend visual regression**: Use `compare-backends.ts` to flag |
| 132 | + rendering differences between WebGL and Canvas2D for each track type |
0 commit comments