Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running in a WebWorker #4

Open
sanbornhilland opened this issue Dec 12, 2018 · 3 comments
Open

Running in a WebWorker #4

sanbornhilland opened this issue Dec 12, 2018 · 3 comments

Comments

@sanbornhilland
Copy link
Contributor

Is it possible or are there plans to make this runnable in a WebWorker?

Currently I can almost get a3a8bc0 running in a web worker but it has a dependency on document.createElementNS which is not available in a WebWorker.

I'm unsure about the CanvasKit version because I don't know where the canvas-kit.js dependency is coming from.

@luigi-rosso
Copy link
Contributor

No plans currently, but this is interesting. I'd like to see if we can support it.

We had to resort to using document.createElementNS for getting the an SVGMatrix transform class that worked across all browsers. Unfortunately DOMMatrix didn't work at all in Safari. https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix. We need this for transforming sub paths via Path2D addPath: https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath.

CanvasKit is essentially WebAssembled SKIA, you can read more about it here: https://skia.org/user/modules/canvaskit

CanvasKit will support some of the more advanced path functionality and some other rendering features (like triangle geometry and more complex fills) we're currently working on in Flare. If you're willing to delve deeper, I'd encourage you to explore that path.

Thanks for looking into Flare!

@sanbornhilland
Copy link
Contributor Author

@luigi-rosso Thanks for the background information. On the SKIA site it mentions that they are working on an NPM distribution. In the mean time is there a way I can get my hands on a build so that I can try running your canvaskit branch?

@sanbornhilland
Copy link
Contributor Author

See #6 for an example that replaces createElementNS with svg.js to run in a WebWorker. That's the main change and it mostly seems to just work. Pretty cool. I'm not familiar with svg.js or the SVGMatrix class but if it's feasible to decouple Flare-JS from the DOM I think it would open up some interesting possibilities for people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants