Commit 962690d
fix(video): batchers + texture-cache bug-hunt batch — 15 confirmed findings (#1546)
* fix(texture): atlas + parser bug batch (aseprite trim/durations, UV aliases, video regions)
Seven confirmed findings from the batchers + texture-cache adversarial
sweep, atlas/parser cluster — all reproduced by failing-first tests in
the new texture-atlas-parsers.spec.js (11 tests):
- aseprite parser read trimmed/spriteSourceSize/sourceSize/pivot/rotated
off the frame rect instead of the frame entry (siblings, as in the
TexturePacker layout) — trim silently ignored, sourceSize missing
- aseprite animation speed was 10*(frameCount-1) ms/frame; tags now
carry the authored per-frame `duration` as frame-object delays
- addUVs coordinate-alias key used texture dims instead of region dims:
sub-region lookups never hit (duplicate regions), and a frame at (0,0)
poisoned full-image lookups (drew frame 0 stretched)
- no-arg createAnimationFromName/getAnimationSettings iterated alias
keys (every frame twice) and the aseprite `anims` entry (NaN sizes)
- addRegion on an unsized video divided by width=0 → Infinity/NaN UVs
(videoWidth fallback, matching uploadTexture/TextureCache.get)
- padded spritesheet "truncation" rewrote the UV divisor while the GL
texture keeps its physical size — frames sampled shifted under WebGL
- `atlases.length === 0` dead guard on a Map — unsupported-format error
was unreachable, malformed atlases constructed empty
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A
* fix(webgl): batcher GL-state bug batch (unit collisions, upload desync, buffer lifetime)
Eight confirmed findings from the batchers + texture-cache adversarial
sweep, GL-state cluster — covered by the new webgl_batcher_state.spec.js
(9 tests, key fixes verified by mutation):
- lit normal maps bound at maxBatchTextures+slot by fixed arithmetic
while the unit allocator handed those same units to color textures —
whoever bound second clobbered the other (unlit sprites showing the
normal map / lit sprites shading with color data). LitQuadBatcher now
reserves its normal range on first bind (lazily — unlit games keep the
full pool); ShaderEffect extra samplers skip units reserved by others
- per-batcher tracking of the global gl.activeTexture state desynced
after another batcher/FBO moved it, landing texImage2D re-uploads on
foreign textures (video frames overwriting a mesh texture). The active
unit now lives on the renderer (shared accessor); createTexture2D
force-activates its target unit before uploading
- post-effect FBO setup + blitTexture null unit 0's binding but only
invalidated the current batcher — other batchers sampled an unbound
texture (opaque black). New renderer.invalidateTextureUnit() reaches
every batcher
- PrimitiveBatcher.drawVertices had no chunking: a filled ellipse at
radius ≳ 435px overflowed the 4096-vertex buffer (silently-dropped
typed-array writes + GL errors, nothing rendered). Oversized shapes
now chunk on primitive boundaries; thick-line expansion checks
capacity per pair
- NoiseTexture2d.destroy() leaked the lit batcher's cached GL texture +
baked canvas (strong-keyed map, only emptied on full reset). New
event.TEXTURE2D_DESTROYED emitted by Texture2d.destroy(); the lit
batcher evicts in response
- module-level mesh depth-clear flag was shared across renderer
instances; now per-renderer, and RENDER_TARGET_CHANGED carries the
emitting renderer so subscribers ignore foreign broadcasts
- quad batchers leaked a GL index buffer on every GAME_RESET (recreate
without delete); mesh batchers kept lost-context index/vertex buffers
after webglcontextrestored (uploads silently failed). Both families
now delete + recreate on reset (WebGLIndexBuffer.destroy/recreate)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A
* docs(changelog): 19.9.0 entries for the batcher + texture-cache bug batch
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A
* fix(types): TEXTURE2D_DESTROYED carries a Texture2dSource (reconcile with #1543)
#1543 widened Texture2d.getTexture() to the new Texture2dSource union
(GPU-resident backings incl. ImageBitmap); the event signature added in
this branch predated that and was too narrow to typecheck.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A
* fix(examples): aseprite animation dropdown hidden behind the #screen overlay
Since the 19.5 examples-shell restyle (#1454), #screen is a fixed overlay
covering everything below the topbar; the tiledMapLoader/spine selectors
were floated above it (absolute + zIndex 1000) but the aseprite one stayed
in normal flow and has been painted over ever since. Float it the same way,
match the house control styling, and default the select to "run front" so
it agrees with the animation the entity actually starts with.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t8kP8vp58ZrvaD2FqJU6A
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent be66f65 commit 962690d
19 files changed
Lines changed: 968 additions & 85 deletions
File tree
- packages
- examples/src/examples/aseprite
- melonjs
- src
- system
- video
- texture
- parser
- webgl
- batchers
- buffer
- tests
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
20 | 33 | | |
21 | 34 | | |
22 | 35 | | |
23 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
24 | 46 | | |
25 | 47 | | |
26 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
52 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
379 | 380 | | |
380 | 381 | | |
381 | 382 | | |
382 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
386 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
387 | 403 | | |
388 | 404 | | |
389 | 405 | | |
| |||
436 | 452 | | |
437 | 453 | | |
438 | 454 | | |
439 | | - | |
| 455 | + | |
| 456 | + | |
440 | 457 | | |
441 | 458 | | |
442 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | | - | |
| 253 | + | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
373 | 376 | | |
374 | 377 | | |
375 | 378 | | |
| |||
475 | 478 | | |
476 | 479 | | |
477 | 480 | | |
478 | | - | |
479 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
480 | 490 | | |
481 | 491 | | |
482 | 492 | | |
| |||
592 | 602 | | |
593 | 603 | | |
594 | 604 | | |
595 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
596 | 616 | | |
597 | | - | |
598 | 617 | | |
599 | | - | |
| 618 | + | |
600 | 619 | | |
601 | 620 | | |
602 | 621 | | |
| |||
649 | 668 | | |
650 | 669 | | |
651 | 670 | | |
652 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
653 | 678 | | |
654 | 679 | | |
655 | 680 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
344 | 348 | | |
345 | 349 | | |
346 | 350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | | - | |
17 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
33 | | - | |
| 42 | + | |
34 | 43 | | |
35 | | - | |
36 | | - | |
| 44 | + | |
| 45 | + | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
| |||
47 | 56 | | |
48 | 57 | | |
49 | 58 | | |
50 | | - | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
56 | 67 | | |
57 | 68 | | |
58 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
59 | 73 | | |
60 | 74 | | |
61 | 75 | | |
62 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
63 | 82 | | |
64 | 83 | | |
65 | 84 | | |
66 | 85 | | |
67 | 86 | | |
68 | | - | |
69 | | - | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
| 47 | + | |
| 48 | + | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
0 commit comments