Skip to content

Add logging for experimental features - #9109

Open
davepagurek wants to merge 8 commits into
mainfrom
experimental-features
Open

Add logging for experimental features#9109
davepagurek wants to merge 8 commits into
mainfrom
experimental-features

Conversation

@davepagurek

@davepagurek davepagurek commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Resolves #9108

Changes:

  • Adds a decorator system for marking experimental functionality in p5
  • Sets up strands and webgpu entrypoints as experimental
  • Updates the contributor docs for strands and webgpu to be better landing pages for users coming from those experimental function warnings

Live example: https://editor.p5js.org/davepagurek/sketches/p1c5jvRAf

image

PR Checklist

@Vaivaswat2244 Vaivaswat2244 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @davepagurek , I had a few thoughts on this.

Comment thread src/webgl/material.js
fn.buildMaterialShader = function (cb, scope) {
return this.baseMaterialShader().modify(cb, scope);
};
p5.registerDecorator('p5.prototype.buildMaterialShader', markExperimental('p5.strands', p5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildNormalShader also has beta tag, that should also be here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good catch!

Comment thread src/core/p5.Renderer3D.js
}
return this._renderer.createStorage(dataOrCount);
};
p5.registerDecorator('p5.prototype.createStorage', markExperimental('webgpu', p5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseComputeShader() (L2379) and compute() (L2725) are @beta and live on Renderer3D, so they are reachable in WEBGL mode where the RendererWebGPU constructor warning never fires...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compute shaders only actually work in WebGPU mode and will throw an error in WebGL mode so I figured that path was less critical to flag.

@ksen0 ksen0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these very helpful documentation updates! I've added some small but major notes re: error message. The important thing with experimental features is being transparent that API may not be stable.

Comment thread src/core/experimental.js
*/

const experimentalMessages = {
webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"WEBGPU mode is experimental, and API related to it (functions and constraints) may change in future versions. You can get involved by giving feedback to help direct its development!"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do constraints refer to in this context?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry "constants"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be rephrased I am just trying to be explicit that API may change (and that means functions or constants may change) in the future

Comment thread src/core/experimental.js

const experimentalMessages = {
webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!',
'p5.strands': 'p5.strands shaders are experimental. Your feedback will help shape its future!',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liekwise "p5.strands API (build shader functions, the hooks in them, and related constants) may change in future versions. You can get involved by giving feedback to help shape its future!"

Comment thread src/webgl/material.js
fn.buildStrokeShader = function (cb, scope) {
return this.baseStrokeShader().modify(cb, scope);
};
p5.registerDecorator('p5.prototype.buildStrokeShader', markExperimental('p5.strands', p5));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trick that you may or may not want to use (I only just thought of it so it may not work) which is that the pattern matcher (first argument) can be a function and if it returns true the decorator will apply and false it won't, which means that if say you add some flags onto the functions itself to mark it as experimental:

p5.prototype.buildStrokeShader.experimental = true

you can just call registerDecorator once and return true whenever the flag is present on a function. That way you don't have to call registerDecorator every time a new experimental API is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better labelling of usage of experimental functionality

4 participants