Commit 91b192a
fix(video): six GL-core audit findings, each reproduced before fixing
Beat 1 of the resumed subsystem audit (video/GL core, single-finder +
inline verification). Per protocol every bug was demonstrated red with
a reproduction test BEFORE being touched; one finding was refined
during reproduction (fillRect gradients never used the stencil path —
scoped the fix to the shape fills that do).
1. getSupportedCompressedTextureFormats: six WEBKIT fallbacks read the
never-assigned `this._gl` → TypeError on any device missing one
compression family (everything except ANGLE/Metal Macs — which is
why it survived: the dev machines expose every family). → `gl.`
2. Nested multi-effect post-effects: RenderTargetPool's two scalars
(_activeBase/_previousBase) became a proper base STACK — each
nested sprite pass gets its own lazily-allocated capture/ping-pong
pair (2/3, 4/5, …) and begin/end pairs unwind like save/restore;
the saved effect projection is a per-pass stack too. Pre-fix, a
2-effect child inside a 2-effect container cleared the parent's
capture, popped its slot, and crashed endPostEffect every frame.
3. #gradientMask: write/clip/restore phases now use a high-bit stencil
marker (collision-free with mask levels) gated on the VISIBLE value
of the active mask (0 when inverted, maskLevel otherwise), and
restore setMask's exact stencil test — the old code painted
gradients inside inverted cutouts and left a NOTEQUAL parity test
that inverted/leaked all subsequent masked draws. setMask/clearMask
now track _maskInvert.
4. disableScissor() flushes pending quads before disabling the test
(mirrors enableScissor/clipRect/restore) — batched sprites could
escape the scissor entirely.
5. WebGL clearRect() erases to actual transparent black per its JSDoc
("#000000" parses with alpha 1 → it painted opaque black; Canvas
parity).
6. Canvas clipRect() skip-optimizations now reason in DEVICE space
(rotation/skew always clips + cache poisoned): the local-space
early-outs dropped canvas-sized clips under a translate and skipped
nested same-size clips via the stale cache.
Reproductions: tests/glcore-audit.spec.js (5) +
tests/canvas-cliprect-transform.spec.js (2) — all 7 red on the unfixed
code (nested-FBO red with the exact predicted undefined.unbind).
renderTargetPool.spec.js updated to the stack internals + 2 new
nesting tests. Full suite 4736 passed / 0 failed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A1 parent 2d11694 commit 91b192a
7 files changed
Lines changed: 502 additions & 73 deletions
File tree
- packages/melonjs
- src/video
- canvas
- rendertarget
- webgl
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1255 | 1255 | | |
1256 | 1256 | | |
1257 | 1257 | | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
1258 | 1292 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | | - | |
| 1293 | + | |
| 1294 | + | |
1266 | 1295 | | |
1267 | 1296 | | |
1268 | 1297 | | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
1273 | 1302 | | |
1274 | | - | |
1275 | 1303 | | |
1276 | 1304 | | |
1277 | 1305 | | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
1283 | 1311 | | |
1284 | 1312 | | |
1285 | 1313 | | |
| |||
Lines changed: 49 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
28 | 44 | | |
29 | 45 | | |
30 | 46 | | |
| |||
53 | 69 | | |
54 | 70 | | |
55 | 71 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
60 | 85 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 86 | + | |
| 87 | + | |
64 | 88 | | |
65 | | - | |
| 89 | + | |
66 | 90 | | |
67 | 91 | | |
68 | 92 | | |
| |||
72 | 96 | | |
73 | 97 | | |
74 | 98 | | |
75 | | - | |
| 99 | + | |
| 100 | + | |
76 | 101 | | |
77 | 102 | | |
78 | | - | |
| 103 | + | |
79 | 104 | | |
80 | 105 | | |
81 | 106 | | |
82 | 107 | | |
83 | 108 | | |
84 | 109 | | |
85 | 110 | | |
86 | | - | |
| 111 | + | |
| 112 | + | |
87 | 113 | | |
88 | 114 | | |
89 | | - | |
| 115 | + | |
90 | 116 | | |
91 | 117 | | |
92 | 118 | | |
| |||
95 | 121 | | |
96 | 122 | | |
97 | 123 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
| |||
126 | 152 | | |
127 | 153 | | |
128 | 154 | | |
129 | | - | |
130 | | - | |
| 155 | + | |
131 | 156 | | |
132 | 157 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
| |||
314 | 320 | | |
315 | 321 | | |
316 | 322 | | |
317 | | - | |
| 323 | + | |
318 | 324 | | |
319 | 325 | | |
320 | | - | |
| 326 | + | |
321 | 327 | | |
322 | 328 | | |
323 | | - | |
| 329 | + | |
324 | 330 | | |
325 | 331 | | |
326 | | - | |
| 332 | + | |
327 | 333 | | |
328 | 334 | | |
329 | | - | |
| 335 | + | |
330 | 336 | | |
331 | 337 | | |
332 | | - | |
| 338 | + | |
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
| |||
819 | 825 | | |
820 | 826 | | |
821 | 827 | | |
822 | | - | |
823 | | - | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
824 | 831 | | |
825 | 832 | | |
826 | 833 | | |
| |||
931 | 938 | | |
932 | 939 | | |
933 | 940 | | |
934 | | - | |
| 941 | + | |
935 | 942 | | |
936 | 943 | | |
937 | 944 | | |
| |||
1057 | 1064 | | |
1058 | 1065 | | |
1059 | 1066 | | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
1060 | 1074 | | |
1061 | 1075 | | |
1062 | 1076 | | |
| |||
1126 | 1140 | | |
1127 | 1141 | | |
1128 | 1142 | | |
1129 | | - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1130 | 1147 | | |
1131 | 1148 | | |
1132 | 1149 | | |
| |||
2260 | 2277 | | |
2261 | 2278 | | |
2262 | 2279 | | |
2263 | | - | |
2264 | 2280 | | |
2265 | 2281 | | |
2266 | 2282 | | |
2267 | 2283 | | |
2268 | 2284 | | |
2269 | 2285 | | |
2270 | 2286 | | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
2271 | 2296 | | |
2272 | | - | |
2273 | | - | |
2274 | | - | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
2275 | 2302 | | |
2276 | 2303 | | |
2277 | 2304 | | |
| |||
2281 | 2308 | | |
2282 | 2309 | | |
2283 | 2310 | | |
2284 | | - | |
| 2311 | + | |
2285 | 2312 | | |
2286 | | - | |
| 2313 | + | |
2287 | 2314 | | |
2288 | 2315 | | |
2289 | 2316 | | |
2290 | 2317 | | |
2291 | 2318 | | |
2292 | 2319 | | |
2293 | 2320 | | |
2294 | | - | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
2295 | 2324 | | |
2296 | 2325 | | |
2297 | | - | |
2298 | | - | |
| 2326 | + | |
| 2327 | + | |
2299 | 2328 | | |
2300 | 2329 | | |
2301 | 2330 | | |
2302 | | - | |
2303 | | - | |
| 2331 | + | |
| 2332 | + | |
2304 | 2333 | | |
2305 | 2334 | | |
2306 | 2335 | | |
| |||
2524 | 2553 | | |
2525 | 2554 | | |
2526 | 2555 | | |
| 2556 | + | |
2527 | 2557 | | |
2528 | 2558 | | |
2529 | 2559 | | |
| |||
2535 | 2565 | | |
2536 | 2566 | | |
2537 | 2567 | | |
| 2568 | + | |
2538 | 2569 | | |
2539 | 2570 | | |
2540 | 2571 | | |
| |||
0 commit comments