Skip to content

Commit

Permalink
[IFC] force single-threading to avoid crashes
Browse files Browse the repository at this point in the history
added test case for multi thread problem
  • Loading branch information
WalchAndreas committed Jul 9, 2024
1 parent e1ac71f commit e9992c5
Show file tree
Hide file tree
Showing 4 changed files with 486 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Aardvark.Data.Ifc/IFCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static IFCData PreprocessIFC(string filePath, XbimEditorCredentials edito
if (model.GeometryStore.IsEmpty)
{
var context = new Xbim3DModelContext(model);
context.MaxThreads = 1;
//upgrade to new geometry representation, uses the default 3D model
context.CreateContext(null, true, false); // THIS IS COSTLY!
}
Expand Down
14 changes: 14 additions & 0 deletions src/Tests/IfcTests/IfcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,19 @@ public static void LoadSlab()
Assert.AreEqual(2, parsed.Materials.Count);
});
}

[Test]
public static void MultiThreadKiller()
{
// NOTE: In IFCParser -> change MaxThreads!
// var context = new Xbim3DModelContext(model);
// context.MaxThreads = 1; <- SINGLE-Thread works!
// context.CreateContext(null, true, false);

LoadEmbeddedData(@"data\simple_scene.ifc", (filePath) => {
var parsed = IFCParser.PreprocessIFC(filePath);
Assert.AreEqual(5, parsed.Materials.Count);
});
}
}
}
1 change: 1 addition & 0 deletions src/Tests/IfcTests/IfcTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ItemGroup>
<EmbeddedResource Include="data\slab.ifc" />
<EmbeddedResource Include="data\surface-model.ifc" />
<EmbeddedResource Include="data\simple_scene.ifc" />
<EmbeddedResource Include="data\wall.ifc" />
</ItemGroup>
<Import Project="..\..\..\.paket\Paket.Restore.targets" />
Expand Down
Loading

0 comments on commit e9992c5

Please sign in to comment.