Skip to content

Commit

Permalink
chore: disable screenshot capture on WebGL
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Apr 21, 2022
1 parent d52ce44 commit 77e95c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/smoke-test-webgl.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ def waitUntil(condition, interval=0.1, timeout=1):
currentMessage += 1
t.ExpectMessage(currentMessage, "'type':'event'")
t.ExpectMessage(currentMessage, "LogError(GUID)")
t.ExpectMessage(
currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
t.ExpectMessageNot(currentMessage, "'length':0")
# t.ExpectMessage(
# currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
# t.ExpectMessageNot(currentMessage, "'length':0")
currentMessage += 1
t.ExpectMessage(currentMessage, "'type':'event'")
t.ExpectMessage(currentMessage, "CaptureMessage(GUID)")
t.ExpectMessage(
currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
t.ExpectMessageNot(currentMessage, "'length':0")
# t.ExpectMessage(
# currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
# t.ExpectMessageNot(currentMessage, "'length':0")
currentMessage += 1
t.ExpectMessage(currentMessage, "'type':'event'")
t.ExpectMessage(
Expand All @@ -163,7 +163,7 @@ def waitUntil(condition, interval=0.1, timeout=1):
t.ExpectMessage(currentMessage, "'tags':{'tag-key':'tag-value'")
t.ExpectMessage(
currentMessage, "'user':{'email':'email@example.com','id':'user-id','ip_address':'::1','username':'username','other':{'role':'admin'}}")
t.ExpectMessage(
currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
t.ExpectMessageNot(currentMessage, "'length':0")
# t.ExpectMessage(
# currentMessage, "'filename':'screenshot.jpg','attachment_type':'event.attachment'")
# t.ExpectMessageNot(currentMessage, "'length':0")
print('TEST: PASS', flush=True)
2 changes: 2 additions & 0 deletions src/Sentry.Unity.Editor/ConfigurationWindow/EnrichmentTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ internal static void Display(ScriptableSentryUnityOptions options)
{
options.AttachScreenshot = EditorGUILayout.BeginToggleGroup(
new GUIContent("Attach Screenshot", "Try to attach current screenshot on events.\n" +
"This is an early-access feature and may not work on all platforms (it is explicitly disabled on WebGL).\n" +
"Additionally, the screenshot is captured mid-frame, when an event happens, so it may be incomplete.\n" +
"A screenshot might not be able to be attached, for example when the error happens on a background thread."),
options.AttachScreenshot);
options.ScreenshotMaxWidth = EditorGUILayout.IntField(
Expand Down
7 changes: 7 additions & 0 deletions src/Sentry.Unity/WebGL/SentryWebGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public static void Configure(SentryUnityOptions options)

// Disable async when accessing files (e.g. FileStream(useAsync: true)) because it throws on WebGL.
options.UseAsyncFileIO = false;

if (options.AttachScreenshot)
{
options.AttachScreenshot = false;
options.DiagnosticLogger?.LogWarning("Attaching screenshots on WebGL is disabled - " +
"it currently produces blank screenshots mid-frame.");
}
}
}
}

0 comments on commit 77e95c5

Please sign in to comment.