[p5.js 2.0 Bug Report]: text() and textWidth() throw runtime errors after friendly error is shown
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.2.0
Web browser and version
Google Chrome Version 144.0.7559.61
Operating system
Windows 11
Steps to reproduce this
Description:
When invalid input is passed to text() or textWidth(), a friendly error message is correctly shown, but execution continues and results in a runtime exception inside the text renderer.
This appears inconsistent with other APIs where execution stops after a friendly error.
Steps:
- Open the p5.js Editor
- Run one of the following sketches
- Observe console output
Snippet:
function setup() {
createCanvas(200, 200);
text(null, 50, 50);
}
function setup() {
createCanvas(200, 200);
console.log(textWidth(null));
}
Expected Behaviour:
After a friendly error is reported, execution should stop or fail gracefully without throwing an internal runtime exception.
Actual Behaviour:
A friendly error is shown, but execution continues and crashes inside the text rendering internals.
Additional Notes:
- This behaviour is reproducible with null and undefined
- Similar friendly-error-then-crash patterns were not observed consistently across other APIs
- The crash originates from Renderer._processLines
I'm happy to take this on if this gets approved
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in the p5.js Editor with the provided text(null) and textWidth(null) sketches, then trace the failure from Renderer._processLines. Check how friendly errors are handled for text() and textWidth() with null or undefined. Done means invalid input reports the friendly error without an internal runtime exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100