Skip to content

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

Closed

Description

@ripperdoc

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!

Activity

  1. bruno-garcia commented on Jan 14, 2022

    @bruno-garcia
    Member

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

  2. ripperdoc commented on Jan 19, 2022

    @ripperdoc
    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.

  3. ripperdoc commented on Jan 26, 2022

    @ripperdoc
    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.

  4. bitsandfoxes commented on Jan 27, 2022

    @bitsandfoxes
    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.

  5. self-assigned this
    on Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions