Skip to content

[p5.js 2.0 Bug Report]: removeCue() on p5.MediaElement leaks debug console.log(id) to user console #8609

@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

No response

Steps to reproduce this

STEPS TO REPRODUCE THIS:

The removeCue() method on p5.MediaElement contains a leftover debug console.log(id) statement at line 5389 of src/dom/dom.js. Every time a user calls removeCue() to remove a scheduled callback from an audio/video element, the internal cue ID is logged to the browser console unnecessarily.

Steps:

  1. Create a media element with createVideo() or createAudio()
  2. Add a cue with media.addCue()
  3. Remove the cue with media.removeCue(id)
  4. Observe the browser console — the cue ID is logged

Snippet:

let beat;

function setup() {
  createCanvas(100, 100);
  beat = createAudio('assets/beat.mp3');
  let cueId = beat.addCue(1.0, () => console.log('cue fired'));
  beat.removeCue(cueId); // ← this logs the cue ID to console unexpectedly
}

Current code at src/dom/dom.js line 5386-5397:

removeCue(id) {
    for (let i = 0; i < this._cues.length; i++) {
      if (this._cues[i].id === id) {
        console.log(id);  // ← leftover debug statement
        this._cues.splice(i, 1);
      }
    }

    if (this._cues.length === 0) {
      this.elt.ontimeupdate = null;
    }
}

Expected behavior: removeCue() should silently remove the cue without logging anything to the console. The console.log(id) appears to be a leftover debug statement and should be removed.

Additional context:

This is a one-line fix — simply remove the console.log(id) at line 5389. The debug statement serves no purpose for end users and pollutes the console output.

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