Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

For Blazor Canvas rendering, is Unmarshalled Interop possible for the draw calls? #146

Open
RChrisCoble opened this issue Aug 11, 2021 · 6 comments
Labels
question Further information is requested

Comments

@RChrisCoble
Copy link

Unmarshalled interop is one of the noted features in .Net 6 for Webassembly.
dotnet/runtime#43767

Avoiding the JS Interop layer would greatly speed up rendering, considering every single method and property call needs to traverse this boundary. Is this possible for .Net 6 now that you have Blazor compiling again?

Thanks.

@charlesroddie
Copy link
Contributor

@RChrisCoble
Copy link
Author

I'm familiar with this feature, as back when the .Net 6 backlog was being planned I requested to Dan Roth we have this ability in Blazor, specifically to use SkiaSharp in client browsers for rendering. This was months before Maui.Graphics became a repo and I was looking for a cross platform 2D rendering API.

That being said, that feature assumes SkiaSharp is being used in this repo to render on Blazor Webassembly, which it doesn't appear to be at present. The Blazor bindings only have Canvas and WebGL.

So, unless this repo plans to add SkiaSharp support to Blazor, I'm not sure this applies.

@RChrisCoble
Copy link
Author

RChrisCoble commented Aug 19, 2021

Or @charlesroddie is this your way of saying this repo will provide SkiaSharp rendering support in Blazor WebAssembly with the express intent of delivering a high performance rendering implementation that allows bypass of the JS/Interop layer, which isn't possible with Canvas/WebGL?

If this is the case, I'm curious if this will require people to AOT compile their code for that Unmarshalled Interop to work.

@charlesroddie
Copy link
Contributor

I am just an observer of this repo. It should give cross-platform 2D rendering with less overhead than SkiaSharp and that is particularly important for web where a few extra MB is a big deal. [Although I see that Skia is used in a few browsers - maybe then SkiaSharp doesn't involve a big download? Will check.] I see this as the key piece to take our dekstop+mobile app to browsers. I don't think Maui.Graphics -> SkiaSharp -> Web makes any sense; it needs to be Maui.Graphics -> WebGL.

I expect that deploying Maui.Graphics for web will have similar issues to SkiaSharp for web, and both will require native dlls which the linked issues is about. Definitely AOT compilation will be essential for deploying to end-users. So in the end they will get WASM with WebGL.

This issue you posted is important in the long run, but getting the current code to display something on web must be the first step and perf questions come later.

@charlesroddie
Copy link
Contributor

Rust has some success with 2D wasm graphics at the moment: https://github.com/femtovg/femtovg (demo website) .

Regarding the unmarshalled interop in this issue, while an improvement, it will involve javascript which is not ideal, and interface types in wasm may be needed to avoid that.

@jsuarezruiz jsuarezruiz added the question Further information is requested label Nov 12, 2021
@Kation
Copy link

Kation commented Feb 18, 2022

Any progress?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants