Skip to content

Add support for browser platform#353

Closed
alex47 wants to merge 220 commits into
clockworklabs:release/latestfrom
alex47:blazor-webassembly
Closed

Add support for browser platform#353
alex47 wants to merge 220 commits into
clockworklabs:release/latestfrom
alex47:blazor-webassembly

Conversation

@alex47
Copy link
Copy Markdown
Contributor

@alex47 alex47 commented Jul 21, 2025

Description of Changes

This is a continuation of: #274
I have applied those changes to the latest codebase.

Added support for the browser platform.

This required:

  • Replacing Thread.Start with a Task (Thread.Start is not supported for browser platforms)
    • also made PreProcessMessages async, in order to use Channels async methods
  • Configuring the Task to be allowed to run on a separate thread (ConfigureAwait(false))
  • Replacing BlockingCollection (which is not supported on the browser platform) with Channel (which is supported on all platforms)
  • Configuring the task spawned in IDbConnection.Connect to run on any thread, not necessarily the caller (ConfigureAwait(false))
  • Removed Ws.Options.UseDefaultCredentials = true; (this is already true by default. In addition, using this setter is not being supported by browser platforms.)
  • Pass the token as query parameter (only on browser platform), as Ws.Options.SetRequestHeader is not supported on browser platform

API

  • This is an API breaking change to the SDK

N/A. No changes to the API.

Requires SpacetimeDB PRs

N/A

Testsuite

SpacetimeDB branch name: master

Testing

Testing was performed manually inside of a Blazor WebAssembly Standalone App, using the reference quickstart-chat code.
The test project can be found here: https://github.com/alex47/BlazorWebassemblyChat

  • Able to send and receive messages in the Blazor WebAssembly chat client
  • Able to send and receive messages in the reference console chat client
  • Able to send and receive messages with "spacetime call" command
image

jdetter and others added 30 commits November 2, 2022 12:01
…ption

Add sslEnabled option to Connect function
* Fix compilation issue with master

* Initial push for SATS (still WIP)

* Small build fix

* Small update

* Updates from meeting with Tyler

* Fixed issues with LayoutExplicit and added some missing functions

* AlgebraicValue cleanup

* Copied changes from BitCraftMini

* Removed TypeDef

---------

Co-authored-by: Clockwork Labs <no-reply@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
* Upload script to help deploying to our partners

* You have to specify hosts individually

* Small fix

* Another small fix - tested + working

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Serialize byte arrays as hex

* Fix namespace

* Small fix

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* First pass

* Committing meta file

* Removed option type - unneeded

* Implementing new some converter

* Some converter updates

* Tons of fixes here

* Cleaned up the some/enum serialization implementation

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: John <no-reply@boppygames.gg>
Co-authored-by: John Detter <no-reply@boppygames.gg>
* Several updates to the way ClientCache + processing updates works

* Client cache changes working

* Removed log statements

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Copied changes from BitCraft

* Applied state diff changes

* State diffs complete

* Compilation fix

* Fix build issues

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Pulled SpacetimeUnitySDK from the BitCraft project

* Removed unused logs

* Removed primary key functionality

* Fix compilation issues with older version of C#

* Primary key client implementation

* Another row update fix

---------

Co-authored-by: John <no-reply@boppygames.gg>
* Pulled SpacetimeUnitySDK from the BitCraft project

* Removed unused logs

* Removed primary key functionality

* Fix compilation issues with older version of C#

---------

Co-authored-by: John <no-reply@boppygames.gg>
* Adding event parameter to table callbacks

* Reverted a namespace change

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
* Add onSubscriptionUpdate callback

* Remove unnecesary onTransactionComplete

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
…ed from callbacks (clockworklabs#20)

Co-authored-by: Steve <steve@codefics.com>
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Removed redundant onSubscriptionUpdate

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Adding OnBeforeDelete event to tables

* Renaming ReducerCallInfo to ReducerEvent

* Removed extra onSubscriptionUpdate

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Adding OnBeforeDelete event to tables

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
kazimuth and others added 21 commits April 23, 2025 20:44
This dramatically improves performance by avoiding the default
implementation of BrotliStream.ReadByte() inherited from Stream, which
allocates an array per byte read.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [ ] Describe a test for this PR that you have completed
## Description of Changes
*Describe what has been changed, any new features or bug fixes*

- Bumps version to 1.1.3

## API

This is not an API breaking change

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

- None

## Testsuite
*If you would like to run the your SDK changes in this PR against a
specific SpacetimeDB branch, specify that here. This can be a branch
name or a link to a PR.*

SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

This is just a version bump, CI is sufficient.
## Description of Changes
*Describe what has been changed, any new features or bug fixes*

- Bumps version to 1.1.4

## API

Not breaking

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

## Testsuite
*If you would like to run the your SDK changes in this PR against a
specific SpacetimeDB branch, specify that here. This can be a branch
name or a link to a PR.*

SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

This is just a version bump
This purges the DbValue type, instead using row instances themselves as
primary key for rows without primary keys. In addition, it instantiates
only a single BinaryReader when reading updates for a table, rather than
instantiating a BinaryReader and performing an array copy per-row of the
table.

Addresses
https://github.com/clockworklabs/SpacetimeDBPrivate/issues/1633

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [ ] CI

---------

Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Update DLLs and generated code for SpacetimeDB 74ad4a1
## Description of Changes
Leverages clockworklabs/SpacetimeDB#2725 to
speed up row deserialization. Also updates DLLs for recent upstream
fixes.

Changes:
- Uses much simpler code when deserializing enums, avoiding the use of
reflection
- Uses manually monomorphized row deserialization methods, which again
avoid the use of reflection when constructing row objects

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
clockworklabs/SpacetimeDB#2725

## Testsuite

SpacetimeDB branch name: jgilles/perf/faster-allocation

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Blackholio
- [x] Bitcraft (have done a basic test but no in-depth testing)
## Description of Changes
Recreating clockworklabs#311 using a branch in this repo in the hope of fixing the
Unity build.

## API

 - [ ] This is an API breaking change to the SDK


## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] blackholio
- [ ] bitcraft

---------

Co-authored-by: Guribo <guribovr@gmail.com>
## Description of Changes
Just bumping version numbers in preparation for a release.

The Unity SDK and C# SDK had different version numbers. That seems
confusing, so I bumped them both to 1.1.5.

## API

No breaking changes

## Requires SpacetimeDB PRs
None, afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
None

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Update DLLs to the 1.1.2 versions that have been pushed to NuGet.

The SpacetimeDB tag that they were built from is
`v1.1.2-csharp-release`.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
None, because we're updating the DLLs to essentially include SpacetimeDB
PRs.

## Testsuite
SpacetimeDB branch name: master

## Testing
CI I guess?

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Bump versions to 1.2.0, as well as update the DLLs from SpacetimeDB
(commit `fc8f7dcc8`). They don't have any changes, but the versions
needed bumping.

## API

This itself is not a breaking changes.

## Requires SpacetimeDB PRs
clockworklabs/SpacetimeDB#2837

## Testsuite
SpacetimeDB branch name: release/v1.2.0

## Testing
CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
*Describe what has been changed, any new features or bug fixes*

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

## Testsuite
*If you would like to run the your SDK changes in this PR against a
specific SpacetimeDB branch, specify that here. This can be a branch
name or a link to a PR.*

SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [ ] Describe a test for this PR that you have completed

---------

Co-authored-by: Alessandro Asoni <alessandro@clockworklabs.io>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
## Description of Changes
`NetworkRequestTracker` previously was keeping all historical reducer
request data, and searching through this every frame to get statistics.
I've modified it to throw out much more data -- it's much faster now,
but only updates every few seconds.

## API

Not an API break, but deprecates an argument of one of
NetworkRequestTracker's methods to no longer do anything.

Adds new APIs.

## Requires SpacetimeDB PRs
N/A

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] Tested Bitcraft. **Their F9 debug menu will require an update,
since we now only keep one time window of request data, rather than
being able to give information about multiple windows.** But it works.
- [x] Blackholio CI
## Description of Changes
Addresses
https://github.com/clockworklabs/SpacetimeDBPrivate/issues/1786 and
clockworklabs#329.
Marks messages as parsed from the background parsing thread, and then
marks them as applied using a separate tracker once they are applied.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] Testing against Bitcraft
## Description of Changes
Updates the DLLs for
clockworklabs/SpacetimeDB#2762, and bumps our
version numbers as well.

## API

 - [ ] This is an API breaking change to the SDK

Not a breaking change

## Requires SpacetimeDB PRs
None afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Ran through Bitcraft tutorial
- [x] Blackholio on CI

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
These version bumps were supposed to happen in
clockworklabs#332,
but apparently I messed something up while I was switching branches.

## API

 - [ ] This is an API breaking change to the SDK

No breaking changes

## Requires SpacetimeDB PRs
None.

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Missed in
clockworklabs#333.

We should update the 1.2.1 tag and the `release/latest` branch after
this.

## API

 - [ ] This is an API breaking change to the SDK

Nope

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
I'm tired of messing up version updates. I "vibecoded" a script to do
it.

## API

 - [ ] This is an API breaking change to the SDK

No. No changes to runtime code.

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
```
$ python3 tools~/update-version.py 1.1.1
Updated: ./SpacetimeDB.ClientSDK.csproj
Updated: ./tests~/tests.csproj
Updated: ./examples~/regression-tests/server/StdbModule.csproj
Updated: ./examples~/regression-tests/client/client.csproj
Updated: ./examples~/quickstart-chat/server/StdbModule.csproj
Updated: ./examples~/quickstart-chat/client/client.csproj
Updated version in package.json to 1.1.1

$ git diff -U1
diff --git a/SpacetimeDB.ClientSDK.csproj b/SpacetimeDB.ClientSDK.csproj
index 5248df6..b3ca7e8 100644
--- a/SpacetimeDB.ClientSDK.csproj
+++ b/SpacetimeDB.ClientSDK.csproj
@@ -18,4 +18,4 @@
     <RepositoryUrl>https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk</RepositoryUrl>
-    <AssemblyVersion>1.2.1</AssemblyVersion>
-    <Version>1.2.1</Version>
+    <AssemblyVersion>1.1.1</AssemblyVersion>
+    <Version>1.1.1</Version>
     <DefaultItemExcludes>$(DefaultItemExcludes);*~/**</DefaultItemExcludes>
@@ -27,3 +27,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.BSATN.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.BSATN.Runtime" Version="1.1.*" />
 
diff --git a/examples~/quickstart-chat/server/StdbModule.csproj b/examples~/quickstart-chat/server/StdbModule.csproj
index 0513a81..f290d22 100644
--- a/examples~/quickstart-chat/server/StdbModule.csproj
+++ b/examples~/quickstart-chat/server/StdbModule.csproj
@@ -16,3 +16,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.Runtime" Version="1.1.*" />
   </ItemGroup>
diff --git a/examples~/regression-tests/server/StdbModule.csproj b/examples~/regression-tests/server/StdbModule.csproj
index c6b1cba..3284863 100644
--- a/examples~/regression-tests/server/StdbModule.csproj
+++ b/examples~/regression-tests/server/StdbModule.csproj
@@ -10,3 +10,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.Runtime" Version="1.1.*" />
   </ItemGroup>
diff --git a/package.json b/package.json
index 7839151..a627246 100644
--- a/package.json
+++ b/package.json
@@ -3,3 +3,3 @@
   "displayName": "SpacetimeDB SDK",
-  "version": "1.2.1",
+  "version": "1.1.1",
   "description": "The SpacetimeDB Client SDK is a software development kit (SDK) designed to interact with and manipulate SpacetimeDB modules..",
```

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
This is a fix for community bug
clockworklabs#340
that was the result of changes to SpacetimeDBClient code that missed
changes to the WebGL build.

## API

 - [ ] This is an API breaking change to the SDK

## Requires SpacetimeDB PRs
- None

## Testsuite
SpacetimeDB branch name: master

## Testing

- [X] Tested changes against Blackholio running under a Unity WebGL
build
@alex47 alex47 marked this pull request as ready for review July 21, 2025 19:01
@alex47
Copy link
Copy Markdown
Contributor Author

alex47 commented Jul 21, 2025

Root issue: clockworklabs/SpacetimeDB#2414

@bfops
Copy link
Copy Markdown
Collaborator

bfops commented Jul 22, 2025

Thank you for doing this & opening a PR! Are you willing to open it against the https://github.com/clockworklabs/SpacetimeDB/ repo in the sdks/csharp subdirectory? We're in the process of migrating all our repos into one, so this one will just be a mirror of that subdirectory.

Sorry for the confusion!

@alex47
Copy link
Copy Markdown
Contributor Author

alex47 commented Jul 22, 2025

I opened a new PR here: clockworklabs/SpacetimeDB#2975

@bfops
Copy link
Copy Markdown
Collaborator

bfops commented Jul 29, 2025

I'm going to close this PR since it has been migrated over to the main repo.

@bfops bfops closed this Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.