phaserjs/phaser · error · Error

Tileset._animationDataTexture: too many animations - total n

Error message

Tileset._animationDataTexture: too many animations - total number of animations plus animation frames is max 8388608, got 

What it means

Thrown by Tileset._animationDataTexture when the combined count of tile animations plus their frames (animations.length + animFrames.length, the 'totalTuples') exceeds 8388608 (4096*4096/2). The animation data is packed into a GPU texture capped at 4096x4096 with 2 components per tuple, so exceeding it cannot be represented in the data texture.

Source

Thrown at src/tilemaps/Tileset.js:638

                animations.push([ animationDuration, animFrames.length ]);

                // The run of frames stores the duration and the actual index.
                for (var j = 0; j < animation.length; j++)
                {
                    var frame = animation[j];
                    animFrames.push([ frame.duration, frame.tileid ]);
                }

                // Store the maximum length of any animation.
                maxLength = Math.max(maxLength, animation.length);
            }
        }

        var totalTuples = animations.length + animFrames.length;

        if (totalTuples > 4096 * 4096 / 2)
        {
            throw new Error('Tileset._animationDataTexture: too many animations - total number of animations plus animation frames is max 8388608, got ' + (totalTuples));
        }

        var size = totalTuples * 2;
        var width = Math.min(size, 4096);
        var height = Math.ceil(size / 4096);

        var u32 = new Uint32Array(width * height);
        var offset = 0;

        var animLen = animations.length;

        for (i = 0; i < animLen; i++)
        {
            animation = animations[i];
            var duration = animation[0];
            var index = animation[1];
            u32[offset++] = duration;

View on GitHub (pinned to 41be1e462b)

Solutions

  1. Audit the tileset's animation definitions and remove/reduce unnecessary frames.
  2. Split the tileset into multiple tilesets so each stays under the limit.
  3. If the count is unexpectedly high, inspect the tileset JSON for corrupted/duplicated animation entries.
  4. Reduce per-tile frame counts (e.g. cap at 8-16 frames) for highly animated maps.

Example fix

// before: one tileset with 20000 tiles * 500 frames -> throws
// after: split into 10 tilesets, ~2000 tiles each, or trim animation frames to <= 8 per tile
Defensive patterns

Strategy: validation

Validate before calling

function totalAnimTuples(animations) {
  let frames = 0;
  for (const a of animations) frames += a.length;
  return animations.length + frames;
}
// before packing: if (totalAnimTuples(animations) > 8388608) throw new RangeError('too many tile animations');

Type guard

function tilesetAnimationsFit(animations) { return totalAnimTuples(animations) <= 8388608; }

Prevention

When it happens

Trigger: Loading a tilemap with tilesets whose total animated-tile frame count exceeds ~8.39M tuples; a corrupt or pathological tileset JSON/Tiled file declaring huge animation arrays; importing many animation frames per tile across many tiles.

Common situations: Extremely dense animated-tile maps; a malformed Tiled export with runaway animation entries; a generator script producing thousands of frames per tile; legitimate large maps that genuinely exceed the texture budget and need splitting.

Related errors


AI-assisted analysis of phaserjs/phaser@41be1e462b (2026-08-13). Data as JSON: /api/errors/c23c6e90e4c53d32. Report an issue: GitHub.