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

CreateCanvas2d() Fails in Server-Side Blazor Apps #12

Closed
SparkieLabs opened this issue Sep 16, 2018 · 4 comments
Closed

CreateCanvas2d() Fails in Server-Side Blazor Apps #12

SparkieLabs opened this issue Sep 16, 2018 · 4 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@SparkieLabs
Copy link

Issue
When trying to call this._context = this._canvasReference.CreateCanvas2d(); in a server-side Blazor app you get the following exception:
Unable to cast object of type 'Microsoft.AspNetCore.Blazor.Server.Circuits.RemoteJSRuntime' to type 'Microsoft.JSInterop.IJSInProcessRuntime'.

It seems related to the "Calling JavaScript from .NET" section of:
Blazor 0.5.0 experimental release now available.

To Reproduce
It happens when you try the Sample in a server-side Blazor app.

@galvesribeiro galvesribeiro self-assigned this Sep 26, 2018
@galvesribeiro galvesribeiro added the invalid This doesn't seem right label Sep 26, 2018
@galvesribeiro
Copy link
Member

Hello @sparkie108

That happens because server-side Blazor requires that all JS interop being async.

The current Canvas implementation isn't async so it will not work. It was meant to be used on the client-side Blazor.

We can make that work but before that, there is a work on batch rendering that must be done so the performance isn't affected.

I've opened #13 to get track of it and for now, there is nothing we can do to allow server-side rendering to work.

Please follow up on that issue as I'm closing this for now.

Thanks!

@ctrl-alt-d
Copy link

I miss a little 'warning' on read.me page informing tabout his limitation.

@brinkp
Copy link

brinkp commented Jan 15, 2019

Any progress on this issue? I really would like to use the Canvas, but I am bound to server-side Blazor...

@galvesribeiro
Copy link
Member

galvesribeiro commented Jan 15, 2019

Not yet.

I'll probably wait for #20 to get in. It is adding WebGL to the table and (if required) will change the API surface a bit.

Once it is done, I'll then move forward with #13 which will add async methods and as a side-effect enable server-side mode.

Use of Canvas remotely with server-side where you don't have batch rendering will probably give a very poor performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants