webarkit / ARnft

A small javascript library for WebAR with NFT
GNU Lesser General Public License v3.0
220 stars 54 forks source link

workers vs activate nft markers in jsartoolkit #234

Open albjeremias opened 3 years ago

albjeremias commented 3 years ago

Hi! :) I've been testing around and found out that in smartphones loading up to 10 NFT markers blows up the memory. I'm not using this library yet, but another version we made directly from jsartoolkit5 (wasm).

my question is, why did you choose to create a worker for each nft?! My main answer is: For loading everything faster in different threads.

kalwalt commented 3 years ago

Hi! :) I've been testing around and found out that in smartphones loading up to 10 NFT markers blows up the memory. I'm not using this library yet, but another version we made directly from jsartoolkit5 (wasm).

my question is, why did you choose to create a worker for each nft?! My main answer is: For loading everything faster in different threads.

I think you are making a comparison between our jsartoolki5 and ARnft. Honestly i haven't thought in that terms, my intentions was simpler to provide a Multi NFT solution, because i haven't yet managed to solve some issues in the Multi NFT feature in JsartoolkitNFT see my PR https://github.com/webarkit/jsartoolkitNFT/pull/102. But i think you are right probably it load faster. Anyawy ARnft need to be improved, Comparing the jsartoolkitNFT and ARnft sinlge NFT marker example ARnft is much slower and with less fps in the Worker. Probably one issue is the update function in ARnft: https://github.com/webarkit/ARnft/blob/14d6a7adfad514abbbf139966d04e34d6295bbd6/src/ARnft.ts#L203-L208 If you some other idea, i'm open to other solutions.

albjeremias commented 3 years ago

ok i didn't made the right questions: Is arnft using wasm version? or normal js? I think that loading the nft markers in different workers makes it load much faster, but in terms of performance we get an out of memory when trying the same implementation with wasm jsartoolkit5. so i wonder if wasm loads way more stuff to the memory? I believe that sending the image to all those workers is what might make it so slow, instead of using a solely worker and a single jsartoolkit5 instance loading all the nfts.

what i think is needed is to patch jsartoolkit5 so that loading could be faster, wasn't there an algorithm of compression for that? Or would be cool to be able to "copy" the memory blocks that jsartoolkit5 needs and only the first time you load on the browser takes time.. second time stores it on the local storage on the browser.. ?!

What i want is to share experiences and help improving this software, by sharing my experience and joining on improving the codebase.

kalwalt commented 3 years ago

Ok now i understood your intention.

Is arnft using wasm version? or normal js?

Because of jsartoolkitNFT it use WASM as single file.

so i wonder if wasm loads way more stuff to the memory?

It could be but i can not be sure.

I believe that sending the image to all those workers is what might make it so slow, instead of using a solely worker and a single jsartoolkit5 instance loading all the nfts.

But with jsartoolkiNFT is not so slow... That is a good point.

wasn't there an algorithm of compression for that?

Yes but not yet merged https://github.com/webarkit/jsartoolkit5/pull/11, i think i need to work again on it. BTW we could integrate into jsartoolkitNFT and so ARnft....