{"record":{"id":"c23c6e90e4c53d32","repo":"phaserjs/phaser","slug":"tileset-animationdatatexture-too-many-animations","errorCode":null,"errorMessage":"Tileset._animationDataTexture: too many animations - total number of animations plus animation frames is max 8388608, got ","messagePattern":"Tileset\\._animationDataTexture: too many animations - total number of animations plus animation frames is max 8388608, got ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/tilemaps/Tileset.js","lineNumber":638,"sourceCode":"                animations.push([ animationDuration, animFrames.length ]);\n\n                // The run of frames stores the duration and the actual index.\n                for (var j = 0; j < animation.length; j++)\n                {\n                    var frame = animation[j];\n                    animFrames.push([ frame.duration, frame.tileid ]);\n                }\n\n                // Store the maximum length of any animation.\n                maxLength = Math.max(maxLength, animation.length);\n            }\n        }\n\n        var totalTuples = animations.length + animFrames.length;\n\n        if (totalTuples > 4096 * 4096 / 2)\n        {\n            throw new Error('Tileset._animationDataTexture: too many animations - total number of animations plus animation frames is max 8388608, got ' + (totalTuples));\n        }\n\n        var size = totalTuples * 2;\n        var width = Math.min(size, 4096);\n        var height = Math.ceil(size / 4096);\n\n        var u32 = new Uint32Array(width * height);\n        var offset = 0;\n\n        var animLen = animations.length;\n\n        for (i = 0; i < animLen; i++)\n        {\n            animation = animations[i];\n            var duration = animation[0];\n            var index = animation[1];\n            u32[offset++] = duration;\n","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/tilemaps/Tileset.js#L620-L656","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Audit the tileset's animation definitions and remove/reduce unnecessary frames.","Split the tileset into multiple tilesets so each stays under the limit.","If the count is unexpectedly high, inspect the tileset JSON for corrupted/duplicated animation entries.","Reduce per-tile frame counts (e.g. cap at 8-16 frames) for highly animated maps."],"exampleFix":"// before: one tileset with 20000 tiles * 500 frames -> throws\n// after: split into 10 tilesets, ~2000 tiles each, or trim animation frames to <= 8 per tile","handlingStrategy":"validation","validationCode":"function totalAnimTuples(animations) {\n  let frames = 0;\n  for (const a of animations) frames += a.length;\n  return animations.length + frames;\n}\n// before packing: if (totalAnimTuples(animations) > 8388608) throw new RangeError('too many tile animations');","typeGuard":"function tilesetAnimationsFit(animations) { return totalAnimTuples(animations) <= 8388608; }","tryCatchPattern":null,"preventionTips":["Cap animation frames per tile.","Split huge animated tilesets into multiple tilesets.","Inspect tileset JSON for runaway or duplicated animation entries."],"tags":["tilemap","tileset","animation","gpu-texture","config"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}