curiosity-ai/catalyst

Blazor is not supported

Closed this issue · 2 comments

Describe the bug
When running under blazor, you cannot register English language models because you receive this error message

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'UID.Hashes' threw an exception.
 ---> System.PlatformNotSupportedException: System.Security.Cryptography.Csp is not supported on this platform.
   at System.Security.Cryptography.RNGCryptoServiceProvider..ctor()
   at UID.Hashes..cctor()
   --- End of inner exception stack trace ---
   at Catalyst.Models.AveragePerceptronTagger..cctor()
System.AggregateException: One or more errors occurred. (The type initializer for 'Catalyst.Models.AveragePerceptronTagger' threw an exception.)
 ---> System.TypeInitializationException: The type initializer for 'Catalyst.Models.AveragePerceptronTagger' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'UID.Hashes' threw an exception.
 ---> System.PlatformNotSupportedException: System.Security.Cryptography.Csp is not supported on this platform.
   at System.Security.Cryptography.RNGCryptoServiceProvider..ctor()
   at UID.Hashes..cctor()
   --- End of inner exception stack trace ---
   at Catalyst.Models.AveragePerceptronTagger..cctor()
   --- End of inner exception stack trace ---
   at Catalyst.Models.English.Register()

Blazor supports this code:

var random = RandomNumberGenerator.Create();

so I think if repackage Mosaic.Core with Blazor support would simply works. Maybe adding support for browser platform would be needed on Catalys package too.

To Reproduce
Just call Catalyst.Models.English.Register(); inside Blazor application

Expected behavior
I expect nothing happens and English model would be registered._

Screenshots
If applicable, add a code example to help explain your problem.

Additional context

Hi @kant2002, on a quick check, we can't just replace it because the RNGCryptoServiceProvider used is thread safe, while the RandomNumberGenerator is not (and thread safety is important on this class).

As Blazor is not a supported platform for Catalyst today, (and I'm sure there will be other issues besides this) I'll close this as won't fix for now.

Would you reevaluate this decision? I'm basically want to work in browser and use this library kant2002/EngLang#35 I technically can perform surgery fix on my fork, but really want to eventually merge it upstream, since consuming fork via Nuget is painful usually.

I believe these limitation is not somewhich which I cannot overcome, if you in principle eventually want to support WASM/WASI workloads.