processing / processing/p5.js

[p5.js 2.0 Bug Report]: text() and textWidth() throw runtime errors after friendly error is shown

Open
#8,492 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Typography p5.js 2.0+
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:
  1. Open the p5.js Editor
  2. Run one of the following sketches
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.