Skiasharp: [QUESTION] SkiaSharp wasm support

Created on 8 Feb 2020  路  6Comments  路  Source: mono/SkiaSharp

Is it real to build SkiaSharp to use it in wasm? We tried to use SKIA inside Unity3d: ios, android and PC were ok, but I dont know is it real to add support for wasm?

type-feature-request

Most helpful comment

We are looking at this right now.

The main issue is that we need to update to the latest skia - which we are doing: #986

We hope to have a build out in the near future which will support WASM.

All 6 comments

We are looking at this right now.

The main issue is that we need to update to the latest skia - which we are doing: #986

We hope to have a build out in the near future which will support WASM.

We hope to have a build out in the near future which will support WASM.

Extremely interested in this effort, to use SkiaSharp from Blazor directly. So a few questions:

  • Would a supported SkiaSharp platform be Blazor? (I assume yes as there's not much other choice)
  • Would this WASM based solution somehow bypass the WASM/JS later to keep performance high?
  • How many "weeks" is 'near future' in a best guess?

Thanks much.

We are hard at work on this right now. So far, we are aiming for the first previews of v2 in March/April. Once that is out, we will go directly to adding WSM support, so that by the time we go stable a month or so later, we will have WASM as part of the main package.

We would probably work along the same lines that the Uno folks are doing it. And, regardless, we would try our best to ensure that there is minimal JS interop for best performance.

We are aiming for April/May for WASM, but that is a very rough estimate. For the time being, try out the Uno builds and give them feedback so that when we start the WASM step, we can have as many of the improvements that they have been working on.

Was tempted to start a new thread for this question, but it probably fits in here to reduce noise.

Does the architecture of supporting SkiaSharp on WASM lend itself to, in the future, potentially supporting the SkiaSharp API as a "Blazor Extension"?

For example, there's an existing Blazor Extension called "Canvas" on GitHub which demonstrates what I'm asking. If, as a Blazor App, you use this API it behaves differently depending on whether you're running client or server. For client it simply passes through to the HTML5 Canvas API to perform the final render. For Server, it packages up the draw calls and marshals them over SignalR to the client to execute (built in Blazor behavior). This allows you to use one API and support both types of Blazor deployments.

I'm not well versed enough on the internal architecture of Skia and SkiaSharp to make a determination if this would be possible, as this server hosting model would presumably require the Skia engine to run on the server but ultimately 'draw' to an abstracted surface backed by an HTML5 canvas on the client end.

I suppose even if you ran the Skia.wasm on the client but were able to run the business logic using SkiaSharp on the server this would at least lighten the download payload of thin clients.

At the end of the day, (one of) the reason someone might want to support Blazor Server is for situations where it's not reasonable to download multiple megabytes of stuff to support a thin client or low bandwidth situations.

Thanks.

Also Interested in Skia on Blazor, also played around with the canvas extension but not sure how to achieve what I need..

I have a windows graphing control based on zedgraph that uses system.drawing graphics.
looking for a way to port to wasm on razor and have the windows 2D drawing calls write to the html canvas.

Moving this discussion to a single location: https://github.com/mono/SkiaSharp/issues/1219

But the Blazor part is here: https://github.com/mono/SkiaSharp/issues/1194

Was this page helpful?
0 / 5 - 0 ratings