skip FES checks on internal calls by avinxshKD · Pull Request #8517 · processing/p5.js
Conversation
Resolves #7817
Changes
Added call depth tracking to skip FES param validation on internal p5 function calls. The decorator now sets _isUserCall flag and only validates at the outermost level. For async contexts (load* methods), added _internal() helper to suppress validation after await points.
Modified 5 shader loading functions in src/webgl/material.js to wrap post-await internal calls: loadFilterShader, loadMaterialShader, loadNormalShader, loadColorShader, loadStrokeShader.
Fixes the issue where users see FES warnings for internal p5 calls they didn't write (like createVector inside worldToScreen and avoids redundant param checking on already-validated internal calls.
Screenshots of the change
N/A - internal behavior change, no visual differences
PR Checklist
-
npm run lintpasses - Inline reference is included / updated
- Unit tests are included / updated
@davepagurek hey let me know if any adjustments needed, happy to work thanks
| if (!p5.disableFriendlyErrors && !p5.disableParameterValidator) { | ||
| validate(name, args); | ||
| const wasInternalCall = this._isUserCall; | ||
| this._isUserCall = true; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this line would result in all calls being internal? What am I missing? I understood it but maybe it would be nice to add a comment for this block and the block above, noting that if one logic is updated the other should probably be reviewed, as they are similar but not quite same.
track call depth with _isUserCall flag, add _internal() for post-await sections fixes processing#7817
@ksen0 Hey, hve added cross-reference comments linking the two blocks, both now have NOTE lines pointing to each other.
| try { | ||
| const cb = await urlToStrandsCallback(url); | ||
| let shader = this.withGlobalStrands(this, () => | ||
| let shader = this._internal(() => this.withGlobalStrands(this, () => |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! While we're at it, can we do the other known methods? In the reference it looks like that means loadModel, loadFont, loadImage, loadBlob, loadBytes, loadJSON, loadStrings, loadTable, and loadXML
hey @davepagurek you mean _internal() applied to ALL load* methods, not just the shader ones.Right??
checked all of them:
loadJSON,loadStrings,loadTable,loadXML,loadBytes,loadBlobnothis.calls at all post-await, they just return data or pass tosuccessCallbackloadImage: works on thep5.Imageinstance and browser APIs, nothis.method()callsloadFont: usesfn.parseFontDatadirectly (bypasses the decorator entirely) and a module-levelcreate()helperloadModel: operates on theGeometryinstance (model.normalize()etc), nothis.method()calls
None of them hit a decorated p5.prototype method after an await, so wrapping wouldn't change behavior. The 5 shader loaders in material.js are the only ones that actually call this.buildXxxShader() / this.createFilterShader() post-await
Should I add wrapping to the others anyway for consistency/future-proofing, or is the current scope (just the shader loaders) what you had in mind? Want to make sure I'm not missing somethin
This was referenced
Feb 15, 2026Awesome, thanks for looking into all of those!
Should I add wrapping to the others anyway for consistency/future-proofing, or is the current scope (just the shader loaders) what you had in mind? Want to make sure I'm not missing somethin
I think it's not a bad idea to add the wrapping anyway so that we don't have to remember in the future.
Hey thanks for reviewing @ksen0 @davepagurek Added _internal() wrapping to all remaining load* methods, loadJSON, loadStrings, loadTable, loadXML, loadBytes, loadBlob, loadImage, loadFont, loadModel.
None of them currently call this.method() post-await, so this is purely future-proofing. Uses a safe guard (this._internal ? this._internal(cb) : cb()) since _internal isn't available in test mocks where param_validator doesn't run
Hey @davepagurek @ksen0 have resolved the merge conflict in param_validator.js by keeping the branch’s internal-call guard logic and adapting it to upstream’s new registerDecorator API. No extra refactor, no behavior changes outside conflict resolution. Thanks lmk if you have any suggestions
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this, looks good!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters