Skip to content

Blob URLs are not always revoked #3933

Open

Description

@JammingBen

Describe the bug

Several places create blob URLs via URL.createObjectURL but never call URL.revokeObjectURL. The browser keeps the underlying blob in memory until the URL is revoked or the page is unloaded. Since Web is a long-lived SPA, memory grows over a session.

Steps to reproduce

  1. Download a few mail attachments or a password protected public link archive, upload files into a folder you're viewing via SSE, or browse through images in the preview app.
  2. Open chrome://blob-internals (or the memory tab in dev tools).

Expected behavior

Blob URLs are revoked once they're no longer needed.

Actual behavior

Blob URLs (and their blobs) stay alive until the tab is closed.

Additional context

Never revoked

  • Mail attachment download - packages/web-app-mail/src/components/MailAttachmentItem.vue:119: object URL passed to triggerDownloadWithFilename and never revoked.
  • Mail appointment download - packages/web-app-mail/src/components/MailAppointmentItem.vue:167: same.
  • Archive download with public link password - packages/web-pkg/src/services/archiver.ts:90: the whole archive is fetched into a blob and the URL is never revoked. The URL is also returned to the caller.
  • SSE processing finished - packages/web-runtime/src/container/sse/files.ts:206 (onSSEProcessingFinishedEvent): calls previewService.loadPreview without cached = true, so the blob URL bypasses the preview cache (and its onEvict revoke) and is written to the resource's thumbnail. Leaks one thumbnail per event, e.g. every upload by another client into the current folder.
  • Avatars - packages/web-pkg/src/composables/piniaStores/avatars.ts:16,24: addAvatar overwrites and removeAvatar nulls the entry without revoking the previous blob URL. Affects own avatar upload/removal in packages/web-pkg/src/components/Avatars/AvatarUpload.vue:149. reset has the same issue.
    • AvatarUpload.vue:161-176 also leaks the new object URL when the upload fails (created at :161, dropped in the catch). Creating it only after the upload succeeded avoids that.
    • avatarMap in piniaStores/avatars.ts has no size limit, so user lists, sharees and space members keep one avatar blob per user ever displayed. An LRU limit (revoking on evict, e.g. via helpers/cache/cache.ts) would bound it, but must not evict avatars that are still mounted, since UserAvatar.vue only reloads when the userId changes.

Revoked in some paths only

  • AppWrapper - packages/web-pkg/src/components/AppTemplates/AppWrapper.vue:500: url.value is overwritten when loadFileTask runs again (file context change) without revoking the old URL. Only the last one is revoked on unmount. If the restartable task is cancelled after getUrlForResource resolved, that URL is lost too. Affects apps using disposition: 'inline' (pdf-viewer, preview) and any vault file (useAppFileHandling.ts:62 always returns a blob URL for vault resources).
  • Preview app
    • packages/web-app-preview/src/composables/useMediaFileLoader.ts:156: when the image warm-up fails, mediaFile.url = undefined drops the URL without revoking it before retrying.
    • packages/web-app-preview/src/App.vue:234 (buildMediaFiles): rebuilds mediaFiles whenever activeFiles changes (e.g. after deleting a file), dropping all loaded URLs without revoking them. onBeforeUnmount only revokes the URLs of the current list.
    • Loads resolving after unmount (isDisposed) still assign a URL that is never revoked.
    • Images are loaded uncached (useMediaFileLoader.ts:123), so every visited image stays in memory until the app is closed. Browsing a large folder accumulates all previews. Not a leak strictly, but unbounded.

Fine

useDownloadFile (revoked after 30s), previewService cached path (cache.ts revokes on evict), useMotionPhoto, OcFileInput, web-app-office-settings, and the web-extensions apps (pastebin, bpmn).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions