Skip to content

[p5.js 2.0+ Bug Report]: p5.remove() does not stop MediaStream tracks created by createCapture() #9225

Description

@slash-init

Most appropriate sub-area of p5.js?

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

p5.js version

2.3.2

Web browser and version

firefox 155.0.0

Operating system

Fedora WS

Steps:

  1. Create a sketch using createCapture(VIDEO) and createCapture(AUDIO).
  2. Store the resulting MediaStreamTracks and verify that their readyState is live.
  3. Call p.remove() and check the tracks again.

Snippet:

new p5(p => {
  p.setup = () => {
    p.createCanvas(1, 1).hide();
    p.createCapture(p.VIDEO, videoStream => {
      p.createCapture(p.AUDIO, async audioStream => {
        const tracks = [
          ...videoStream.getTracks(),
          ...audioStream.getTracks()
        ];
        console.log(
          'before remove:',
          tracks.map(track => `${track.kind}: ${track.readyState}`)
        );
        await p.remove();
        console.log(
          'after remove:',
          tracks.map(track => `${track.kind}: ${track.readyState}`)
        );
      });
    });
  };
});

Expected behavior:

After p.remove(), the MediaStreamTracks created by createCapture() should be stopped, with their readyState changing from live to ended.

Actual behavior:

After p.remove(), the tracks remain live.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions