{"record":{"id":"7fd5ad464e7f56fe","repo":"remotion-dev/remotion","slug":"blocksize-must-be-1","errorCode":null,"errorMessage":"\"blockSize\" must be >= 1","messagePattern":"\"blockSize\" must be >= 1","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/pixelate.ts","lineNumber":37,"sourceCode":"} as const satisfies InteractivitySchema;\n\nexport type PixelateParams = {\n\treadonly blockSize?: number;\n};\n\ntype PixelateResolved = {\n\tblockSize: number;\n};\n\nconst resolve = (p: PixelateParams): PixelateResolved => ({\n\tblockSize: p.blockSize ?? DEFAULT_BLOCK_SIZE,\n});\n\nconst validatePixelateParams = (params: PixelateParams): void => {\n\tassertEffectParamsObject(params, 'Pixelate');\n\tassertOptionalFiniteNumber(params.blockSize, 'blockSize');\n\tif ((params.blockSize ?? DEFAULT_BLOCK_SIZE) < 1) {\n\t\tthrow new Error('\"blockSize\" must be >= 1');\n\t}\n};\n\ntype PixelateState = {\n\treadonly gl: WebGL2RenderingContext;\n\treadonly program: WebGLProgram;\n\treadonly vao: WebGLVertexArrayObject;\n\treadonly vbo: WebGLBuffer;\n\treadonly texture: WebGLTexture;\n\treadonly uSource: WebGLUniformLocation | null;\n\treadonly uBlockSize: WebGLUniformLocation | null;\n\treadonly uResolution: WebGLUniformLocation | null;\n};\n\nconst VERTEX_SHADER = /* glsl */ `#version 300 es\n\nin vec2 aPos;\nin vec2 aUv;","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/pixelate.ts#L19-L55","documentation":"Thrown by validatePixelateParams when the user-supplied (or defaulted) blockSize is less than 1. The schema declares blockSize with min:1, and this runtime guard enforces it before any GL work happens. A blockSize below 1 is meaningless for the pixelation math (it would divide UV space by a non-positive number) and is rejected early.","triggerScenarios":"Calling `pixelate({blockSize: 0})`, `pixelate({blockSize: -5})`, or passing a fractional value below 1 such as `pixelate({blockSize: 0.5})`. The check uses `(params.blockSize ?? DEFAULT_BLOCK_SIZE) < 1`, so an explicit 0 or negative trips it; undefined falls through to the default of 20 and is safe.","commonSituations":"Animation that tweens blockSize toward zero and overshoots; an interpolated value from a schema-driven UI control that allowed values below the documented min; user copies a value from a different effect with a different scale; passing a string or NaN will trip an earlier assertOptionalFiniteNumber check, not this one.","solutions":["Set blockSize to at least 1, e.g. `pixelate({blockSize: 1})` for the finest allowed pixelation.","When animating blockSize, clamp the interpolated value with `Math.max(1, value)` before passing it.","If you want 'no pixelation', omit blockSize entirely (defaults to 20) or remove the pixelate effect from the sequence rather than driving blockSize toward 0.","Audit interpolate() ranges and spring physics outputs that feed blockSize to ensure they never dip below 1."],"exampleFix":"// before\nimport {pixelate} from '@remotion/effects';\nconst e = pixelate({blockSize: 0}); // throws '\"blockSize\" must be >= 1'\n\n// after\nimport {interpolate, useCurrentFrame} from 'remotion';\nconst frame = useCurrentFrame();\nconst raw = interpolate(frame, [0, 60], [0, 40]);\nconst e = pixelate({blockSize: Math.max(1, Math.round(raw))});","handlingStrategy":"validation","validationCode":"function validateBlockSize(v: unknown): number {\n  if (v === undefined) return 20; // DEFAULT_BLOCK_SIZE\n  if (typeof v !== 'number' || !Number.isFinite(v)) {\n    throw new TypeError('blockSize must be a finite number');\n  }\n  if (v < 1) throw new Error('\"blockSize\" must be >= 1');\n  return v;\n}\nconst blockSize = validateBlockSize(maybeBlockSize);","typeGuard":"function isValidBlockSize(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v >= 1;\n}","tryCatchPattern":null,"preventionTips":["Clamp animated blockSize with Math.max(1, value) before passing it.","When interpolating toward zero, stop the interpolation at 1 (or remove the effect).","Audit schema-driven UI controls to enforce min:1 on the client.","Use the type guard above in any code path that receives blockSize from untrusted input."],"tags":["validation","pixelate","params","typescript","animation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}