Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/Suggestion: when/how to get WebGL working #516

Closed
ripperdoc opened this issue Jan 13, 2022 · 4 comments · Fixed by #657
Closed

Question/Suggestion: when/how to get WebGL working #516

ripperdoc opened this issue Jan 13, 2022 · 4 comments · Fixed by #657
Assignees
Labels
Feature New feature or request WebGL

Comments

@ripperdoc
Copy link

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?

Thanks!

@bruno-garcia bruno-garcia added Feature New feature or request WebGL labels Jan 14, 2022
@bruno-garcia
Copy link
Member

We want to look into WebGL in the next 2 or 3 months. We had some initial experimentation already: #329

@ripperdoc
Copy link
Author

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.

@ripperdoc
Copy link
Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request WebGL
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants