Why Svelte's onDestroy event is not executing URL.revokeObjectURL()?

194 Views Asked by At

I've been loading modal with a help of svelte-simple-modal library, and I want to cleanup variable used for loading image that is stored in memory, previously obtained from backend through JSON.

So I have these important things in tag of Modal.svelte (component which loads with modal window):

arrayBufferCover = base64ToArrayBuffer(response[0].details[0].cover);
blob = new Blob([arrayBufferCover], {type: "image/jpeg"});
blobCoverURL = URL.createObjectURL(blob);
onDestroy(() => URL.revokeObjectURL(blobCoverURL));

And this is what I have in HTML section of Modal.svelte:

<img alt="cover" src={blobCoverURL} />

onDestroy event is occuring after modal window is closed, I'm totally sure it does, but when I check in console, I still have multiple objects listed in sources section (everytime I open modal one object is made). Contrary to that, the list of objects I get from chrome://blob-internals/ is periodically getting smaller, which may be meaning cleanup is properly done, just that Sources in Console is not refreshed, but I'm really not sure, especially because IDs I see comparing those two reports are different?

0

There are 0 best solutions below