getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
206 stars 51 forks source link

Assembly Alias causes `System.Text.Json` exception #1777

Open bitsandfoxes opened 2 weeks ago

bitsandfoxes commented 2 weeks ago

Steps to reproduce:

  1. Build the SDK with TFM netstandard2.1 (i.e. using Unity 2022 or newer)
  2. Run the aliasing tool
  3. Attempt to capture an error, session, transaction
  4. Observe the following error while the SDK attempts to serialize an envelope
    TypeLoadException: VTable setup of type System.Text.Json.Utf8JsonWriter failed

This does not happen when skipping the aliasing step.

bitsandfoxes commented 2 weeks ago

As workarounds:

  1. Use version Unity 2021 or older to build the SDK - and that's how CI does it
  2. Disable aliasing when packing/repacking the SDK
sambonfire commented 2 weeks ago

Workaround #1 won't work for us, so I attempted workaround #2. It worked in editor, but when I did a player build, it crashes with a new error:

System.Text.Json.Utf8JsonWriter doesn't implement interface System.IAsyncDisposable
bruno-garcia commented 3 days ago

Since we're SOL on this one, I'll try my luck and see if @xoofx has any idea what might be going on 🙏

tl;dr: Same code base, if we build with netstandard2.1 (i.e. using Unity 2022 or newer) it crashes. Works if we build with ns2.0.