jnordberg / gif.js

JavaScript GIF encoding library

Home Page:http://jnordberg.github.io/gif.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[suggestion] desynchronized canvas and offscreencanvas in a worker (processing w/o 'client-side')

eladkarako opened this issue · comments

Hi,
There are few new stuff (to this date) that might be helpful,

  1. the desynchronized-canvas is a new feature added https://www.chromestatus.com/features/6360971442388992 and explained mostly just by example below and https://blog.chromium.org/2019/05/chrome-75-beta-low-latency-canvas.html. It should be fine (ignored) if not supported, and if it does have support it should accelerate in some way your existing canvas operation.
    let context_type = '2d'; // Or 'webgl' 
    canvas.getContext(context_type, {desynchronized: true});

  2. the offscreencanvas API got a lot more documentations, and few example pages created by Chrome. Essentially you can do most of the processing in a canvas that exist on a worker alone, without (or limiting) the need of placing a canvas on the 'main-thread', it was designed mostly for webGL but you can use it in 2d as well.

    https://ebidel.github.io/demos/offscreencanvas.html
    try view-source:https://ebidel.github.io/demos/offscreencanvas.html
    https://wiki.whatwg.org/wiki/OffscreenCanvas
    (just for reference) https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface

    (and when done you can still postMessage back the typed-array's context (Transferable) as you do now).