Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWeb Assembly port #155
Web Assembly port #155
Comments
|
Yes please! |
|
There might be a bit of work getting the multithreaded story sorted out, it would be nice if we could use post message rather than SharedArrayBuffer for communication. |
|
Web Assembly is one of the reasons behind the Executor and RenderCommandListener abstractions. (The other one is WebRender, which is hesitant to add any more threads, at least in Gecko.) Core Pathfinder no longer spawns any threads. For a single-threaded workload you would buffer RenderCommands into a vector, then send them to a Renderer all at once instead of using a SceneProxy. This is likely what a Web Assembly port will want to do. |
|
I'd love to help with this. I need some project to find out how ready the wasm ecosystem is and this seems like it could be that project. @pcwalton do you have a list of items to work on? |
|
@est31 Here are the remaining blockers:
|
|
@pcwalton thanks for the list. I'm not sure I want to do the HarfBuzz/Freetype parts because I don't want to attempt installing emscripten again. It's very tedious to install and set up. The js embedding for wasi right now seems to build on emscripten itself :/. So maybe I should work on #164 first?
Instead of the C API, I'd have used wasm-bindgen instead. It allows you to expose rust-y APIs to javascript. |
|
Any and all help is appreciated! I'll probably get to FreeType and HB if someone else doesn't do it first. As for the C API, we need it for other reasons, for example @toolness' Unity plugin, so I figured we might as well use it for the wasm port as well. But I don't feel strongly about it either way. |
|
Hmm yeah I just realized that #164 is larger than I thought. It requires changes in font-kit as well as skribo or requires replacing skribo use entirely both of which is probably involved and it's probably easier for you given you know both much better than me. I'd love to help though after #164 is resolved! Of course, only if you haven't done WASM support by then already :). |
|
FreeType and Harfbuzz compile without any modification via emscripten. We'd have to compile the whole thing via |
|
Also, won't SIMD be a problem? |
|
@jrowny feel free to take this issue :) |
|
I would like to report success! Modified pathfinder repo: https://github.com/s3bk/pathfinder I am using vector to draw things and font to parse fonts and draw text. |
|
Wow! |
|
Excellent ! |
|
@boulabiar I plan to support right to left scripts eventually. The pdf viewer using the font crate renders Arabic text correct. |
|
Upon request from #rust-offtopic, here is the PDF viewer running in wasm: https://pdf-rs.github.io/view-wasm/ (use ◁ and ▷ keys to navigate) I moved the code to display a scene here: https://github.com/s3bk/pathfinder_view |
|
Nice job @s3bk! Any chance you can hoist a sample up so that it's straight forward to infer performance of the tiger sample? e.g. Hard to tell if it's redrawing in full as you pan or if things are cached at that point. Looking to check out what the perf/cost is for dynamically changing path data / animation in the wasm port. |
|
@CoreyDotCom the scene of the tiger is cached, but everything is redrawn every frame (that something changed). |
|
@CoreyDotCom https://github.com/s3bk/webgl_demo/ In the grafeia demo, a lot of time is spend copying memory… 30% on chromium and 11.5% in Firefox. |
@s3bk WoW looks promising. I wanted to try it out. Is there instruction about how to build pathfinder with your change to wasm? |
|
@leoyanggit |
|
@s3bk Thanks! I successfully compiled and ran webgl_demo. I'm currently looking into text rendering. You mentioned you are using https://github.com/pdf-rs/font to render text. I'm wondering you have a demo that uses it along with pathfinder. |
|
@leoyanggit you are lucky. I just implemented some for pathfinder_canvas
Demo using the canvas api from python: |
|
woops. WebAssembly … the canvas text stuff should still work. |
|
If I use pf-text feature
|
|
|
|
If posslble, could we move this to #pathfinder:matrix.org? |
|
We have a wasm port now. Let's close this in favor of more specific items. |
It would be nice to have a Web Assembly port, like Google's CanvasKit for Skia.