Skip to content

fix: revoke Blob URLs created by p5.File - #9155

Open
slash-init wants to merge 1 commit into
processing:mainfrom
slash-init:fix/file-blob-url-lifecycle
Open

fix: revoke Blob URLs created by p5.File#9155
slash-init wants to merge 1 commit into
processing:mainfrom
slash-init:fix/file-blob-url-lifecycle

Conversation

@slash-init

Copy link
Copy Markdown
Contributor

Resolves #9134

Changes:

  • Track Blob URLs created by p5.File._load() on the owning p5 instance.
  • Automatically revoke all tracked Blob URLs when p5.remove() is called.
  • Add p5.File.revoke() for explicitly releasing a file's Blob URL.
  • Make p5.File.revoke() idempotent and remove revoked URLs from the instance's tracking set.
  • Pass the p5 instance through both createFileInput() and Element.drop() so media files are tracked correctly.
  • Add unit tests covering Blob URL tracking, automatic cleanup, manual revocation, and both file-loading entry points.

PR Checklist

@rk-3001

rk-3001 commented Sep 9, 2026

Copy link
Copy Markdown

Hi, I'd like to take this on.
Cause: p5.File._load() creates blob URLs for audio/video files via URL.createObjectURL() but never revokes them, so they leak for the page's lifetime instead of the sketch's.
Fix: track created URLs in a _blobUrls Set on the p5 instance (passed through from createFileInput/drop), revoke + clear them in p5.remove(), and add a file.revoke() method for early manual cleanup. I'll include unit tests.
I can work on this...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants