mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 02:15:01 +00:00
Revert object URL cleanup in fallbackGetImgFromBlob
The image element needs the object URL to remain valid for its lifetime. Revoking it immediately would break the image rendering. This is an acceptable small leak since: 1. Skin images are loaded infrequently 2. The primary code path uses createImageBitmap which doesn't have this issue 3. The fallback is only used in browsers without createImageBitmap support
This commit is contained in:
parent
acc8804173
commit
8ab073828a
1 changed files with 6 additions and 9 deletions
|
|
@ -55,15 +55,12 @@ export async function getFileFromZip(
|
|||
}
|
||||
}
|
||||
|
||||
async function fallbackGetImgFromBlob(blob: Blob): Promise<HTMLImageElement> {
|
||||
const url = URL.createObjectURL(blob);
|
||||
try {
|
||||
const img = await Utils.imgFromUrl(url);
|
||||
return img;
|
||||
} finally {
|
||||
// Clean up the object URL after the image has loaded (or failed to load)
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
function fallbackGetImgFromBlob(blob: Blob): Promise<HTMLImageElement> {
|
||||
// Note: We cannot revoke the object URL here because the returned image
|
||||
// element needs the URL to remain valid for its lifetime. This is an
|
||||
// acceptable small leak since skin images are loaded infrequently and
|
||||
// the primary path uses createImageBitmap which doesn't have this issue.
|
||||
return Utils.imgFromUrl(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
export async function getImgFromBlob(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue