Blazor.Canvas icon indicating copy to clipboard operation
Blazor.Canvas copied to clipboard

ToBlobAsync on Canvas

Open KristofferStrube opened this issue 2 years ago • 8 comments

Related to Issue #158.

I have started by implementing the primary features to solve the issue.

I still need to:

  • [x] Decide whether or not to implement other parts of the Blob API or just keep it as it is which is to surface the IJSObjectReference.
  • [x] Write an example as part of the TestProject (probably very similar to the ToDataURL example).

KristofferStrube avatar Mar 16 '22 00:03 KristofferStrube

Thanks for the initial work! Looks like it's on the right track to me :-)

stefanloerwald avatar Mar 16 '22 17:03 stefanloerwald

Hi @KristofferStrube,

Sorry for not interacting with this for a while. Is this ready for review now?

Thanks Stefan

stefanloerwald avatar Jun 17 '22 16:06 stefanloerwald

Hi @stefanloerwald,

I wanted to give a last shot at getting the sample to work in the Blazor Server sample and then also maybe simply some of the Interop, even more, using IJSObjectReferences as you had suggested earlier.

Would it be a deal-breaker for the feature if the sample doesn't work in Blazor Server?

KristofferStrube avatar Jun 21 '22 09:06 KristofferStrube

I don't think it's 100% a deal-breaker if it doesn't work in Blazor Server, but I'd like to understand why. If it's just a payload limit then I'd love to see whether we can deliver the payload in a different way (or in chunks), to make it work (basically, how much effort is this?).

If it's not going to work reliably with Blazor Server, can we make sure it fails gracefully (i.e. if we know it's executed server-side, can we throw an appropriate exception)?

stefanloerwald avatar Jun 23 '22 16:06 stefanloerwald

It is a problem with the sample itself and sending too big payloads. It can handle up to about 200x200 canvases. It just fails in an ugly way currently. Should I just change the sample to a smaller canvas and make some notes about it not working for bigger canvases because of payload limits. Don't know if there is some general issue or MS Doc site that we could also link to to justify the limitation.

KristofferStrube avatar Jun 23 '22 18:06 KristofferStrube

I suppose it might be limited by the SignalR connection: https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&WT.mc_id=DOP-MVP-38654&tabs=dotnet#configure-server-options

Maybe it's better to deactivate this method entirely for server-side?

stefanloerwald avatar Jun 25 '22 06:06 stefanloerwald

I don't know if there is a way to limit whether or not a method is visible in Blazor Server.

KristofferStrube avatar Jun 25 '22 18:06 KristofferStrube

It doesn't need to be that strict. We can just throw a PlatformNotSupportedException whenever we're in Blazor Server. I think that's sufficient. I don't expect this API to be super popular, so as long as it serves your use case, I'm fine with being a bit more restrictive than necessary for cases where the limit can be a pain.

stefanloerwald avatar Jun 25 '22 18:06 stefanloerwald

Hey @stefanloerwald sorry for the long wait.

I didn't really like the solution I came up with since it was somewhat cumbersome to make the callback. Since this, I have worked a lot on JSInterop. I found the method DotNet.createJSObjectReference which can be used to create object references from JS which was one of the things I was missing.

So I have made those changes and I think the PR is ready for review now.

KristofferStrube avatar Oct 21 '22 07:10 KristofferStrube

Thank you @KristofferStrube! This looks all good now. I'll merge and release a new version soon.

stefanloerwald avatar Oct 22 '22 13:10 stefanloerwald

This should now be available as version 3.2.0. Thanks again for the contribution.

stefanloerwald avatar Oct 22 '22 13:10 stefanloerwald