Skip to content

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

@shuklaaryan367-byte

Description

@shuklaaryan367-byte

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions