Skip to content

Commit 51bbea4

Browse files
yura415claude
andcommitted
fix: bridge safety + PlayMode test migration + tick group skip
Wrap all 4 codegen'd bridge callbacks (Get/Set/GetAll/SetAll_Component) in try/catch to prevent C# exceptions from corrupting the native QuickJS call stack (SIGSEGV). Change Set_Component missing-entity log from LogError to LogWarning to avoid NUnit false positives. Add tick group skip optimization: track active tick groups via static bitmask set during script fulfillment, skip tick systems entirely when no scripts use that group. Component lifecycle ticks (fixedUpdate, lateUpdate) still run unconditionally for Fixed/AfterTransform groups. Add UpdateAllLookups before TickComponents in JsSystemRunner to refresh bridge ComponentLookups after structural changes in PlayMode tests. Migrate E2E tests from EditMode to PlayMode assemblies. Update SceneFixture for PlayMode: add ForceRediscovery for fixture system scripts, keep search paths and entities across tests. Fix flaky StressTest_SyntaxErrorRecovery_UnderPressure: assert ReloadScript returns false instead of comparing ErrorCount. 8/8 EditMode, 134/134 PlayMode tests pass. Median 12.5ms (80 FPS). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent daec5da commit 51bbea4

135 files changed

Lines changed: 861 additions & 1748 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Editor/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
[assembly: InternalsVisibleTo("UnityJS.Editor.Tests")]
44
[assembly: InternalsVisibleTo("UnityJS.Entities.PlayModeTests")]
5-
[assembly: InternalsVisibleTo("UnityJS.Entities.EditModeTests")]
65
[assembly: InternalsVisibleTo("Project.Tests.EditMode")]

Editor/Integrations/IntegrationTestHarness.cs.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.

Integrations/ALINE/Tests/EditMode/DrawBridgeE2ETests.cs.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.

Integrations/ALINE/Tests/EditMode/JsDrawIntegrationE2ETests.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

Integrations/ALINE/Tests/EditMode/JsDrawIntegrationE2ETests.cs.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.

Integrations/ALINE/Tests/EditMode/DrawBridgeE2ETests.cs renamed to Integrations/ALINE/Tests/PlayMode/DrawBridgeE2ETests.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
namespace UnityJS.Integration.ALINE.EditModeTests
1+
namespace UnityJS.Integration.ALINE.PlayModeTests
22
{
33
using System.Collections;
4-
using Entities.EditModeTests;
5-
using Entities.Tests;
4+
using UnityJS.Entities.Tests;
65
using NUnit.Framework;
76
using Unity.Entities;
87
using Unity.Mathematics;
@@ -17,16 +16,27 @@ public class DrawBridgeE2ETests
1716
const string SCRIPT = "components/e2e_draw_probe";
1817
const int INIT_FRAMES = 10;
1918

19+
SceneFixture m_Scene;
20+
21+
[SetUp]
22+
public void SetUp()
23+
{
24+
m_Scene = new SceneFixture(World.DefaultGameObjectInjectionWorld);
25+
}
26+
27+
[TearDown]
28+
public void TearDown()
29+
{
30+
m_Scene?.Dispose();
31+
}
32+
2033
[UnityTest]
2134
public IEnumerator Draw_AllFunctions_CallableFromComponent()
2235
{
23-
yield return new EnterPlayMode();
24-
var world = World.DefaultGameObjectInjectionWorld;
25-
using var scene = new SceneFixture(world);
26-
var entity = scene.Spawn(SCRIPT);
27-
var eid = scene.GetEntityId(entity);
36+
var entity = m_Scene.Spawn(SCRIPT);
37+
var eid = m_Scene.GetEntityId(entity);
2838
for (var i = 0; i < INIT_FRAMES; i++) yield return null;
29-
Assert.IsTrue(scene.AllFulfilled(), "Script must be fulfilled");
39+
Assert.IsTrue(m_Scene.AllFulfilled(), "Script must be fulfilled");
3040

3141
var error = JsEval.Bool($"!!_e2e_draw[{eid}]?.error");
3242
Assert.IsFalse(error,
@@ -38,8 +48,6 @@ public IEnumerator Draw_AllFunctions_CallableFromComponent()
3848
// 8 draw calls: setColor, line, ray, wireSphere, wireBox, solidBox, circleXz, arrow
3949
var callCount = JsEval.Int($"_e2e_draw[{eid}]?.callCount ?? -1");
4050
Assert.AreEqual(8, callCount, "All 8 draw functions must have been called");
41-
42-
yield return new ExitPlayMode();
4351
}
4452
}
4553
}

Integrations/ALINE/Tests/PlayMode/DrawBridgeE2ETests.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace UnityJS.Integration.ALINE.PlayModeTests
2+
{
3+
using System.Collections;
4+
using NUnit.Framework;
5+
using UnityEngine.TestTools;
6+
using UnityJS.Runtime;
7+
8+
/// <summary>
9+
/// E2E test verifying ALINE draw integration produces no JS errors.
10+
/// </summary>
11+
[TestFixture]
12+
public class JsDrawIntegrationE2ETests
13+
{
14+
[UnityTest]
15+
public IEnumerator PlayModeCycle_DrawBridge_NoErrors()
16+
{
17+
var vm = JsRuntimeManager.Instance;
18+
Assert.IsNotNull(vm, "JsRuntimeManager should exist in play mode");
19+
20+
yield return null;
21+
22+
if (vm != null)
23+
Assert.IsEmpty(vm.CapturedExceptions, "No JS exceptions after draw bridge frame");
24+
}
25+
}
26+
}

Integrations/ALINE/Tests/PlayMode/JsDrawIntegrationE2ETests.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Integrations/ALINE/Tests/EditMode/UnityJS.Integration.ALINE.EditModeTests.asmdef renamed to Integrations/ALINE/Tests/PlayMode/UnityJS.Integration.ALINE.PlayModeTests.asmdef

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "UnityJS.Integration.ALINE.EditModeTests",
3-
"rootNamespace": "UnityJS.Integration.ALINE.EditModeTests",
2+
"name": "UnityJS.Integration.ALINE.PlayModeTests",
3+
"rootNamespace": "UnityJS.Integration.ALINE.PlayModeTests",
44
"references": [
55
"UnityJS.QJS",
66
"UnityJS.Runtime",
@@ -11,14 +11,9 @@
1111
"Unity.Collections",
1212
"ALINE",
1313
"UnityEngine.TestRunner",
14-
"UnityEditor.TestRunner",
15-
"UnityJS.Integrations.Editor",
16-
"UnityJS.Entities.EditModeTests",
1714
"UnityJS.Entities.TestUtils"
1815
],
19-
"includePlatforms": [
20-
"Editor"
21-
],
16+
"includePlatforms": [],
2217
"excludePlatforms": [],
2318
"allowUnsafeCode": true,
2419
"overrideReferences": true,

0 commit comments

Comments
 (0)