Skip to content

[p5.js 2.0 Bug Report]: Browser capability warnings in DOM and mouse modules bypass Friendly Error System (3 raw console.log calls) #8611

@MASTERsj01

Description

@MASTERsj01

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

p5.js VERSION: 2.x (main)

Web browser and version

Any

Operating system

Any

Steps to reproduce this

STEPS TO REPRODUCE THIS:

Three browser-capability warning messages across src/dom/dom.js and src/events/mouse.js use raw console.log() instead of the Friendly Error System. These messages fire when the user's browser lacks support for certain APIs, but they bypass FES and are hardcoded in English.

Affected locations:

File Line Function Message
src/events/mouse.js L1939 requestPointerLock() "requestPointerLock is not implemented in this browser"
src/dom/dom.js L2055 createFileInput() "The File APIs are not fully supported in this browser. Cannot create element."
src/dom/dom.js L3939 drop() "The File APIs are not fully supported in this browser."

Snippet to reproduce requestPointerLock issue:

function setup() {
  createCanvas(100, 100);
  p5.disableFriendlyErrors = true;
}

function doubleClicked() {
  requestPointerLock();
  // On a browser without pointer lock support,
  // this logs a raw console.log even though FES is disabled
}

Current code at src/events/mouse.js line 1933-1944:

p5.prototype.requestPointerLock = function() {
  const canvas = this._curElement.elt;
  canvas.requestPointerLock =
    canvas.requestPointerLock || canvas.mozRequestPointerLock;
  if (!canvas.requestPointerLock) {
    console.log('requestPointerLock is not implemented in this browser');
    return false;
  }
  canvas.requestPointerLock();
  return true;
};

Current code at src/dom/dom.js line 2053-2058:

if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
    console.log(
      'The File APIs are not fully supported in this browser. Cannot create element.'
    );
    return;
}

Expected behavior: These browser capability warnings should use p5._friendlyError() so they respect p5.disableFriendlyErrors and can be translated via the i18n system.

Additional context:

All three messages follow the same pattern — checking for browser API support and logging a raw English string when the API is unavailable. This is consistent with ongoing FES migration efforts across the codebase.

I'd be happy to work on this if it 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