Skip to content

Commit 7943336

Browse files
vaindbruno-garciabitsandfoxes
authored
feat: WebGL - dotnet support (#657)
* feat: JS error example * chore: webgl sample - disable compression * fix: SentryWebGL version info sources * fix: WebGL BackgroundWorker implementation & sample packages * feat: implement WebGL with a custom HttpMessageHandler * refactor: change WebGL implementation to override HttpTransport * chore: update WebGL sample test code * feat: update SmokeTest for WebGL * test: webgl smoke test script * fix: compilation on Unity 2019 * test: finalize webGL test scripts * ci: add WebGL smoke test to CI * refactor: update WebGL to use HttpTransportBase * refactor: WebGL - use latest sentry-dotnet APIs * fix: disable async file IO on WebGL * ci: change docker image name to the new one with WebGL * fix: compilation on Unity 2020+ * refactor: move WebRequest transport to its own file * chore: update package snapshot * refactor: improve HttpRequestMessage stream type support * chore: update broken python packages on CI * chore: fix WebGL smoke test on CI * fix: SmokeTester GetTestArg when in the editor * chore: skip unity shader errors on webgl smoke test * fixup: chore: skip unity shader errors on webgl smoke test Co-authored-by: Bruno Garcia <[email protected]> Co-authored-by: Stefan Jandl <[email protected]>
1 parent ab5b781 commit 7943336

File tree

19 files changed

+876
-10
lines changed

19 files changed

+876
-10
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ jobs:
197197
path: samples/artifacts/builds/Android
198198
if-no-files-found: error
199199

200+
- name: Build WebGL Player
201+
run: |
202+
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn=http://[email protected]:8000/12345 /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
203+
docker exec unity dotnet msbuild /t:UnityBuildPlayerWebGL /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
204+
205+
- name: Upload WebGL Build
206+
uses: actions/upload-artifact@v2
207+
with:
208+
name: testapp-webgl-${{ matrix.unity-version }}
209+
path: samples/artifacts/builds/WebGL
210+
if-no-files-found: error
211+
200212
package-validation:
201213
needs: [build]
202214
name: UPM Package validation
@@ -453,3 +465,26 @@ jobs:
453465
$runtime = "iOS " + $runtime
454466
}
455467
./Scripts/smoke-test-ios.ps1 Test "$runtime"
468+
469+
webgl-smoke-test:
470+
needs: [build]
471+
name: Run WebGL Unity ${{ matrix.unity-version }} Smoke Test
472+
runs-on: ubuntu-latest
473+
strategy:
474+
fail-fast: false
475+
matrix:
476+
unity-version: ['2019', '2020', '2021']
477+
steps:
478+
- name: Checkout
479+
uses: actions/[email protected]
480+
481+
- name: Download test app artifact
482+
uses: actions/download-artifact@v2
483+
with:
484+
name: testapp-webgl-${{ matrix.unity-version }}
485+
path: samples/artifacts/builds/WebGL
486+
487+
- run: pip3 install --upgrade --user selenium urllib3 requests
488+
489+
- run: python3 scripts/smoke-test-webgl.py
490+
timeout-minutes: 10

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- WebGL - .NET support ([#657](https://github.com/getsentry/sentry-unity/pull/657))
78
- Capture `Debug.LogError()` and `Debug.LogException()` also on background threads ([#673](https://github.com/getsentry/sentry-unity/pull/673))
89

910
- Adding override for Sentry CLI URL ([#666](https://github.com/getsentry/sentry-unity/pull/666))

Directory.Build.targets

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ Related: https://forum.unity.com/threads/6572-debugger-agent-unable-to-listen-on
254254
<!-- <Error Condition="!Exists('$(IOSBuildPath)')" Text="iOS build not found. Did something go wrong?"></Error> -->
255255
</Target>
256256

257+
<!-- Build a WebGL player: dotnet msbuild /t:UnityBuildPlayerWebGL src/Sentry.Unity -->
258+
<Target Name="UnityBuildPlayerWebGL" DependsOnTargets="FindUnity" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
259+
<Error Condition="$(UnityRoot) == ''" Text="Couldn't find Unity."></Error>
260+
261+
<Message Importance="High" Text="Building the sample player for WebGL." />
262+
263+
<Exec Command="$(UnityExec) -quit -batchmode -nographics -logFile - -projectPath $(UnitySampleProjectPath) -executeMethod Builder.BuildWebGLPlayer -buildPath $(PlayerBuildPath)WebGL" IgnoreStandardErrorWarningFormat="true" />
264+
</Target>
265+
266+
<!-- Run smoke test on the WebGL player: dotnet msbuild /t:UnitySmokeTestPlayerWebGL src/Sentry.Unity -->
267+
<Target Name="UnitySmokeTestPlayerWebGL" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
268+
<Exec Command="python3 -X utf8 &quot;$(RepoRoot)/scripts/smoke-test-webgl.py&quot;" IgnoreStandardErrorWarningFormat="true"/>
269+
</Target>
270+
257271
<!-- If Unity Library Project doesn't exist, create a Unity project. We use this project to restore packages needed to build
258272
this solution without using the sample project which depends on the output of this build. -->
259273
<Target Name="UnityCreatePackages" Condition="!Exists('$(UnityPackageProject)') AND '$(MSBuildProjectName)' == 'Sentry.Unity'" AfterTargets="FindUnity">

package-dev/Runtime/SentryInitialization.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#define SENTRY_NATIVE_ANDROID
66
#elif UNITY_STANDALONE_WIN && ENABLE_IL2CPP
77
#define SENTRY_NATIVE_WINDOWS
8+
#elif UNITY_WEBGL
9+
#define SENTRY_WEBGL
810
#endif
911
#endif
1012

@@ -17,6 +19,8 @@
1719
using Sentry.Unity.Android;
1820
#elif SENTRY_NATIVE_WINDOWS
1921
using Sentry.Unity.Native;
22+
#elif SENTRY_WEBGL
23+
using Sentry.Unity.WebGL;
2024
#endif
2125

2226
[assembly: AlwaysLinkAssembly]
@@ -39,6 +43,8 @@ public static void Init()
3943
SentryNativeAndroid.Configure(options, sentryUnityInfo);
4044
#elif SENTRY_NATIVE_WINDOWS
4145
SentryNative.Configure(options);
46+
#elif SENTRY_WEBGL
47+
SentryWebGL.Configure(options);
4248
#endif
4349

4450
SentryUnity.Init(options);

samples/unity-of-bugs/Assets/Editor/Builder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group)
6767
public static void BuildLinuxIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.StandaloneLinux64, BuildTargetGroup.Standalone);
6868
public static void BuildAndroidIl2CPPPlayer() => BuildIl2CPPPlayer(BuildTarget.Android, BuildTargetGroup.Android);
6969
public static void BuildIOSPlayer() => BuildIl2CPPPlayer(BuildTarget.iOS, BuildTargetGroup.iOS);
70+
public static void BuildWebGLPlayer() => BuildIl2CPPPlayer(BuildTarget.WebGL, BuildTargetGroup.WebGL);
7071

7172
private static void SetupSentryOptions(Dictionary<string, string> args)
7273
{

0 commit comments

Comments
 (0)