XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

On Azure (winx64) deployed it generates gltf with missing geometry

Open rubit0 opened this issue 1 year ago • 1 comments

I made a asp.net (dotnet 8) web app to convert a ifc file to gltf but when deployed to azure (standard winx64 dotnet appservice plan) it generates a gltf with missing geometry. I tried all sort of combinations, self-contained single file, x64, x86, and the default dotnet 8 runtime.

bim2go_backend_3d-problem

There are no errors and I exhausted all possible deployment configuration options. I'm using the latest stable releases:

<PackageReference Include="Xbim.Essentials" Version="6.0.445" />
<PackageReference Include="Xbim.Geometry" Version="5.1.541" />
<PackageReference Include="Xbim.Gltf.IO" Version="5.1.120" />

This is the main code snipped that generates the gltf:

public static byte[] CreateGltf(Stream ifcFileStream)
{
    using var ifcStore = IfcStore.Open(ifcFileStream,
        Xbim.IO.StorageType.Ifc,
        Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3,
        Xbim.IO.XbimModelType.MemoryModel);

    var context3DModel = new Xbim3DModelContext(ifcStore);
    context3DModel.CreateContext(null, false);
    var sceneBuilder = new Builder();
    var gltf = sceneBuilder.BuildInstancedScene(ifcStore, XbimMatrix3D.Identity, new List<Type>
        {
            typeof(IIfcSpace),
            typeof(IIfcFeatureElement)
        });

    using (var memoryStream = new MemoryStream())
    {
        Interface.SaveModel(gltf, memoryStream);
        return memoryStream.ToArray();
    }
}

I would love to find out how to fix this issue, in theory there should be no difference between my dotnet runtime and the one on azure. Could this be a floating point precision issue?

rubit0 avatar Jul 30 '24 12:07 rubit0

Very strange. We've used Xbim.Geometry 5.1 & 6 extensively in azure app services (winx86 and winx64) and not seen this kind of 'partial' failure. Azure issues are usually all or nothing (environmental etc) rather than this kind of thing. However we're not using gltf which may add another layer of complexity.

Things to check:

  • Is it 100% repeatable? Is it always the same elements missing?
  • Does it occur with other models, or just this one?
  • Have you tried setting the number of threads to 1? (i.e. Xbim3DModelContext.MaxThreads = 1)
  • Have you managed to get any logs from the Geometry Engine (using an ILogger)
  • Have you tried generating wexbim rather than glTF to establish if it's a core GE issue vs gltf export
  • Have you tried stripping the model down to a the affected walls & openings?

It looks like it's failing to cut the openings (a boolean operation in OpenCascade). That might point at a few things including:

  • Precision (as you mention) - try adjusting the precision on ModelFactors
  • wrong / incompatible VC/Windows runtime (Kudu may be able to tell you what's installed)
  • a threading issue
  • potentially an endian edge case?

andyward avatar Aug 07 '24 15:08 andyward