Improve WebGL Support

オープン
#2,415 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp, unity

調査の方向性

DebugStackTrace.cs と AotHelper.cs の WebGL スタックトレースパスから始め、次に SentryInitialization.cs で無効化されている起動時トレーシングの統合を確認します。SmokeTester.cs と既存の WebGL スモークテスト構成を使用して、動作を調査します。選択した例外、ロギング、または起動時トレーシングの改善を対象とする、定義済みの WebGL スコープとテストが用意されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Errors Feature Unity
Description

The SDK's WebGL support is currently limited to C#.

Current Limitations

PlayerSettings.WebGL.exceptionSupport
  • None - Not supported. See https://github.com/getsentry/sentry-unity/pull/2141 for more details.
  • Explicitly Thrown Exceptions Only - Captures and reports exceptions but misses stack trace.
  • Full Without Stacktrace - Captures and reports exceptions but misses stacktrace.
  • Full With Stacktrace- Captures and reports exception and provides a stacktrace (albeit with no line numbers due to lack of IL2CPP backend availability)
Fails to create new StackTrace()

This is happening with Explicitly Thrown Exceptions Only and Full Without Stacktrace.
The SDK fails trying to create a new SentryStackTrace. The SDK fails with Could not resolve stack frame. This is due to the DebugStackTrace failing to create a managed frame. It relies on the following snippet used in the AotHelper

var stackTrace = new StackTrace(false);
return stackTrace.GetFrame(0)?.GetMethod() is null;

To resolve this we could provide our own dedicated WebGLStackTraceFactory to create a new frame and fall back on stackFrame.ToString() instead of doing nothing. And probably skip a whole lot of other, for WebGL unnecessary checks i.e.

if (CreateFrame(stackFrame) is { } frame)
{
    yield return frame;
}
else
{
    yield return new SentryStackFrame { Function = stackFrame.ToString() };
}
Missing stack trace for LogError events

The missing stacktrace also mentioned in https://github.com/getsentry/sentry-unity/issues/2091#issuecomment-2839750715 is also related to the PlayerSettings.WebGL.exceptionSupport. When setting to FullWithStacktrace the SDK is able to provide stack traces for these events as well. Set to any other option Unity does not pass down a stack trace to the logging integration and we'd need to create a new stack trace, bringing us back to the point above.

Current Recommendation

The current recommendation is to set PlayerSettings.WebGL.exceptionSupport to Full With Stacktrace to get the most out of the SDK. Anything else will require us to build a WebGL specific integration to better handle those cases.

Future Plans

Native Support

Taken from @vaind https://github.com/getsentry/sentry-unity/issues/668#issuecomment-1099453415

Stack traces for the embedded code coming from Unity's .jslib are pretty limited. They're just not there on the error reported by the browser.

The integration could still be useful at least to get the error type/text + stack traces if they're coming from standard javascript files.

  1. Add sentry-js bundle to the sentry-unity package. The minified version should be fine: https://browser.sentry-cdn.com/10.24.0/bundle.min.js
  2. Create a PostBuild step to alter the generated index.html, adding the Sentry-javascript initialization to the beginning of <head>:
<script src="Build/bundle.js"></script>
<script>
  Sentry.init({
    dsn: "https://[email protected]/5439417",
    release: "0.1.0",
    ....
});
</script>
  1. We're already smoke testing for WebGL. Use the SmokeTester.cs to create a javascript error. The existing python server would capture and check that.
  2. [optional] Implement scope sync - requires individual functions, similar to Objective-C
Startup Tracing

Currently, the startup tracing integration is disabled for WebGL due to the UnityWebRequestTransport seemingly not being ready this early in the runtime.

https://github.com/getsentry/sentry-unity/blob/ec8cc5bd9df3a572e0323ad44b17e61c5de706c6/package-dev/Runtime/SentryInitialization.cs#L52-L58

This could be solved by creating timestamps instead of starting the spans and creating and sending the transaction after the fact.

主要言語
C#
スター
294
フォーク
63
平均マージ
3日 17時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-unity のほかの issue

getsentry/sentry-unity の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。