Fix filter() crash on createGraphics(WEBGL) by mirroring strands API … by aashu2006 · Pull Request #8568 · processing/p5.js
Resolves #8549
Changes
Fixes filter() crash when called on createGraphics(WEBGL) buffers.
Strands previously augmented only p5.prototype, but p5.Graphics does not inherit from it. When filter() executed on a p5.Graphics instance, strands callbacks (e.g. getTexture, vec*, dot, etc.) were missing, causing runtime errors.
This PR:
- Introduces two helpers:
augmentFn(permanent, unconditional overwrite)augmentFnTemporary(temporary hook with restoration viagraphicsOverrides)
- Mirrors all permanent strands API augmentations from
p5.prototypeontop5.Graphics.prototype - Mirrors temporary shader hooks during
modify()and restores them indeinitStrandsContext - Ensures
createGraphics(WEBGL).filter()has access to the full strands API layer - Prevents temporary hook leakage after
modify()completes
WebGL unit tests and visual tests pass locally. Manual testing confirms the crash is resolved.
Screenshots of the change:
Manual test confirming no crash and correct behavior:
createGraphics(WEBGL).filter(INVERT)runs without error- Temporary hooks are cleaned up after execution
PR Checklist
-
npm run lintpasses - Inline reference is included / updated
- Unit tests are included / updated
