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
{{ message }}
Repository navigation
Question/Suggestion: when/how to get WebGL working #516
I understand sentry-unity doesn't support WebGL, because of single-threading (?). But as our app run on many platforms, is there a way I can re-use most of the Sentry logic for building the events, but just do the actual sending myself with UnityWebRequest? Is there a way I could capture the event to be sent and handle it myself?
And are there any plans to make WebGL builds work with this plugin?
Just an interim update on my workaround: the BeforeSend hook can be used to intercept the SentryEvent on WebGL, but when I try to re-use the JSON writer logic I get a compilation error. E.g. with this function as BeforeSend hook:
private SentryEvent? SendSentryEventFallback(SentryEvent ev)
{
using var stream = new MemoryStream();
using var writer = new Utf8JsonWriter(stream);
ev.WriteTo(writer);
string json = Encoding.UTF8.GetString(stream.ToArray());
Debug.Log(json);
return null;
}
It looks fine in VS Code but Unity complains about 'Utf8JsonWriter' is inaccessible due to its protection level. Can't understand why as this is a public C# class, but maybe Unity is hiding System.Text.Json classes? If I can't get that to work I guess I have to serialize it manually.
Another update: I wasn't able to get access to Utf8JsonWriter so had to do it the hard way - serializing SentryEvent and Envelopes semi-manually using Newtonsoft. Of course, that meant some guesses to map property names to correct JSON version. I would have wished for some more support for pluggable clients/transport/serialization (or I failed to find the right one). But at least I can send errors from WebGL to Sentry now.
Thanks for the updates! It's really highly appreciated.
We've made some progress too and have a working draft from which to work off of: #329, which does exactly that. It replaces the transport and uses a Unity callback to work around the limitation on background threads. We'll keep the idea of plug&play in mind going forward.
The problem with the Utf8JsonWriter is that we alias all the dependencies that we bring to avoid conflicting with other packages.
Activity
bruno-garcia commentedon Jan 14, 2022
We want to look into WebGL in the next 2 or 3 months. We had some initial experimentation already: #329
ripperdoc commentedon Jan 19, 2022
Just an interim update on my workaround: the BeforeSend hook can be used to intercept the SentryEvent on WebGL, but when I try to re-use the JSON writer logic I get a compilation error. E.g. with this function as BeforeSend hook:
It looks fine in VS Code but Unity complains about
'Utf8JsonWriter' is inaccessible due to its protection level. Can't understand why as this is a public C# class, but maybe Unity is hiding System.Text.Json classes? If I can't get that to work I guess I have to serialize it manually.ripperdoc commentedon Jan 26, 2022
Another update: I wasn't able to get access to Utf8JsonWriter so had to do it the hard way - serializing SentryEvent and Envelopes semi-manually using Newtonsoft. Of course, that meant some guesses to map property names to correct JSON version. I would have wished for some more support for pluggable clients/transport/serialization (or I failed to find the right one). But at least I can send errors from WebGL to Sentry now.
bitsandfoxes commentedon Jan 27, 2022
Thanks for the updates! It's really highly appreciated.
We've made some progress too and have a working draft from which to work off of: #329, which does exactly that. It replaces the transport and uses a Unity callback to work around the limitation on background threads. We'll keep the idea of plug&play in mind going forward.
The problem with the
Utf8JsonWriteris that we alias all the dependencies that we bring to avoid conflicting with other packages.