Commit 8b7209b
Score: tile wide pan SVG into GPU-friendly chunks
Ravel-class scores render as one ~37k-px-wide system, which — multiplied
by devicePixelRatio — exceeds every reasonable GPU's max texture
dimension (Intel iGPUs: 8192; modern discrete: 16384). The browser
can't promote that single-layer transform target, so every translate3d
during playback CPU-rasterizes the entire pan, dropping playback to
~10 fps with most frames at 100ms+ on Ravel.
`sliceSvgIntoTiles` cuts the SVG along measure boundaries into chunks ≤
4096 px wide. Each tile is a fresh `<svg>` whose outer viewBox crops
to its slice; the inner `svg.definition-scale` keeps the source's full
internal viewBox but is explicitly placed at source-outer dimensions
so Verovio's nested transforms resolve to the same outer-coord
positions as the source. Measures are MOVED out of the source (not
cloned) so total DOM stays roughly constant. `<defs>` are duplicated
per tile (~50 SMuFL symbols, small). The first tile keeps the system-
level chrome (system bar, brace/bracket); later tiles drop those.
Loop scores skip slicing — their pan widths never approach the
threshold and the loop × tile combo would force a more elaborate
wrap implementation.
Downstream `buildAnchors`, `padAnchors`, `buildPannedShells`, plus the
header / tempo re-timing pass in mountScore, all switch from operating
on a single SVG element to walking `pan` (cross-tile queries) with
`panRect` for coord math; tile 0 owns the chrome template + defs for
shell construction. `stripHeadersFrom` is gated to tile 0 only on
sliced layouts — later tiles' first `.measure` is a mid-piece measure
whose chrome is a valid mid-piece keysig change and must not be
clobbered.
Measured on Ravel (37k-px pan → 11 tiles): playback avg frame 109ms →
**22.7ms** (5×), p50 16.8ms (steady 60 fps), drops over 33ms 88% →
8%. Small/medium scores are unaffected (single-tile path, math
identical). No console errors across all four test scores.
Cross-measure spans (slurs / ties straddling a tile boundary) clip on
whichever tile doesn't carry the span's parent measure. With 4096-px
tiles and typical slur durations (< 1 s ≈ 300 px at scroll rate) this
is rare; accepting it for now.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0d88834 commit 8b7209b
3 files changed
Lines changed: 234 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
114 | 124 | | |
115 | 125 | | |
116 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
117 | 130 | | |
118 | | - | |
| 131 | + | |
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
123 | 136 | | |
124 | 137 | | |
125 | 138 | | |
126 | | - | |
127 | | - | |
| 139 | + | |
| 140 | + | |
128 | 141 | | |
129 | 142 | | |
130 | | - | |
131 | | - | |
| 143 | + | |
| 144 | + | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
| |||
146 | 159 | | |
147 | 160 | | |
148 | 161 | | |
149 | | - | |
| 162 | + | |
| 163 | + | |
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
| |||
158 | 172 | | |
159 | 173 | | |
160 | 174 | | |
161 | | - | |
| 175 | + | |
162 | 176 | | |
163 | 177 | | |
164 | 178 | | |
| |||
176 | 190 | | |
177 | 191 | | |
178 | 192 | | |
179 | | - | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
| |||
191 | 205 | | |
192 | 206 | | |
193 | 207 | | |
194 | | - | |
| 208 | + | |
195 | 209 | | |
196 | 210 | | |
197 | 211 | | |
| |||
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
244 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
245 | 268 | | |
246 | 269 | | |
247 | 270 | | |
| |||
0 commit comments