Skip to content

Fix frameRate() example #1106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2015
Merged

Fix frameRate() example #1106

merged 1 commit into from
Nov 14, 2015

Conversation

toolness
Copy link
Member

This fixes the frameRate() example mentioned in processing/p5.js-website#196. I think.

If this is the "proper" fix, I'm not actually sure it's all that intuitive--I mean, I could easily see myself calling color() at my top-level code, and a thrown error like TypeError: a._renderer is undefined wouldn't really help me debug it--I wonder if there's a way the friendly error system could throw a less cryptic message?

lmccart pushed a commit that referenced this pull request Nov 14, 2015
@lmccart lmccart merged commit 661805d into processing:master Nov 14, 2015
@lmccart
Copy link
Member

lmccart commented Nov 14, 2015

this is the correct fix, no p5 functions work outside of setup/draw... if you can think of any good way to catch this error it'd be wonderful, but I haven't come up with anything yet. the main issue is that calling p5 functions before setup fails because p5 hasn't been instantiated yet (this non-automatic global binding of p5 functions is in place to support instance mode, where p5 is wrapped up in one object so as not to pollute the global namespace. so we have to wait to be sure we are working in global mode before adding all the p5 functions). so i'm not how we could catch errors when p5 isn't running? but any thoughts welcome!

@toolness
Copy link
Member Author

Ah, got it... That is a tough problem.

It's a bit hacky, but what if we added an onerror event handler that caught errors during page load and offered help if possible?

Here's an example: http://jsbin.com/riyaco/2/edit?html,console,output

Again, it's hacky, and I'm not sure how many false positives it'd trigger...

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.

2 participants