KnicKnic / WASM-ImageMagick

Webassembly compilation of https://github.com/ImageMagick/ImageMagick & samples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Not an Issue] memory / file.destroy()

cancerberoSgx opened this issue · comments

When interactively transforming several images without reloading the page I'm seeing (obviously) that RAM consumed by chrome increases until at some point the call to WASM will fail (TODO: print the exception).

exception thrown: abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 2136801280, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 "). Build with -s ASSERTIONS=1 for more info.

You can simulate it if you have low free memory (chrome with many tabs open) and open this one: https://cancerberosgx.github.io/autumn-leaves/photo-morph/#%7B%22selectedImageUrls%22%3A%5B%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1460400355256-e87506dcec4f%3Fixlib%3Drb-0.3.5%26s%3Db4a72fe29f709d81050016ca2a75f053%26auto%3Dformat%26fit%3Dcrop%26w%3D1350%26q%3D80%22%2C%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1439127989242-c3749a012eac%3Fixlib%3Drb-0.3.5%26s%3D7fc8fea1879fe330634a89948a6e5d06%26auto%3Dformat%26fit%3Dcrop%26w%3D1350%26q%3D80%22%2C%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1467825487722-2a7c4cd62e75%3Fixlib%3Drb-0.3.5%26s%3D2403f6e3a8a69f23e2a842720b87ffbe%26auto%3Dformat%26fit%3Dcrop%26w%3D1350%26q%3D80%22%2C%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1460088033389-a14158fa866d%3Fixlib%3Drb-0.3.5%26s%3D841ae3028c1ef31c36454c40a18b92b9%26auto%3Dformat%26fit%3Dcrop%26w%3D1353%26q%3D80%22%5D%2C%22selectedMorph%22%3A%22Tile4Morph%22%2C%22selectedMorphValue%22%3A%7B%22frames%22%3A6%2C%22loop%22%3A0%2C%22speed%22%3A4%2C%22delayShort%22%3A10%2C%22delayLong%22%3A50%2C%22imageWidth%22%3A0%2C%22imageHeight%22%3A0%7D%7D

Basically that one will load 4 big images and then try to execute a command with several intermediate images. It's failing.

I wander if we should provide a method to dispose/destroy the input and output files ? I'm almost sure the memory consumption is at the .html level not at the webworker's because there we are removing files but I think we should at some point analyse this problem

That's why I'm creating this issue and also I wanted to know your opinion

Thanks!

It should be noted that I do not move the objects when transferring between the web worker. When investigating this issue you may want to update all of the postMessage, https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage#Transfer_Example .

After some research this seems to be the expected behavior so I'm closing this.