clockworklabs / clockworklabs/SpacetimeDB
C# Blazor / Browser Support
Nobody has claimed this yet.
- #274 by @CloneDeath — closed without merging
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
System.Threading.Thread.Start() is not supported for browsers.
Instead, async/await with Task.Run is preferred, as it runs for all platforms (including browser).
The issue can be reproduced here: https://github.com/CloneDeath/SpacetimeWebChat
spacetime start- Publish the DB to
quickstart-chatlocally - Build and run the "WebClient" project
- Navigate to the host in a browser, with the console open
Expected: No errors
Actual: You will see the below error printed to the console
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. blazor.webassembly.js:1:46936
---> System.PlatformNotSupportedException: Operation is not supported on this platform. blazor.webassembly.js:1:46936
at System.Threading.Thread.ThrowIfNoThreadStart(Boolean internalThread) blazor.webassembly.js:1:46936
at System.Threading.Thread.Start(Boolean captureContext, Boolean internalThread) blazor.webassembly.js:1:46936
at System.Threading.Thread.Start() blazor.webassembly.js:1:46936
at SpacetimeDB.DbConnectionBase`3[[SpacetimeDB.Types.DbConnection, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[SpacetimeDB.Types.RemoteTables, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[SpacetimeDB.Types.Reducer, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]..ctor() blazor.webassembly.js:1:46936
at SpacetimeDB.Types.DbConnection..ctor() in /home/nicholas/Projects/Games/MMO/quickstart-chat/WebClient/module_bindings/SpacetimeDBClient.g.cs:line 422 blazor.webassembly.js:1:46936
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) blazor.webassembly.js:1:46936
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) blazor.webassembly.js:1:46936
--- End of inner exception stack trace --- blazor.webassembly.js:1:46936
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) blazor.webassembly.js:1:46936
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions) blazor.webassembly.js:1:46936
at System.RuntimeType.CreateInstanceOfT() blazor.webassembly.js:1:46936
at System.Activator.CreateInstance[DbConnection]() blazor.webassembly.js:1:46936
at SpacetimeDB.DbConnectionBuilder`1[[SpacetimeDB.Types.DbConnection, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]..ctor() blazor.webassembly.js:1:46936
at SpacetimeDB.DbConnectionBase`3[[SpacetimeDB.Types.DbConnection, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[SpacetimeDB.Types.RemoteTables, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[SpacetimeDB.Types.Reducer, WebClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Builder() blazor.webassembly.js:1:46936
at WebClient.ServerApi.ConnectToDB() in /home/nicholas/Projects/Games/MMO/quickstart-chat/WebClient/ServerApi.cs:line 32 blazor.webassembly.js:1:46936
at WebClient.ServerApi.Run() in /home/nicholas/Projects/Games/MMO/quickstart-chat/WebClient/ServerApi.cs:line 22 blazor.webassembly.js:1:46936
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the listed spacetime start, database publish, WebClient build, and browser steps, then inspect the DbConnectionBase constructor and ServerApi.cs at lines 22 and 32. Review closed pull request #274 for prior context; done means the WebClient runs in the browser without the reported Thread.Start platform exception in the console.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100