Code Monkey home page Code Monkey logo

Comments (2)

mossroy avatar mossroy commented on June 18, 2024

It will not be that simple.
My first approach was to use a webworker to call the whole localArchive.readArticle(title, callbackFunction);

But Web Workers can not access the variables of the caller. You have to pass the values through messages.
A File object is not clonable, and the dump files are too big to be cloned in memory.

That's why my first reflex was to use Web Workers only when DeviceStorage is available.
Anyway, except if my tests were wrong, a WebWorker does not seem to have access to navigator.getDeviceStorage() function.

So it seems this approach will not work at all.

Maybe it would work to use a Web Worker that encapsulates only the bzip2 algorithm.
But, in this case, both the input byte array and the output string will have to be cloned. So there will be an overhead.
And the recursive algorithm that reads an article will have to be modified to handle the fact that a Web Worker output is asynchronous

from kiwix-js.

mossroy avatar mossroy commented on June 18, 2024

I managed to implement it on the bzip2 algorithm itself.
It works pretty well : the spinner icon is turning while decoding the article, and the User Interface is not blocked.

I measured the overhead, based on the unit test "readArticle" on the small dump : it is 14% longer with the Web Worker (395 ms against 341 ms) on my computer.

Even with this overhead, it appears worth it to me.

from kiwix-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.