Skip to content

[p5.js 2.0+ Bug Report]: Blob URLs created by p5.File._load() for video/audio files are never revoked #9134

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

v2.3.1

Web browser and version

firefox 154.0

Operating system

Linux Fedora release 44

Steps to reproduce this

Steps:

  1. Create a File representing a video or audio file.
  2. Pass the file to p5.File._load(), which creates an object URL and exposes it through file.data.
  3. Pass file.data to createImg(), then call img.remove(). Observe that URL.revokeObjectURL() is never called for the object URL created by _load().

Snippet:

test('does not revoke the object URL when the created image is removed', async () => {
  const blob = new Blob(['fake video'], { type: 'video/mp4' });
  const inputFile = new window.File([blob], 'test.mp4', {
    type: 'video/mp4'
  });

  const objectURL = 'blob:test-url';

  vi.spyOn(URL, 'createObjectURL').mockReturnValue(objectURL);
  const revokeObjectURL = vi.spyOn(URL, 'revokeObjectURL');

  let file;

  File._load(inputFile, loadedFile => {
    file = loadedFile;
  });

  const img = mockP5Prototype.createImg(file.data, '');
  img.remove();

  expect(revokeObjectURL).not.toHaveBeenCalled();
});

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions