You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled across #149 also in pursuit of using supabase-csharp with realtime features for a Unity WebGL app, and want to let folks know what I've learned.
I think there's some confusion about what's incompatible about the web environment.
When building a Unity project that uses supabase-csharp (and supabase-realtime) to web, it crashes immediately upon boot with something like Uncaught RuntimeError: null function or function signature mismatch, showing up in a browser alert window.
That's when I started searching and found this #149. I tried out the WebGLThreadingPatcher library you suggested @wiverson, but it still crashed, with seemingly no difference.
Then I made a development build and saw that the error is coming from the logger:
Build.framework.js:337 Uncaught RuntimeError: memory access out of bounds
at LogProvider_GetCurrentClassLogger_m1F55E16ECAC60254069E96E7BADEE9F667745E21 (Build.wasm:0x26cbc73)
at dynCall_ii (Build.wasm:0x4751338)
at Build.framework.js:1815:22
at invoke_ii (Build.framework.js:19375:12)
at WebsocketClient_GetLogger_m8F836197E6E2E18E72EE3EF1FCF5C97D29F0D76B (Build.wasm:0x26cba65)
at WebsocketClient__cctor_mFE6E849D4288EFF63C63B14B6732956F9D4E70BE (Build.wasm:0x26cca11)
re-compiling supabase-realtime myself, changing the websocket-client dependency to 5.1, and using .NET Standard 2.1.
putting that DLL in my Unity project, copying in the .netstandard2.1 compilation output folder into Packages/realtime-csharp.6.0.4/lib/ forcing the whole Packages/realtime-csharp.6.0.4 directory into source control.
and updating the NuGet packages.config to use 5.1.0:
<package id="Websocket.Client" version="5.1.0" />
Then making a new web build, it no longer crashes immediately, but it does throw an exception:
Exception: Error: called non-existent method System.IObservable`1<Websocket.Client.Models.ReconnectionInfo> Websocket.Client.WebsocketClient::get_ReconnectionHappened()
I don't fully understand why that method is missing, but I think it's because there's no System.Net support for Unity building to web. I don't think it's failing because of lack of proper support for threading support on web.
You can’t use any .NET networking classes within the Web platform because JavaScript code doesn’t have direct access to internet protocol (IP) sockets to implement network connectivity. Specifically, Web doesn’t support any .NET classes within the System.Net namespace. docs
The classes of System.Net are stubbed out. For example, if you try and make a websocket client from System.Net.WebSocket and connect to a server, it doesn't crash. It silently fails, hanging forever.
Therefore, any C# WebSocket library will need a special Unity version that works around the missing System.Net.WebSocket via conditionals and a web plugin -- .jslib files. See here in unity-websocket for example.
I don't really know the best way to do that for cases like this, where the packages (supabase-csharp, supabase-realtime and websocket-client) are pre-compiled and published to NuGet, i.e. not part of the Unity build process and its jslib plugin machinery. Adding the jslib pieces to websocket-client and publishing it, supabase-realtime and supabase-csharp as Unity packages, too? That seems inconvenient to the point of unlikely... Would love to hear any suggestions folks have!
All that to say, I think supabase-csharp will work just fine on Unity WebGL if it uses a WebSocket library that has that jslib architecture in place.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I stumbled across #149 also in pursuit of using supabase-csharp with realtime features for a Unity WebGL app, and want to let folks know what I've learned.
I think there's some confusion about what's incompatible about the web environment.
When building a Unity project that uses supabase-csharp (and supabase-realtime) to web, it crashes immediately upon boot with something like
Uncaught RuntimeError: null function or function signature mismatch
, showing up in a browser alert window.That's when I started searching and found this #149. I tried out the
WebGLThreadingPatcher
library you suggested @wiverson, but it still crashed, with seemingly no difference.Then I made a development build and saw that the error is coming from the logger:
In the most recent major version of
websocket-client
, they changed out the logger https://github.com/Marfusios/websocket-client/releases/tag/v5.0. So I tried using that version manually. That entailed:re-compiling supabase-realtime myself, changing the
websocket-client
dependency to 5.1, and using .NET Standard 2.1.putting that DLL in my Unity project, copying in the .netstandard2.1 compilation output folder into
Packages/realtime-csharp.6.0.4/lib/
forcing the wholePackages/realtime-csharp.6.0.4
directory into source control.and updating the NuGet
packages.config
to use 5.1.0:Then making a new web build, it no longer crashes immediately, but it does throw an exception:
That's coming from https://github.com/supabase-community/realtime-csharp/blob/v5.0.5/Realtime/RealtimeSocket.cs#L116.
I don't fully understand why that method is missing, but I think it's because there's no
System.Net
support for Unity building to web. I don't think it's failing because of lack of proper support for threading support on web.The classes of
System.Net
are stubbed out. For example, if you try and make a websocket client fromSystem.Net.WebSocket
and connect to a server, it doesn't crash. It silently fails, hanging forever.Therefore, any C# WebSocket library will need a special Unity version that works around the missing
System.Net.WebSocket
via conditionals and a web plugin -- .jslib files. See here inunity-websocket
for example.I don't really know the best way to do that for cases like this, where the packages (
supabase-csharp
,supabase-realtime
andwebsocket-client
) are pre-compiled and published to NuGet, i.e. not part of the Unity build process and its jslib plugin machinery. Adding the jslib pieces towebsocket-client
and publishing it,supabase-realtime
andsupabase-csharp
as Unity packages, too? That seems inconvenient to the point of unlikely... Would love to hear any suggestions folks have!All that to say, I think supabase-csharp will work just fine on Unity WebGL if it uses a WebSocket library that has that jslib architecture in place.
Beta Was this translation helpful? Give feedback.
All reactions